1
Fork 0

Fix another related ICE

This commit is contained in:
Oliver Scherer 2018-11-29 12:58:25 +01:00
parent 28cc3405a8
commit 8f9a093f52
4 changed files with 40 additions and 6 deletions

View file

@ -1355,11 +1355,6 @@ fn slice_pat_covered_by_constructor<'tcx>(
ConstValue::Scalar(val) | ConstValue::ScalarPair(val, _) => val,
};
if let Ok(ptr) = val.to_ptr() {
let is_array_ptr = const_val.ty
.builtin_deref(true)
.and_then(|t| t.ty.builtin_index())
.map_or(false, |t| t == tcx.types.u8);
assert!(is_array_ptr);
tcx.alloc_map.lock().unwrap_memory(ptr.alloc_id).bytes.as_ref()
} else {
bug!("unexpected non-ptr ConstantValue")

View file

@ -6,6 +6,19 @@ fn main() {
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
_ => (),
}
}

View file

@ -6,6 +6,19 @@ fn main() {
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
_ => (),
}
}

View file

@ -1,4 +1,4 @@
// compile-pass
//compile-pass
fn main() {
let s = &[0x00; 4][..]; //Slice of any value
@ -6,6 +6,19 @@ fn main() {
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
_ => (),
}
}