Skip to content

Commit 6b9001f

Browse files
committed
Only remove unreachable blocks
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.
1 parent 02d2594 commit 6b9001f

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

compiler/rustc_mir_transform/src/elaborate_drops.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use crate::simplify::remove_dead_blocks;
12
use crate::MirPass;
23
use rustc_data_structures::fx::FxHashMap;
34
use rustc_index::bit_set::BitSet;
@@ -68,6 +69,9 @@ impl<'tcx> MirPass<'tcx> for ElaborateDrops {
6869
.elaborate()
6970
};
7071
elaborate_patch.apply(body);
72+
73+
remove_dead_blocks(tcx, body);
74+
body.basic_blocks_mut().raw.shrink_to_fit();
7175
}
7276
}
7377

compiler/rustc_mir_transform/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,6 @@ fn mir_promoted(
342342
// These next passes must be executed together
343343
&add_call_guards::CriticalCallEdges,
344344
&elaborate_drops::ElaborateDrops,
345-
&simplify::SimplifyCfg::new("elaborate-drops"),
346345
&coverage::InstrumentCoverage,
347346
],
348347
Some(MirPhase::Analysis(AnalysisPhase::Initial)),

0 commit comments

Comments
 (0)