Skip to content

Commit

Permalink
Only remove unreachable blocks
Browse files Browse the repository at this point in the history
Only remove unreachable blocks after drop elaboration but
avoid merging blocks, as that sometimes confuses borrowck
precomputation of borrows_out_of_scope.
See issue rust-lang#80949 for more details.
  • Loading branch information
zeegomo committed Feb 23, 2023
1 parent 02d2594 commit 6b9001f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 4 additions & 0 deletions compiler/rustc_mir_transform/src/elaborate_drops.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::simplify::remove_dead_blocks;
use crate::MirPass;
use rustc_data_structures::fx::FxHashMap;
use rustc_index::bit_set::BitSet;
Expand Down Expand Up @@ -68,6 +69,9 @@ impl<'tcx> MirPass<'tcx> for ElaborateDrops {
.elaborate()
};
elaborate_patch.apply(body);

remove_dead_blocks(tcx, body);
body.basic_blocks_mut().raw.shrink_to_fit();
}
}

Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_mir_transform/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,6 @@ fn mir_promoted(
// These next passes must be executed together
&add_call_guards::CriticalCallEdges,
&elaborate_drops::ElaborateDrops,
&simplify::SimplifyCfg::new("elaborate-drops"),
&coverage::InstrumentCoverage,
],
Some(MirPhase::Analysis(AnalysisPhase::Initial)),
Expand Down

0 comments on commit 6b9001f

Please sign in to comment.