Fix ICE in mir interpretation

This commit is contained in:
Oliver Scherer 2019-12-23 01:24:11 +01:00
parent fc5deca214
commit 056dff5748
2 changed files with 11 additions and 1 deletions

View File

@ -530,11 +530,12 @@ where
// This can only be reached in ConstProp and non-rustc-MIR.
throw_ub!(BoundsCheckFailed { len: min_length as u64, index: n as u64 });
}
assert!(offset < min_length);
let index = if from_end {
assert!(offset - 1 < min_length);
n - u64::from(offset)
} else {
assert!(offset < min_length);
u64::from(offset)
};

View File

@ -0,0 +1,9 @@
// check-pass
#![feature(slice_patterns)]
fn main() {
match &[0, 1] as &[i32] {
[a @ .., x] => {}
&[] => {}
}
}