Skip to content

Commit

Permalink
Don't lint *_interior_mutable_const on unions due to potential ICE.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarcho committed Sep 25, 2022
1 parent 8b1ad17 commit b180d95
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions clippy_lints/src/non_copy_const.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ fn is_value_unfrozen_raw<'tcx>(
// the fact that we have to dig into every structs to search enums
// leads us to the point checking `UnsafeCell` directly is the only option.
ty::Adt(ty_def, ..) if ty_def.is_unsafe_cell() => true,
// As of 2022-09-08 miri doesn't track which union field is active so there's no safe way to check the
// contained value.
ty::Adt(def, ..) if def.is_union() => false,
ty::Array(..) | ty::Adt(..) | ty::Tuple(..) => {
let val = cx.tcx.destructure_mir_constant(cx.param_env, val);
val.fields.iter().any(|field| inner(cx, *field))
Expand Down
3 changes: 3 additions & 0 deletions tests/ui/crashes/ice-9445.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const UNINIT: core::mem::MaybeUninit<core::cell::Cell<&'static ()>> = core::mem::MaybeUninit::uninit();

fn main() {}

0 comments on commit b180d95

Please sign in to comment.