Skip to content

Commit fca642c

Browse files
Add pass for simple phase change
1 parent fd18b45 commit fca642c

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

compiler/rustc_mir_transform/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ mod inline;
6161
mod instcombine;
6262
mod lower_intrinsics;
6363
mod lower_slice_len;
64+
mod marker;
6465
mod match_branches;
6566
mod multiple_return_terminators;
6667
mod normalize_array_len;
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
use std::borrow::Cow;
2+
3+
use crate::MirPass;
4+
use rustc_middle::mir::{Body, MirPhase};
5+
use rustc_middle::ty::TyCtxt;
6+
7+
/// Changes the MIR phase without changing the MIR itself.
8+
pub struct PhaseChange(pub MirPhase);
9+
10+
impl<'tcx> MirPass<'tcx> for PhaseChange {
11+
fn phase_change(&self) -> Option<MirPhase> {
12+
Some(self.0)
13+
}
14+
15+
fn name(&self) -> Cow<'_, str> {
16+
Cow::from(format!("PhaseChange-{:?}", self.0))
17+
}
18+
19+
fn run_pass(&self, _: TyCtxt<'tcx>, _body: &mut Body<'tcx>) {}
20+
}

0 commit comments

Comments
 (0)