sync printing of MIR terminators with their new names (and dedup some to-str logic)
This commit is contained in:
parent
807e5b8022
commit
49b5701df6
2 changed files with 27 additions and 44 deletions
|
@ -238,45 +238,6 @@ pub fn source_range_no_file(tcx: TyCtxt<'_>, span: Span) -> String {
|
||||||
format!("{}:{}-{}:{}", start.line, start.col.to_usize() + 1, end.line, end.col.to_usize() + 1)
|
format!("{}:{}-{}:{}", start.line, start.col.to_usize() + 1, end.line, end.col.to_usize() + 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn statement_kind_name(statement: &Statement<'_>) -> &'static str {
|
|
||||||
use StatementKind::*;
|
|
||||||
match statement.kind {
|
|
||||||
Assign(..) => "Assign",
|
|
||||||
FakeRead(..) => "FakeRead",
|
|
||||||
SetDiscriminant { .. } => "SetDiscriminant",
|
|
||||||
Deinit(..) => "Deinit",
|
|
||||||
StorageLive(..) => "StorageLive",
|
|
||||||
StorageDead(..) => "StorageDead",
|
|
||||||
Retag(..) => "Retag",
|
|
||||||
PlaceMention(..) => "PlaceMention",
|
|
||||||
AscribeUserType(..) => "AscribeUserType",
|
|
||||||
Coverage(..) => "Coverage",
|
|
||||||
Intrinsic(..) => "Intrinsic",
|
|
||||||
ConstEvalCounter => "ConstEvalCounter",
|
|
||||||
Nop => "Nop",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn terminator_kind_name(term: &Terminator<'_>) -> &'static str {
|
|
||||||
use TerminatorKind::*;
|
|
||||||
match term.kind {
|
|
||||||
Goto { .. } => "Goto",
|
|
||||||
SwitchInt { .. } => "SwitchInt",
|
|
||||||
UnwindResume => "Resume",
|
|
||||||
UnwindTerminate => "Terminate",
|
|
||||||
Return => "Return",
|
|
||||||
Unreachable => "Unreachable",
|
|
||||||
Drop { .. } => "Drop",
|
|
||||||
Call { .. } => "Call",
|
|
||||||
Assert { .. } => "Assert",
|
|
||||||
Yield { .. } => "Yield",
|
|
||||||
GeneratorDrop => "GeneratorDrop",
|
|
||||||
FalseEdge { .. } => "FalseEdge",
|
|
||||||
FalseUnwind { .. } => "FalseUnwind",
|
|
||||||
InlineAsm { .. } => "InlineAsm",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn statement_span_viewable<'tcx>(
|
fn statement_span_viewable<'tcx>(
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
body_span: Span,
|
body_span: Span,
|
||||||
|
@ -304,7 +265,7 @@ fn terminator_span_viewable<'tcx>(
|
||||||
if !body_span.contains(span) {
|
if !body_span.contains(span) {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
let id = format!("{}:{}", bb.index(), terminator_kind_name(term));
|
let id = format!("{}:{}", bb.index(), term.kind.name());
|
||||||
let tooltip = tooltip(tcx, &id, span, vec![], &data.terminator);
|
let tooltip = tooltip(tcx, &id, span, vec![], &data.terminator);
|
||||||
Some(SpanViewable { bb, span, id, tooltip })
|
Some(SpanViewable { bb, span, id, tooltip })
|
||||||
}
|
}
|
||||||
|
@ -631,7 +592,7 @@ fn tooltip<'tcx>(
|
||||||
"\n{}{}: {}: {:?}",
|
"\n{}{}: {}: {:?}",
|
||||||
TOOLTIP_INDENT,
|
TOOLTIP_INDENT,
|
||||||
source_range,
|
source_range,
|
||||||
statement_kind_name(&statement),
|
statement.kind.name(),
|
||||||
statement
|
statement
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -641,7 +602,7 @@ fn tooltip<'tcx>(
|
||||||
"\n{}{}: {}: {:?}",
|
"\n{}{}: {}: {:?}",
|
||||||
TOOLTIP_INDENT,
|
TOOLTIP_INDENT,
|
||||||
source_range,
|
source_range,
|
||||||
terminator_kind_name(term),
|
term.kind.name(),
|
||||||
term.kind
|
term.kind
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
|
@ -380,6 +380,28 @@ pub enum StatementKind<'tcx> {
|
||||||
Nop,
|
Nop,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl StatementKind<'_> {
|
||||||
|
/// Returns a simple string representation of a `StatementKind` variant, independent of any
|
||||||
|
/// values it might hold (e.g. `StatementKind::Assign` always returns `"Assign"`).
|
||||||
|
pub const fn name(&self) -> &'static str {
|
||||||
|
match self {
|
||||||
|
StatementKind::Assign(..) => "Assign",
|
||||||
|
StatementKind::FakeRead(..) => "FakeRead",
|
||||||
|
StatementKind::SetDiscriminant { .. } => "SetDiscriminant",
|
||||||
|
StatementKind::Deinit(..) => "Deinit",
|
||||||
|
StatementKind::StorageLive(..) => "StorageLive",
|
||||||
|
StatementKind::StorageDead(..) => "StorageDead",
|
||||||
|
StatementKind::Retag(..) => "Retag",
|
||||||
|
StatementKind::PlaceMention(..) => "PlaceMention",
|
||||||
|
StatementKind::AscribeUserType(..) => "AscribeUserType",
|
||||||
|
StatementKind::Coverage(..) => "Coverage",
|
||||||
|
StatementKind::Intrinsic(..) => "Intrinsic",
|
||||||
|
StatementKind::ConstEvalCounter => "ConstEvalCounter",
|
||||||
|
StatementKind::Nop => "Nop",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(
|
#[derive(
|
||||||
Clone,
|
Clone,
|
||||||
TyEncodable,
|
TyEncodable,
|
||||||
|
@ -790,8 +812,8 @@ impl TerminatorKind<'_> {
|
||||||
match self {
|
match self {
|
||||||
TerminatorKind::Goto { .. } => "Goto",
|
TerminatorKind::Goto { .. } => "Goto",
|
||||||
TerminatorKind::SwitchInt { .. } => "SwitchInt",
|
TerminatorKind::SwitchInt { .. } => "SwitchInt",
|
||||||
TerminatorKind::UnwindResume => "Resume",
|
TerminatorKind::UnwindResume => "UnwindResume",
|
||||||
TerminatorKind::UnwindTerminate => "Terminate",
|
TerminatorKind::UnwindTerminate => "UnwindTerminate",
|
||||||
TerminatorKind::Return => "Return",
|
TerminatorKind::Return => "Return",
|
||||||
TerminatorKind::Unreachable => "Unreachable",
|
TerminatorKind::Unreachable => "Unreachable",
|
||||||
TerminatorKind::Drop { .. } => "Drop",
|
TerminatorKind::Drop { .. } => "Drop",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue