From 7dec440340040ae377abcf22968a1d850a908f1b Mon Sep 17 00:00:00 2001 From: Simon Vandel Sillesen Date: Thu, 24 Sep 2020 21:02:53 +0200 Subject: [PATCH] Resolve https://github.com/rust-lang/rust/pull/76673#discussion_r494426303 --- compiler/rustc_middle/src/mir/terminator/mod.rs | 2 ++ compiler/rustc_mir/src/transform/remove_unneeded_drops.rs | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_middle/src/mir/terminator/mod.rs b/compiler/rustc_middle/src/mir/terminator/mod.rs index fcfd648c2b7a..8909f02270cb 100644 --- a/compiler/rustc_middle/src/mir/terminator/mod.rs +++ b/compiler/rustc_middle/src/mir/terminator/mod.rs @@ -96,6 +96,8 @@ pub enum TerminatorKind<'tcx> { /// P <- V /// } /// ``` + /// + /// Note that DropAndReplace is eliminated as part of the `ElaborateDrops` pass. DropAndReplace { place: Place<'tcx>, value: Operand<'tcx>, diff --git a/compiler/rustc_mir/src/transform/remove_unneeded_drops.rs b/compiler/rustc_mir/src/transform/remove_unneeded_drops.rs index f027f5e33a18..b9f29786c64e 100644 --- a/compiler/rustc_mir/src/transform/remove_unneeded_drops.rs +++ b/compiler/rustc_mir/src/transform/remove_unneeded_drops.rs @@ -38,8 +38,7 @@ impl<'tcx> MirPass<'tcx> for RemoveUnneededDrops { impl<'a, 'tcx> Visitor<'tcx> for RemoveUnneededDropsOptimizationFinder<'a, 'tcx> { fn visit_terminator(&mut self, terminator: &Terminator<'tcx>, location: Location) { match terminator.kind { - TerminatorKind::Drop { place, target, .. } - | TerminatorKind::DropAndReplace { place, target, .. } => { + TerminatorKind::Drop { place, target, .. } => { let ty = place.ty(self.body, self.tcx); let needs_drop = ty.ty.needs_drop(self.tcx, self.tcx.param_env(self.def_id)); if !needs_drop {