Skip to content

Commit 8f9a093

Browse files
committed
Fix another related ICE
1 parent 28cc340 commit 8f9a093

File tree

4 files changed

+40
-6
lines changed

4 files changed

+40
-6
lines changed

src/librustc_mir/hair/pattern/_match.rs

-5
Original file line numberDiff line numberDiff line change
@@ -1355,11 +1355,6 @@ fn slice_pat_covered_by_constructor<'tcx>(
13551355
ConstValue::Scalar(val) | ConstValue::ScalarPair(val, _) => val,
13561356
};
13571357
if let Ok(ptr) = val.to_ptr() {
1358-
let is_array_ptr = const_val.ty
1359-
.builtin_deref(true)
1360-
.and_then(|t| t.ty.builtin_index())
1361-
.map_or(false, |t| t == tcx.types.u8);
1362-
assert!(is_array_ptr);
13631358
tcx.alloc_map.lock().unwrap_memory(ptr.alloc_id).bytes.as_ref()
13641359
} else {
13651360
bug!("unexpected non-ptr ConstantValue")

src/test/ui/pattern/slice-pattern-const-2.rs

+13
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,19 @@ fn main() {
66
match s {
77
MAGIC_TEST => (),
88
[0x00, 0x00, 0x00, 0x00] => (),
9+
[4, 5, 6, 7] => (), // this should warn
10+
_ => (),
11+
}
12+
match s {
13+
[0x00, 0x00, 0x00, 0x00] => (),
14+
MAGIC_TEST => (),
15+
[4, 5, 6, 7] => (), // this should warn
16+
_ => (),
17+
}
18+
match s {
19+
[0x00, 0x00, 0x00, 0x00] => (),
20+
[4, 5, 6, 7] => (),
21+
MAGIC_TEST => (), // this should warn
922
_ => (),
1023
}
1124
}

src/test/ui/pattern/slice-pattern-const-3.rs

+13
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,19 @@ fn main() {
66
match s {
77
MAGIC_TEST => (),
88
["0x00", "0x00", "0x00", "0x00"] => (),
9+
["4", "5", "6", "7"] => (), // this should warn
10+
_ => (),
11+
}
12+
match s {
13+
["0x00", "0x00", "0x00", "0x00"] => (),
14+
MAGIC_TEST => (),
15+
["4", "5", "6", "7"] => (), // this should warn
16+
_ => (),
17+
}
18+
match s {
19+
["0x00", "0x00", "0x00", "0x00"] => (),
20+
["4", "5", "6", "7"] => (),
21+
MAGIC_TEST => (), // this should warn
922
_ => (),
1023
}
1124
}
+14-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,24 @@
1-
// compile-pass
1+
//compile-pass
22

33
fn main() {
44
let s = &[0x00; 4][..]; //Slice of any value
55
const MAGIC_TEST: &[u8] = b"TEST"; //Const slice to pattern match with
66
match s {
77
MAGIC_TEST => (),
88
[0x00, 0x00, 0x00, 0x00] => (),
9+
[84, 69, 83, 84] => (), // this should warn
10+
_ => (),
11+
}
12+
match s {
13+
[0x00, 0x00, 0x00, 0x00] => (),
14+
MAGIC_TEST => (),
15+
[84, 69, 83, 84] => (), // this should warn
16+
_ => (),
17+
}
18+
match s {
19+
[0x00, 0x00, 0x00, 0x00] => (),
20+
[84, 69, 83, 84] => (),
21+
MAGIC_TEST => (), // this should warn
922
_ => (),
1023
}
1124
}

0 commit comments

Comments
 (0)