From 6f50289d437bd2d9308761bd2405d63a633cbe1e Mon Sep 17 00:00:00 2001 From: Scott Olson Date: Sat, 23 Apr 2016 00:26:10 -0600 Subject: [PATCH] Fix lvalue projections with fat pointer bases. --- src/interpreter.rs | 2 +- tests/compile-fail/bugs/slice_index.rs | 12 ------------ tests/run-pass/arrays.rs | 7 +++++++ 3 files changed, 8 insertions(+), 13 deletions(-) delete mode 100644 tests/compile-fail/bugs/slice_index.rs diff --git a/src/interpreter.rs b/src/interpreter.rs index 546935dee76..5eea525a543 100644 --- a/src/interpreter.rs +++ b/src/interpreter.rs @@ -792,7 +792,7 @@ fn eval_lvalue(&mut self, lvalue: &mir::Lvalue<'tcx>) -> EvalResult { 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 index 52a76247ca4..00000000000 --- a/tests/compile-fail/bugs/slice_index.rs +++ /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() {} diff --git a/tests/run-pass/arrays.rs b/tests/run-pass/arrays.rs index 36b7217f580..1fbf24b4668 100644 --- a/tests/run-pass/arrays.rs +++ b/tests/run-pass/arrays.rs @@ -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]]); -- 2.44.0