about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOliver Scherer <github35764891676564198441@oli-obk.de>2019-12-23 01:24:11 +0100
committerOliver Scherer <github35764891676564198441@oli-obk.de>2019-12-23 01:24:11 +0100
commit056dff5748270249d81a03b355bc7ddd8da7f900 (patch)
treea7db117700a6bd9bf5c07f61aa87a397602c6a7c
parentfc5deca2143a448d10a1241a777275e59448c94d (diff)
downloadrust-056dff5748270249d81a03b355bc7ddd8da7f900.tar.gz
rust-056dff5748270249d81a03b355bc7ddd8da7f900.zip
Fix ICE in mir interpretation
-rw-r--r--src/librustc_mir/interpret/place.rs3
-rw-r--r--src/test/ui/consts/const_prop_slice_pat_ice.rs9
2 files changed, 11 insertions, 1 deletions
diff --git a/src/librustc_mir/interpret/place.rs b/src/librustc_mir/interpret/place.rs
index 8923b167fde..6e7fa302abc 100644
--- a/src/librustc_mir/interpret/place.rs
+++ b/src/librustc_mir/interpret/place.rs
@@ -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)
                 };
 
diff --git a/src/test/ui/consts/const_prop_slice_pat_ice.rs b/src/test/ui/consts/const_prop_slice_pat_ice.rs
new file mode 100644
index 00000000000..5fec36e44bd
--- /dev/null
+++ b/src/test/ui/consts/const_prop_slice_pat_ice.rs
@@ -0,0 +1,9 @@
+// check-pass
+#![feature(slice_patterns)]
+
+fn main() {
+    match &[0, 1] as &[i32] {
+        [a @ .., x] => {}
+        &[] => {}
+    }
+}