]> git.lizzy.rs Git - rust.git/blobdiff - compiler/rustc_mir_transform/src/check_unsafety.rs
simplify more, ret_deref -> has_deref
[rust.git] / compiler / rustc_mir_transform / src / check_unsafety.rs
index ded1f0462cb016bf82feb6ab4428f9cdf8db2d27..a2ad96cfc16d2929999300a8000d06dbd6d5f4cc 100644 (file)
@@ -219,14 +219,11 @@ fn visit_place(&mut self, place: &Place<'tcx>, context: PlaceContext, _location:
                     // We have to check the actual type of the assignment, as that determines if the
                     // old value is being dropped.
                     let assigned_ty = place.ty(&self.body.local_decls, self.tcx).ty;
-                    if assigned_ty.needs_drop(
-                        self.tcx,
-                        self.tcx.param_env(base_ty.ty_adt_def().unwrap().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(
                             self.source_info.span,
-                            "union fields that need dropping should be impossible",
+                            format!("union fields that need dropping should be impossible: {assigned_ty}")
                         );
                     }
                 } else {