We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 286cb14 + 5b8df34 commit 4a551ffCopy full SHA for 4a551ff
src/librustc_mir/interpret/place.rs
@@ -530,11 +530,12 @@ where
530
// This can only be reached in ConstProp and non-rustc-MIR.
531
throw_ub!(BoundsCheckFailed { len: min_length as u64, index: n as u64 });
532
}
533
- assert!(offset < min_length);
534
535
let index = if from_end {
+ assert!(0 < offset && offset - 1 < min_length);
536
n - u64::from(offset)
537
} else {
538
+ assert!(offset < min_length);
539
u64::from(offset)
540
};
541
src/test/ui/consts/const_prop_slice_pat_ice.rs
@@ -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