Skip to content

Commit c153bd6

Browse files
committed
Auto merge of rust-lang#9539 - Jarcho:ice_9445, r=flip1995
Don't lint `*_interior_mutable_const` on unions due to potential ICE. fixes rust-lang#9445 cc rust-lang#101113 This started ICE'ing sometime last month due to stricter UB checks. I'm not sure how we could check the value of a union as MIRI doesn't seem to store which field is currently active. changelog: Don't ICE on const unions containing a `!Freeze` type.
2 parents 78dc616 + b180d95 commit c153bd6

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

clippy_lints/src/non_copy_const.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,9 @@ fn is_value_unfrozen_raw<'tcx>(
149149
// the fact that we have to dig into every structs to search enums
150150
// leads us to the point checking `UnsafeCell` directly is the only option.
151151
ty::Adt(ty_def, ..) if ty_def.is_unsafe_cell() => true,
152+
// As of 2022-09-08 miri doesn't track which union field is active so there's no safe way to check the
153+
// contained value.
154+
ty::Adt(def, ..) if def.is_union() => false,
152155
ty::Array(..) | ty::Adt(..) | ty::Tuple(..) => {
153156
let val = cx.tcx.destructure_mir_constant(cx.param_env, val);
154157
val.fields.iter().any(|field| inner(cx, *field))

tests/ui/crashes/ice-9445.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const UNINIT: core::mem::MaybeUninit<core::cell::Cell<&'static ()>> = core::mem::MaybeUninit::uninit();
2+
3+
fn main() {}

0 commit comments

Comments
 (0)