@@ -291,6 +291,9 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
291
291
} else if self . ecx . type_is_freeze ( v. layout . ty ) {
292
292
// This is `Freeze`, there cannot be an `UnsafeCell`
293
293
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)
294
297
} else {
295
298
// We want to not actually read from memory for this visit. So, before
296
299
// 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
341
344
}
342
345
}
343
346
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`" )
351
349
}
352
350
}
353
351
}
0 commit comments