let lhs = &self.thir[lhs];
if let ty::Adt(adt_def, _) = lhs.ty.kind() && adt_def.is_union() {
if let Some((assigned_ty, assignment_span)) = self.assignment_info {
- if assigned_ty.needs_drop(self.tcx, self.tcx.param_env(adt_def.did())) {
+ if assigned_ty.needs_drop(self.tcx, self.param_env) {
// This would be unsafe, but should be outright impossible since we reject such unions.
- self.tcx.sess.delay_span_bug(assignment_span, "union fields that need dropping should be impossible");
+ self.tcx.sess.delay_span_bug(assignment_span, format!("union fields that need dropping should be impossible: {assigned_ty}"));
}
} else {
self.requires_unsafe(expr.span, AccessToUnionField);
pub fn check_unsafety<'tcx>(tcx: TyCtxt<'tcx>, def: ty::WithOptConstParam<LocalDefId>) {
// THIR unsafeck is gated under `-Z thir-unsafeck`
- if !tcx.sess.opts.debugging_opts.thir_unsafeck {
+ if !tcx.sess.opts.unstable_opts.thir_unsafeck {
return;
}