use body's param-env when checking if type needs drop
This commit is contained in:
parent
c2ecd3af87
commit
6d2bd541e0
3 changed files with 25 additions and 7 deletions
|
@ -431,9 +431,9 @@ impl<'a, 'tcx> Visitor<'a, 'tcx> for UnsafetyVisitor<'a, '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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue