Skip to content

Commit c7e94b0

Browse files
committed
Use zero based indexing for pass_count
1 parent 80dcc52 commit c7e94b0

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

compiler/rustc_middle/src/mir/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ impl<'tcx> Body<'tcx> {
335335

336336
let mut body = Body {
337337
phase: MirPhase::Built,
338-
pass_count: 1,
338+
pass_count: 0,
339339
source,
340340
basic_blocks: BasicBlocks::new(basic_blocks),
341341
source_scopes,
@@ -370,7 +370,7 @@ impl<'tcx> Body<'tcx> {
370370
pub fn new_cfg_only(basic_blocks: IndexVec<BasicBlock, BasicBlockData<'tcx>>) -> Self {
371371
let mut body = Body {
372372
phase: MirPhase::Built,
373-
pass_count: 1,
373+
pass_count: 0,
374374
source: MirSource::item(CRATE_DEF_ID.to_def_id()),
375375
basic_blocks: BasicBlocks::new(basic_blocks),
376376
source_scopes: IndexVec::new(),

compiler/rustc_mir_build/src/build/custom/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ pub(super) fn build_custom_mir<'tcx>(
5757
is_polymorphic: false,
5858
tainted_by_errors: None,
5959
injection_phase: None,
60-
pass_count: 1,
60+
pass_count: 0,
6161
};
6262

6363
body.local_decls.push(LocalDecl::new(return_ty, return_ty_span));

compiler/rustc_mir_transform/src/pass_manager.rs

+2
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ fn run_passes_inner<'tcx>(
140140
}
141141

142142
body.phase = new_phase;
143+
body.pass_count = 0;
143144

144145
dump_mir_for_phase_change(tcx, body);
145146
if validate || new_phase == MirPhase::Runtime(RuntimePhase::Optimized) {
@@ -171,5 +172,6 @@ pub fn dump_mir_for_pass<'tcx>(
171172
}
172173

173174
pub fn dump_mir_for_phase_change<'tcx>(tcx: TyCtxt<'tcx>, body: &Body<'tcx>) {
175+
assert_eq!(body.pass_count, 0);
174176
mir::dump_mir(tcx, true, body.phase.name(), &"after", body, |_, _| Ok(()))
175177
}

0 commit comments

Comments
 (0)