Skip to content

Commit 4575ee1

Browse files
committed
Auto merge of #1448 - RalfJung:rustup, r=RalfJung
rustup; and a bit of UnsafeCell detection refactoring
2 parents e26029a + e063ce2 commit 4575ee1

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

rust-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
50c0192c64241d723066add22c53d472e2b9cba9
1+
1fb612bd15bb3ef098fd24c20d0727de573b4410

src/helpers.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,9 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
291291
} else if self.ecx.type_is_freeze(v.layout.ty) {
292292
// This is `Freeze`, there cannot be an `UnsafeCell`
293293
Ok(())
294+
} else if matches!(v.layout.fields, FieldsShape::Union(..)) {
295+
// A (non-frozen) union. We fall back to whatever the type says.
296+
(self.unsafe_cell_action)(v)
294297
} else {
295298
// We want to not actually read from memory for this visit. So, before
296299
// walking this value, we have to make sure it is not a
@@ -341,13 +344,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
341344
}
342345
}
343346

344-
// We have to do *something* for unions.
345-
fn visit_union(&mut self, v: MPlaceTy<'tcx, Tag>, _fields: NonZeroUsize) -> InterpResult<'tcx> {
346-
// With unions, we fall back to whatever the type says, to hopefully be consistent
347-
// with LLVM IR.
348-
// FIXME: are we consistent, and is this really the behavior we want?
349-
let frozen = self.ecx.type_is_freeze(v.layout.ty);
350-
if frozen { Ok(()) } else { (self.unsafe_cell_action)(v) }
347+
fn visit_union(&mut self, _v: MPlaceTy<'tcx, Tag>, _fields: NonZeroUsize) -> InterpResult<'tcx> {
348+
bug!("we should have already handled unions in `visit_value`")
351349
}
352350
}
353351
}

0 commit comments

Comments
 (0)