mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-02 07:22:42 +00:00
Don't go through the formatting infrastructure just to get the name of a phase
This commit is contained in:
parent
744a97b98c
commit
c2166ec628
@ -184,30 +184,7 @@ impl RuntimePhase {
|
||||
|
||||
impl Display for MirPhase {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
MirPhase::Built => write!(f, "built"),
|
||||
MirPhase::Analysis(p) => write!(f, "analysis-{}", p),
|
||||
MirPhase::Runtime(p) => write!(f, "runtime-{}", p),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for AnalysisPhase {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
AnalysisPhase::Initial => write!(f, "initial"),
|
||||
AnalysisPhase::PostCleanup => write!(f, "post_cleanup"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for RuntimePhase {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
RuntimePhase::Initial => write!(f, "initial"),
|
||||
RuntimePhase::PostCleanup => write!(f, "post_cleanup"),
|
||||
RuntimePhase::Optimized => write!(f, "optimized"),
|
||||
}
|
||||
f.write_str(self.name())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -89,6 +89,19 @@ pub enum MirPhase {
|
||||
Runtime(RuntimePhase),
|
||||
}
|
||||
|
||||
impl MirPhase {
|
||||
pub fn name(&self) -> &'static str {
|
||||
match *self {
|
||||
MirPhase::Built => "built",
|
||||
MirPhase::Analysis(AnalysisPhase::Initial) => "analysis",
|
||||
MirPhase::Analysis(AnalysisPhase::PostCleanup) => "analysis-post-cleanup",
|
||||
MirPhase::Runtime(RuntimePhase::Initial) => "runtime",
|
||||
MirPhase::Runtime(RuntimePhase::PostCleanup) => "runtime-post-cleanup",
|
||||
MirPhase::Runtime(RuntimePhase::Optimized) => "runtime-optimized",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// See [`MirPhase::Analysis`].
|
||||
#[derive(Copy, Clone, TyEncodable, TyDecodable, Debug, PartialEq, Eq, PartialOrd, Ord)]
|
||||
#[derive(HashStable)]
|
||||
|
@ -184,7 +184,7 @@ pub fn dump_mir_for_phase_change<'tcx>(tcx: TyCtxt<'tcx>, body: &Body<'tcx>) {
|
||||
mir::dump_mir(
|
||||
tcx,
|
||||
Some(&format_args!("{:03}-000", phase_index)),
|
||||
&format!("{}", body.phase),
|
||||
body.phase.name(),
|
||||
&"after",
|
||||
body,
|
||||
|_, _| Ok(()),
|
||||
|
Loading…
Reference in New Issue
Block a user