Skip to content

Commit d5a91f3

Browse files
committed
Use IndexVec::indices instead of reimplementing it
The change is limited to the iteration over indices instead of using `basic_blocks_mut()` directly, in the case the previous implementation intentionally avoided invalidating the caches stored in MIR body.
1 parent 763703c commit d5a91f3

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

compiler/rustc_mir_transform/src/uninhabited_enum_branching.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
use crate::MirPass;
44
use rustc_data_structures::stable_set::FxHashSet;
55
use rustc_middle::mir::{
6-
BasicBlock, BasicBlockData, Body, Local, Operand, Rvalue, StatementKind, SwitchTargets,
7-
TerminatorKind,
6+
BasicBlockData, Body, Local, Operand, Rvalue, StatementKind, SwitchTargets, TerminatorKind,
87
};
98
use rustc_middle::ty::layout::TyAndLayout;
109
use rustc_middle::ty::{Ty, TyCtxt};
@@ -73,10 +72,7 @@ impl<'tcx> MirPass<'tcx> for UninhabitedEnumBranching {
7372
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
7473
trace!("UninhabitedEnumBranching starting for {:?}", body.source);
7574

76-
let basic_block_count = body.basic_blocks().len();
77-
78-
for bb in 0..basic_block_count {
79-
let bb = BasicBlock::from_usize(bb);
75+
for bb in body.basic_blocks().indices() {
8076
trace!("processing block {:?}", bb);
8177

8278
let Some(discriminant_ty) = get_switched_on_type(&body.basic_blocks()[bb], tcx, body) else {

0 commit comments

Comments
 (0)