Skip to content

Commit 056dff5

Browse files
committed
Fix ICE in mir interpretation
1 parent fc5deca commit 056dff5

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

Diff for: src/librustc_mir/interpret/place.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -530,11 +530,12 @@ where
530530
// This can only be reached in ConstProp and non-rustc-MIR.
531531
throw_ub!(BoundsCheckFailed { len: min_length as u64, index: n as u64 });
532532
}
533-
assert!(offset < min_length);
534533

535534
let index = if from_end {
535+
assert!(offset - 1 < min_length);
536536
n - u64::from(offset)
537537
} else {
538+
assert!(offset < min_length);
538539
u64::from(offset)
539540
};
540541

Diff for: src/test/ui/consts/const_prop_slice_pat_ice.rs

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// check-pass
2+
#![feature(slice_patterns)]
3+
4+
fn main() {
5+
match &[0, 1] as &[i32] {
6+
[a @ .., x] => {}
7+
&[] => {}
8+
}
9+
}

0 commit comments

Comments
 (0)