]> git.lizzy.rs Git - rust.git/blobdiff - compiler/rustc_mir_build/src/check_unsafety.rs
Auto merge of #99506 - Dylan-DPC:rollup-q3msucx, r=Dylan-DPC
[rust.git] / compiler / rustc_mir_build / src / check_unsafety.rs
index 54d3b7cdda62c271b379666a80adf25c9a68f9f2..1f0d0ce04aaa3aebdb023c6a0950c67b78c8b709 100644 (file)
@@ -431,9 +431,9 @@ fn visit_expr(&mut self, expr: &Expr<'tcx>) {
                 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);
@@ -618,7 +618,7 @@ pub fn description_and_note(&self, tcx: TyCtxt<'_>) -> (Cow<'static, str>, &'sta
 
 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;
     }