Auto merge of #55922 - oli-obk:slice_pat_ice, r=zackmdavis
Fix ICE in `const` slice patterns fixes #55911 based on https://github.com/rust-lang/rust/pull/55915 New commits start at eabc1551e0d0953f1951020afb5919ab4c129cf5
This commit is contained in:
commit
21cb46a6e9
5 changed files with 132 additions and 66 deletions
24
src/test/ui/pattern/slice-pattern-const-2.rs
Normal file
24
src/test/ui/pattern/slice-pattern-const-2.rs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
// compile-pass
|
||||
|
||||
fn main() {
|
||||
let s = &[0x00; 4][..]; //Slice of any value
|
||||
const MAGIC_TEST: &[u32] = &[4, 5, 6, 7]; //Const slice to pattern match with
|
||||
match s {
|
||||
MAGIC_TEST => (),
|
||||
[0x00, 0x00, 0x00, 0x00] => (),
|
||||
[4, 5, 6, 7] => (), // this should warn
|
||||
_ => (),
|
||||
}
|
||||
match s {
|
||||
[0x00, 0x00, 0x00, 0x00] => (),
|
||||
MAGIC_TEST => (),
|
||||
[4, 5, 6, 7] => (), // this should warn
|
||||
_ => (),
|
||||
}
|
||||
match s {
|
||||
[0x00, 0x00, 0x00, 0x00] => (),
|
||||
[4, 5, 6, 7] => (),
|
||||
MAGIC_TEST => (), // this should warn
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
24
src/test/ui/pattern/slice-pattern-const-3.rs
Normal file
24
src/test/ui/pattern/slice-pattern-const-3.rs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
// compile-pass
|
||||
|
||||
fn main() {
|
||||
let s = &["0x00"; 4][..]; //Slice of any value
|
||||
const MAGIC_TEST: &[&str] = &["4", "5", "6", "7"]; //Const slice to pattern match with
|
||||
match s {
|
||||
MAGIC_TEST => (),
|
||||
["0x00", "0x00", "0x00", "0x00"] => (),
|
||||
["4", "5", "6", "7"] => (), // this should warn
|
||||
_ => (),
|
||||
}
|
||||
match s {
|
||||
["0x00", "0x00", "0x00", "0x00"] => (),
|
||||
MAGIC_TEST => (),
|
||||
["4", "5", "6", "7"] => (), // this should warn
|
||||
_ => (),
|
||||
}
|
||||
match s {
|
||||
["0x00", "0x00", "0x00", "0x00"] => (),
|
||||
["4", "5", "6", "7"] => (),
|
||||
MAGIC_TEST => (), // this should warn
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
24
src/test/ui/pattern/slice-pattern-const.rs
Normal file
24
src/test/ui/pattern/slice-pattern-const.rs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
//compile-pass
|
||||
|
||||
fn main() {
|
||||
let s = &[0x00; 4][..]; //Slice of any value
|
||||
const MAGIC_TEST: &[u8] = b"TEST"; //Const slice to pattern match with
|
||||
match s {
|
||||
MAGIC_TEST => (),
|
||||
[0x00, 0x00, 0x00, 0x00] => (),
|
||||
[84, 69, 83, 84] => (), // this should warn
|
||||
_ => (),
|
||||
}
|
||||
match s {
|
||||
[0x00, 0x00, 0x00, 0x00] => (),
|
||||
MAGIC_TEST => (),
|
||||
[84, 69, 83, 84] => (), // this should warn
|
||||
_ => (),
|
||||
}
|
||||
match s {
|
||||
[0x00, 0x00, 0x00, 0x00] => (),
|
||||
[84, 69, 83, 84] => (),
|
||||
MAGIC_TEST => (), // this should warn
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue