Skip to content

Commit

Permalink
Use IndexVec::indices instead of reimplementing it
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tmiasko committed Nov 20, 2021
1 parent 763703c commit d5a91f3
Showing 1 changed file with 2 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
use crate::MirPass;
use rustc_data_structures::stable_set::FxHashSet;
use rustc_middle::mir::{
BasicBlock, BasicBlockData, Body, Local, Operand, Rvalue, StatementKind, SwitchTargets,
TerminatorKind,
BasicBlockData, Body, Local, Operand, Rvalue, StatementKind, SwitchTargets, TerminatorKind,
};
use rustc_middle::ty::layout::TyAndLayout;
use rustc_middle::ty::{Ty, TyCtxt};
Expand Down Expand Up @@ -73,10 +72,7 @@ impl<'tcx> MirPass<'tcx> for UninhabitedEnumBranching {
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
trace!("UninhabitedEnumBranching starting for {:?}", body.source);

let basic_block_count = body.basic_blocks().len();

for bb in 0..basic_block_count {
let bb = BasicBlock::from_usize(bb);
for bb in body.basic_blocks().indices() {
trace!("processing block {:?}", bb);

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

0 comments on commit d5a91f3

Please sign in to comment.