From 88c45f9891ede9d5b6643783f51f722fcf817d08 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Tue, 18 Feb 2020 09:32:02 +0100 Subject: [PATCH] adjust for rustc changes --- rust-version | 2 +- src/helpers.rs | 9 +++------ tests/compile-fail/validity/cast_fn_ptr1.rs | 2 +- tests/compile-fail/validity/cast_fn_ptr2.rs | 2 +- tests/compile-fail/validity/fn_ptr_offset.rs | 2 +- tests/compile-fail/validity/invalid_bool.rs | 2 +- tests/compile-fail/validity/invalid_char.rs | 2 +- 7 files changed, 9 insertions(+), 12 deletions(-) diff --git a/rust-version b/rust-version index 82d8da1d03..0b22c04d30 100644 --- a/rust-version +++ b/rust-version @@ -1 +1 @@ -e86c9e6ef8be7ddec0360f20aae7d86c69c59a83 +c839a7b4c26e58319b0c40448dd423facff34cd0 diff --git a/src/helpers.rs b/src/helpers.rs index 19db6852c5..5ff0a5671c 100644 --- a/src/helpers.rs +++ b/src/helpers.rs @@ -300,18 +300,15 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx } // We have to do *something* for unions. - fn visit_union(&mut self, v: MPlaceTy<'tcx, Tag>) -> InterpResult<'tcx> { + fn visit_union(&mut self, v: MPlaceTy<'tcx, Tag>, fields: usize) -> InterpResult<'tcx> { + assert!(fields > 0); // we should never reach "pseudo-unions" with 0 fields, like primitives + // With unions, we fall back to whatever the type says, to hopefully be consistent // with LLVM IR. // FIXME: are we consistent, and is this really the behavior we want? let frozen = self.ecx.type_is_freeze(v.layout.ty); if frozen { Ok(()) } else { (self.unsafe_cell_action)(v) } } - - // We should never get to a primitive, but always short-circuit somewhere above. - fn visit_primitive(&mut self, _v: MPlaceTy<'tcx, Tag>) -> InterpResult<'tcx> { - bug!("we should always short-circuit before coming to a primitive") - } } } diff --git a/tests/compile-fail/validity/cast_fn_ptr1.rs b/tests/compile-fail/validity/cast_fn_ptr1.rs index d1f6e33e45..eb94ba256b 100644 --- a/tests/compile-fail/validity/cast_fn_ptr1.rs +++ b/tests/compile-fail/validity/cast_fn_ptr1.rs @@ -7,5 +7,5 @@ fn main() { let g: fn(*const i32) = unsafe { std::mem::transmute(f as fn(&i32)) }; g(0usize as *const i32) - //~^ ERROR encountered 0, but expected something greater or equal to 1 + //~^ ERROR encountered a NULL reference } diff --git a/tests/compile-fail/validity/cast_fn_ptr2.rs b/tests/compile-fail/validity/cast_fn_ptr2.rs index 809f118c1d..a3faa84f1d 100644 --- a/tests/compile-fail/validity/cast_fn_ptr2.rs +++ b/tests/compile-fail/validity/cast_fn_ptr2.rs @@ -7,5 +7,5 @@ fn main() { let g: fn() -> &'static i32 = unsafe { std::mem::transmute(f as fn() -> *const i32) }; let _x = g(); - //~^ ERROR encountered 0, but expected something greater or equal to 1 + //~^ ERROR encountered a NULL reference } diff --git a/tests/compile-fail/validity/fn_ptr_offset.rs b/tests/compile-fail/validity/fn_ptr_offset.rs index 4989f4d3af..5eec58b5e2 100644 --- a/tests/compile-fail/validity/fn_ptr_offset.rs +++ b/tests/compile-fail/validity/fn_ptr_offset.rs @@ -6,5 +6,5 @@ fn main() { let x : fn() = f; let y : *mut u8 = unsafe { mem::transmute(x) }; let y = y.wrapping_offset(1); - let _x : fn() = unsafe { mem::transmute(y) }; //~ ERROR encountered a potentially NULL pointer + let _x : fn() = unsafe { mem::transmute(y) }; //~ ERROR encountered a pointer, but expected a function pointer } diff --git a/tests/compile-fail/validity/invalid_bool.rs b/tests/compile-fail/validity/invalid_bool.rs index ce46461619..35f4d4228e 100644 --- a/tests/compile-fail/validity/invalid_bool.rs +++ b/tests/compile-fail/validity/invalid_bool.rs @@ -1,3 +1,3 @@ fn main() { - let _b = unsafe { std::mem::transmute::(2) }; //~ ERROR encountered 2, but expected something less or equal to 1 + let _b = unsafe { std::mem::transmute::(2) }; //~ ERROR encountered 2, but expected a boolean } diff --git a/tests/compile-fail/validity/invalid_char.rs b/tests/compile-fail/validity/invalid_char.rs index a3f9070363..42922cdc91 100644 --- a/tests/compile-fail/validity/invalid_char.rs +++ b/tests/compile-fail/validity/invalid_char.rs @@ -1,6 +1,6 @@ fn main() { assert!(std::char::from_u32(-1_i32 as u32).is_none()); - let _val = match unsafe { std::mem::transmute::(-1) } { //~ ERROR encountered 4294967295, but expected something less or equal to 1114111 + let _val = match unsafe { std::mem::transmute::(-1) } { //~ ERROR encountered 4294967295, but expected a valid unicode codepoint 'a' => {true}, 'b' => {false}, _ => {true},