Skip to content

Commit

Permalink
Fix ICE in mir interpretation
Browse files Browse the repository at this point in the history
  • Loading branch information
oli-obk committed Dec 23, 2019
1 parent fc5deca commit 056dff5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/librustc_mir/interpret/place.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
};

Expand Down
9 changes: 9 additions & 0 deletions src/test/ui/consts/const_prop_slice_pat_ice.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// check-pass
#![feature(slice_patterns)]

fn main() {
match &[0, 1] as &[i32] {
[a @ .., x] => {}
&[] => {}
}
}

0 comments on commit 056dff5

Please sign in to comment.