Skip to content

Commit 895a4b2

Browse files
committed
Remove the suite_index parameter of the run_passes!() macro
This can be obtained via the `$mir_phase` value.
1 parent 37e1d29 commit 895a4b2

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

src/librustc/mir/mod.rs

+12
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,18 @@ pub enum MirPhase {
8080
Optimized,
8181
}
8282

83+
impl MirPhase {
84+
/// Gets the index of the current MirPhase within the set of all MirPhases.
85+
pub fn phase_index(&self) -> usize {
86+
match self {
87+
MirPhase::Build => 0,
88+
MirPhase::Const => 1,
89+
MirPhase::Validated => 2,
90+
MirPhase::Optimized => 3,
91+
}
92+
}
93+
}
94+
8395
/// Lowered representation of a single function.
8496
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
8597
pub struct Mir<'tcx> {

src/librustc_mir/transform/mod.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,11 @@ pub macro run_passes(
159159
$tcx:ident,
160160
$mir:ident,
161161
$def_id:ident,
162-
$suite_index:expr,
163162
$mir_phase:expr;
164163
$($pass:expr,)*
165164
) {{
166-
let suite_index: usize = $suite_index;
165+
let phase_index = $mir_phase.phase_index();
166+
167167
let run_passes = |mir: &mut _, promoted| {
168168
let mir: &mut Mir<'_> = mir;
169169

@@ -178,7 +178,7 @@ pub macro run_passes(
178178
let mut index = 0;
179179
let mut run_pass = |pass: &dyn MirPass| {
180180
let run_hooks = |mir: &_, index, is_after| {
181-
dump_mir::on_mir_pass($tcx, &format_args!("{:03}-{:03}", suite_index, index),
181+
dump_mir::on_mir_pass($tcx, &format_args!("{:03}-{:03}", phase_index, index),
182182
&pass.name(), source, mir, is_after);
183183
};
184184
run_hooks(mir, index, false);
@@ -207,7 +207,7 @@ fn mir_const<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx Stea
207207
let _ = tcx.unsafety_check_result(def_id);
208208

209209
let mut mir = tcx.mir_built(def_id).steal();
210-
run_passes![tcx, mir, def_id, 0, MirPhase::Const;
210+
run_passes![tcx, mir, def_id, MirPhase::Const;
211211
// Remove all `EndRegion` statements that are not involved in borrows.
212212
cleanup_post_borrowck::CleanEndRegions,
213213

@@ -229,7 +229,7 @@ fn mir_validated<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx
229229
}
230230

231231
let mut mir = tcx.mir_const(def_id).steal();
232-
run_passes![tcx, mir, def_id, 1, MirPhase::Validated;
232+
run_passes![tcx, mir, def_id, MirPhase::Validated;
233233
// What we need to run borrowck etc.
234234
qualify_consts::QualifyAndPromoteConstants,
235235
simplify::SimplifyCfg::new("qualify-consts"),
@@ -247,7 +247,7 @@ fn optimized_mir<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx
247247
}
248248

249249
let mut mir = tcx.mir_validated(def_id).steal();
250-
run_passes![tcx, mir, def_id, 2, MirPhase::Optimized;
250+
run_passes![tcx, mir, def_id, MirPhase::Optimized;
251251
// Remove all things not needed by analysis
252252
no_landing_pads::NoLandingPads,
253253
simplify_branches::SimplifyBranches::new("initial"),

0 commit comments

Comments
 (0)