]> git.lizzy.rs Git - rust.git/commitdiff
Fix lvalue projections with fat pointer bases.
authorScott Olson <scott@solson.me>
Sat, 23 Apr 2016 06:26:10 +0000 (00:26 -0600)
committerScott Olson <scott@solson.me>
Sat, 23 Apr 2016 06:26:10 +0000 (00:26 -0600)
src/interpreter.rs
tests/compile-fail/bugs/slice_index.rs [deleted file]
tests/run-pass/arrays.rs

index 546935dee76667b7561d557f012a641b8f4c8bfa..5eea525a54322d056828dea66b2ac768d2c69649 100644 (file)
@@ -792,7 +792,7 @@ fn eval_lvalue(&mut self, lvalue: &mir::Lvalue<'tcx>) -> EvalResult<Lvalue> {
             Static(_def_id) => unimplemented!(),
 
             Projection(ref proj) => {
-                let base_ptr = try!(self.eval_lvalue(&proj.base)).to_ptr();
+                let base_ptr = try!(self.eval_lvalue(&proj.base)).ptr;
                 let base_layout = self.lvalue_layout(&proj.base);
                 let base_ty = self.lvalue_ty(&proj.base);
 
diff --git a/tests/compile-fail/bugs/slice_index.rs b/tests/compile-fail/bugs/slice_index.rs
deleted file mode 100644 (file)
index 52a7624..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-#![feature(custom_attribute)]
-#![allow(dead_code, unused_attributes)]
-
-// error-pattern:assertion failed
-
-#[miri_run]
-fn slice() -> u8 {
-    let arr: &[_] = &[101, 102, 103, 104, 105, 106];
-    arr[5]
-}
-
-fn main() {}
index 36b7217f5806277335485c7b3a81a0c083fed023..1fbf24b46684e66fc6d4b94a9af207af499b88a8 100644 (file)
@@ -38,11 +38,18 @@ fn index() -> i32 {
     [42; 8]
 }
 
+#[miri_run]
+fn slice_index() -> u8 {
+    let arr: &[_] = &[101, 102, 103, 104, 105, 106];
+    arr[5]
+}
+
 #[miri_run]
 fn main() {
     //assert_eq!(empty_array(), []);
     assert_eq!(index_unsafe(), 20);
     assert_eq!(index(), 20);
+    assert_eq!(slice_index(), 106);
     /*
     assert_eq!(big_array(), [5, 4, 3, 2, 1]);
     assert_eq!(array_array(), [[5, 4], [3, 2], [1, 0]]);