]> git.lizzy.rs Git - rust.git/commitdiff
Add pass for simple phase change
authorDylan MacKenzie <ecstaticmorse@gmail.com>
Thu, 2 Dec 2021 20:04:32 +0000 (12:04 -0800)
committerDylan MacKenzie <ecstaticmorse@gmail.com>
Fri, 3 Dec 2021 01:31:38 +0000 (17:31 -0800)
compiler/rustc_mir_transform/src/lib.rs
compiler/rustc_mir_transform/src/marker.rs [new file with mode: 0644]

index 4ef35a0cd36cee21942f016c45cf4265b4cc7db3..f28f5679855177308900dc6f59e523093b8c76f7 100644 (file)
@@ -61,6 +61,7 @@
 mod instcombine;
 mod lower_intrinsics;
 mod lower_slice_len;
+mod marker;
 mod match_branches;
 mod multiple_return_terminators;
 mod normalize_array_len;
diff --git a/compiler/rustc_mir_transform/src/marker.rs b/compiler/rustc_mir_transform/src/marker.rs
new file mode 100644 (file)
index 0000000..06819fc
--- /dev/null
@@ -0,0 +1,20 @@
+use std::borrow::Cow;
+
+use crate::MirPass;
+use rustc_middle::mir::{Body, MirPhase};
+use rustc_middle::ty::TyCtxt;
+
+/// Changes the MIR phase without changing the MIR itself.
+pub struct PhaseChange(pub MirPhase);
+
+impl<'tcx> MirPass<'tcx> for PhaseChange {
+    fn phase_change(&self) -> Option<MirPhase> {
+        Some(self.0)
+    }
+
+    fn name(&self) -> Cow<'_, str> {
+        Cow::from(format!("PhaseChange-{:?}", self.0))
+    }
+
+    fn run_pass(&self, _: TyCtxt<'tcx>, _body: &mut Body<'tcx>) {}
+}