about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSimon Vandel Sillesen <simon.vandel@gmail.com>2020-09-19 14:25:53 +0200
committerSimon Vandel Sillesen <simon.vandel@gmail.com>2020-09-22 23:09:07 +0200
commitf472303a93699f4d6465ada0ab7e9a999c34b0ec (patch)
tree20a0a9cb8acf3cf41e4ffbc51848bd677d7c6703
parentd3338dcf4de915fedc39ca46cb9944250bcb1a9e (diff)
downloadrust-f472303a93699f4d6465ada0ab7e9a999c34b0ec.tar.gz
rust-f472303a93699f4d6465ada0ab7e9a999c34b0ec.zip
The optimization should also apply for DropAndReplace
-rw-r--r--compiler/rustc_mir/src/transform/remove_unneeded_drops.rs3
1 files changed, 2 insertions, 1 deletions
diff --git a/compiler/rustc_mir/src/transform/remove_unneeded_drops.rs b/compiler/rustc_mir/src/transform/remove_unneeded_drops.rs
index 505133219b8..b8ad816f758 100644
--- a/compiler/rustc_mir/src/transform/remove_unneeded_drops.rs
+++ b/compiler/rustc_mir/src/transform/remove_unneeded_drops.rs
@@ -29,7 +29,8 @@ 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::Drop { place, target, .. }
+            | TerminatorKind::DropAndReplace { 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 {