Skip to content

Commit 2ca256a

Browse files
Record drops that would be live without const_precise_live_drops
1 parent e89e935 commit 2ca256a

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

compiler/rustc_mir/src/transform/check_consts/validation.rs

+16-12
Original file line numberDiff line numberDiff line change
@@ -813,12 +813,6 @@ impl Visitor<'tcx> for Validator<'mir, 'tcx> {
813813
// projections that cannot be `NeedsDrop`.
814814
TerminatorKind::Drop { place: dropped_place, .. }
815815
| TerminatorKind::DropAndReplace { place: dropped_place, .. } => {
816-
// If we are checking live drops after drop-elaboration, don't emit duplicate
817-
// errors here.
818-
if super::post_drop_elaboration::checking_enabled(self.ccx) {
819-
return;
820-
}
821-
822816
let mut err_span = self.span;
823817

824818
// Check to see if the type of this place can ever have a drop impl. If not, this
@@ -830,20 +824,30 @@ impl Visitor<'tcx> for Validator<'mir, 'tcx> {
830824
return;
831825
}
832826

833-
let needs_drop = if let Some(local) = dropped_place.as_local() {
827+
let local_needs_drop = if let Some(local) = dropped_place.as_local() {
834828
// Use the span where the local was declared as the span of the drop error.
835829
err_span = self.body.local_decls[local].source_info.span;
836830
self.qualifs.needs_drop(self.ccx, local, location)
837831
} else {
838832
true
839833
};
840834

841-
if needs_drop {
842-
self.check_op_spanned(
843-
ops::LiveDrop { dropped_at: Some(terminator.source_info.span) },
844-
err_span,
845-
);
835+
if !local_needs_drop {
836+
return;
846837
}
838+
839+
self.passes_checks_without_unstable_features = false;
840+
841+
// If we are checking live drops after drop-elaboration, don't emit duplicate
842+
// errors here.
843+
if super::post_drop_elaboration::checking_enabled(self.ccx) {
844+
return;
845+
}
846+
847+
self.check_op_spanned(
848+
ops::LiveDrop { dropped_at: Some(terminator.source_info.span) },
849+
err_span,
850+
);
847851
}
848852

849853
TerminatorKind::InlineAsm { .. } => self.check_op(ops::InlineAsm),

0 commit comments

Comments
 (0)