Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rust-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
e86c9e6ef8be7ddec0360f20aae7d86c69c59a83
c839a7b4c26e58319b0c40448dd423facff34cd0
9 changes: 3 additions & 6 deletions src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/compile-fail/validity/cast_fn_ptr1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
2 changes: 1 addition & 1 deletion tests/compile-fail/validity/cast_fn_ptr2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
2 changes: 1 addition & 1 deletion tests/compile-fail/validity/fn_ptr_offset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
2 changes: 1 addition & 1 deletion tests/compile-fail/validity/invalid_bool.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
fn main() {
let _b = unsafe { std::mem::transmute::<u8, bool>(2) }; //~ ERROR encountered 2, but expected something less or equal to 1
let _b = unsafe { std::mem::transmute::<u8, bool>(2) }; //~ ERROR encountered 2, but expected a boolean
}
2 changes: 1 addition & 1 deletion tests/compile-fail/validity/invalid_char.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
fn main() {
assert!(std::char::from_u32(-1_i32 as u32).is_none());
let _val = match unsafe { std::mem::transmute::<i32, char>(-1) } { //~ ERROR encountered 4294967295, but expected something less or equal to 1114111
let _val = match unsafe { std::mem::transmute::<i32, char>(-1) } { //~ ERROR encountered 4294967295, but expected a valid unicode codepoint
'a' => {true},
'b' => {false},
_ => {true},
Expand Down