]> git.lizzy.rs Git - rust.git/commitdiff
Remove the `suite_index` parameter of the `run_passes!()` macro
authorWesley Wiser <wwiser@gmail.com>
Sun, 21 Oct 2018 14:47:01 +0000 (10:47 -0400)
committerWesley Wiser <wwiser@gmail.com>
Tue, 23 Oct 2018 02:45:36 +0000 (22:45 -0400)
This can be obtained via the `$mir_phase` value.

src/librustc/mir/mod.rs
src/librustc_mir/transform/mod.rs

index 797836f166173f0366e7838afe7ce65cb3cca6b2..e53def65886de3351316e446c52b1a38c5beb42d 100644 (file)
@@ -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> {
index 61e150ea12a2261837519190bbc905806bff5b38..ff85d780a4ce307138851dd780ba1aa56281f315 100644 (file)
@@ -159,11 +159,11 @@ fn run_pass<'a, 'tcx>(&self,
     $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 @@ fn run_pass<'a, 'tcx>(&self,
         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![tcx, mir, def_id, 0, MirPhase::Const;
+    run_passes![tcx, mir, def_id, MirPhase::Const;
         // Remove all `EndRegion` statements that are not involved in borrows.
         cleanup_post_borrowck::CleanEndRegions,
 
@@ -229,7 +229,7 @@ fn mir_validated<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx
     }
 
     let mut mir = tcx.mir_const(def_id).steal();
-    run_passes![tcx, mir, def_id, 1, MirPhase::Validated;
+    run_passes![tcx, mir, def_id, MirPhase::Validated;
         // What we need to run borrowck etc.
         qualify_consts::QualifyAndPromoteConstants,
         simplify::SimplifyCfg::new("qualify-consts"),
@@ -247,7 +247,7 @@ fn optimized_mir<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx
     }
 
     let mut mir = tcx.mir_validated(def_id).steal();
-    run_passes![tcx, mir, def_id, 2, MirPhase::Optimized;
+    run_passes![tcx, mir, def_id, MirPhase::Optimized;
         // Remove all things not needed by analysis
         no_landing_pads::NoLandingPads,
         simplify_branches::SimplifyBranches::new("initial"),