Skip to content

Commit 30dd6cf

Browse files
committed
The optimization should also apply for DropAndReplace
1 parent 673935f commit 30dd6cf

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

compiler/rustc_mir/src/transform/remove_unneeded_drops.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ impl<'tcx> MirPass<'tcx> for RemoveUnneededDrops {
2929
impl<'a, 'tcx> Visitor<'tcx> for RemoveUnneededDropsOptimizationFinder<'a, 'tcx> {
3030
fn visit_terminator(&mut self, terminator: &Terminator<'tcx>, location: Location) {
3131
match terminator.kind {
32-
TerminatorKind::Drop { place, target, .. } => {
32+
TerminatorKind::Drop { place, target, .. }
33+
| TerminatorKind::DropAndReplace { place, target, .. } => {
3334
let ty = place.ty(self.body, self.tcx);
3435
let needs_drop = ty.ty.needs_drop(self.tcx, self.tcx.param_env(self.def_id));
3536
if !needs_drop {

0 commit comments

Comments
 (0)