diff --git a/src/test/ui/pattern/slice-pattern-const-2.rs b/src/test/ui/pattern/slice-pattern-const-2.rs index 6f9501d025c2..15c23b39b01f 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 e7a30cef57a8..dbc61af16b56 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 d353f6cddbd0..e2589ddf81c6 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"" => (), + _ => (), + } }