From 8a9414ae19ad16468935ca30930e45d1ae91aa59 Mon Sep 17 00:00:00 2001 From: Oliver Scherer Date: Fri, 7 Dec 2018 19:06:22 +0100 Subject: [PATCH] Add a few more tests of edge cases --- src/test/ui/pattern/slice-pattern-const-2.rs | 7 ++++++ src/test/ui/pattern/slice-pattern-const-3.rs | 7 ++++++ src/test/ui/pattern/slice-pattern-const.rs | 23 ++++++++++++++++++++ 3 files changed, 37 insertions(+) diff --git a/src/test/ui/pattern/slice-pattern-const-2.rs b/src/test/ui/pattern/slice-pattern-const-2.rs index 6f9501d025c..15c23b39b01 100644 --- a/src/test/ui/pattern/slice-pattern-const-2.rs +++ b/src/test/ui/pattern/slice-pattern-const-2.rs @@ -21,4 +21,11 @@ fn main() { MAGIC_TEST => (), // this should warn _ => (), } + const FOO: [u32; 1] = [4]; + match [99] { + [0x00] => (), + [4] => (), + FOO => (), // this should warn + _ => (), + } } diff --git a/src/test/ui/pattern/slice-pattern-const-3.rs b/src/test/ui/pattern/slice-pattern-const-3.rs index e7a30cef57a..dbc61af16b5 100644 --- a/src/test/ui/pattern/slice-pattern-const-3.rs +++ b/src/test/ui/pattern/slice-pattern-const-3.rs @@ -21,4 +21,11 @@ fn main() { MAGIC_TEST => (), // this should warn _ => (), } + const FOO: [&str; 1] = ["boo"]; + match ["baa"] { + ["0x00"] => (), + ["boo"] => (), + FOO => (), // this should warn + _ => (), + } } diff --git a/src/test/ui/pattern/slice-pattern-const.rs b/src/test/ui/pattern/slice-pattern-const.rs index d353f6cddbd..e2589ddf81c 100644 --- a/src/test/ui/pattern/slice-pattern-const.rs +++ b/src/test/ui/pattern/slice-pattern-const.rs @@ -21,4 +21,27 @@ fn main() { MAGIC_TEST => (), // this should warn _ => (), } + const FOO: [u8; 1] = [4]; + match [99] { + [0x00] => (), + [4] => (), + FOO => (), // this should warn + _ => (), + } + const BAR: &[u8; 1] = &[4]; + match &[99] { + [0x00] => (), + [4] => (), + BAR => (), // this should warn + b"a" => (), + _ => (), + } + + const BOO: &[u8; 0] = &[]; + match &[] { + [] => (), + BOO => (), // this should warn + b"" => (), + _ => (), + } }