diff options
| author | Wesley Wiser <wwiser@gmail.com> | 2018-10-21 10:47:01 -0400 |
|---|---|---|
| committer | Wesley Wiser <wwiser@gmail.com> | 2018-10-22 22:45:36 -0400 |
| commit | 895a4b2d45e6d5c274bcd561391b2cc6a73dd2c5 (patch) | |
| tree | 3861b7ed9da5253962303d372c4356b49117ea75 | |
| parent | 37e1d2975e1002f0718552554055647392e46f0d (diff) | |
| download | rust-895a4b2d45e6d5c274bcd561391b2cc6a73dd2c5.tar.gz rust-895a4b2d45e6d5c274bcd561391b2cc6a73dd2c5.zip | |
Remove the `suite_index` parameter of the `run_passes!()` macro
This can be obtained via the `$mir_phase` value.
| -rw-r--r-- | src/librustc/mir/mod.rs | 12 | ||||
| -rw-r--r-- | src/librustc_mir/transform/mod.rs | 12 |
2 files changed, 18 insertions, 6 deletions
diff --git a/src/librustc/mir/mod.rs b/src/librustc/mir/mod.rs index 797836f1661..e53def65886 100644 --- a/src/librustc/mir/mod.rs +++ b/src/librustc/mir/mod.rs @@ -80,6 +80,18 @@ pub enum MirPhase { Optimized, } +impl MirPhase { + /// Gets the index of the current MirPhase within the set of all MirPhases. + pub fn phase_index(&self) -> usize { + match self { + MirPhase::Build => 0, + MirPhase::Const => 1, + MirPhase::Validated => 2, + MirPhase::Optimized => 3, + } + } +} + /// Lowered representation of a single function. #[derive(Clone, RustcEncodable, RustcDecodable, Debug)] pub struct Mir<'tcx> { diff --git a/src/librustc_mir/transform/mod.rs b/src/librustc_mir/transform/mod.rs index 61e150ea12a..ff85d780a4c 100644 --- a/src/librustc_mir/transform/mod.rs +++ b/src/librustc_mir/transform/mod.rs @@ -159,11 +159,11 @@ pub macro run_passes( $tcx:ident, $mir:ident, $def_id:ident, - $suite_index:expr, $mir_phase:expr; $($pass:expr,)* ) {{ - let suite_index: usize = $suite_index; + let phase_index = $mir_phase.phase_index(); + let run_passes = |mir: &mut _, promoted| { let mir: &mut Mir<'_> = mir; @@ -178,7 +178,7 @@ pub macro run_passes( let mut index = 0; let mut run_pass = |pass: &dyn MirPass| { let run_hooks = |mir: &_, index, is_after| { - dump_mir::on_mir_pass($tcx, &format_args!("{:03}-{:03}", suite_index, index), + dump_mir::on_mir_pass($tcx, &format_args!("{:03}-{:03}", phase_index, index), &pass.name(), source, mir, is_after); }; run_hooks(mir, index, false); @@ -207,7 +207,7 @@ fn mir_const<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx Stea let _ = tcx.unsafety_check_result(def_id); let mut mir = tcx.mir_built(def_id).steal(); - run_passes