Skip to content

Commit

Permalink
The optimization should also apply for DropAndReplace
Browse files Browse the repository at this point in the history
  • Loading branch information
simonvandel committed Sep 22, 2020
1 parent d3338dc commit f472303
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion compiler/rustc_mir/src/transform/remove_unneeded_drops.rs
Expand Up @@ -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 {
Expand Down

0 comments on commit f472303

Please sign in to comment.