Drive-by cleanup: debug::term_type
=> TerminatorKind::name
This commit is contained in:
parent
03d5f9b783
commit
f542778533
@ -749,6 +749,29 @@ pub enum TerminatorKind<'tcx> {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl TerminatorKind<'_> {
|
||||||
|
/// Returns a simple string representation of a `TerminatorKind` variant, independent of any
|
||||||
|
/// values it might hold (e.g. `TerminatorKind::Call` always returns `"Call"`).
|
||||||
|
pub const fn name(&self) -> &'static str {
|
||||||
|
match self {
|
||||||
|
TerminatorKind::Goto { .. } => "Goto",
|
||||||
|
TerminatorKind::SwitchInt { .. } => "SwitchInt",
|
||||||
|
TerminatorKind::Resume => "Resume",
|
||||||
|
TerminatorKind::Terminate => "Terminate",
|
||||||
|
TerminatorKind::Return => "Return",
|
||||||
|
TerminatorKind::Unreachable => "Unreachable",
|
||||||
|
TerminatorKind::Drop { .. } => "Drop",
|
||||||
|
TerminatorKind::Call { .. } => "Call",
|
||||||
|
TerminatorKind::Assert { .. } => "Assert",
|
||||||
|
TerminatorKind::Yield { .. } => "Yield",
|
||||||
|
TerminatorKind::GeneratorDrop => "GeneratorDrop",
|
||||||
|
TerminatorKind::FalseEdge { .. } => "FalseEdge",
|
||||||
|
TerminatorKind::FalseUnwind { .. } => "FalseUnwind",
|
||||||
|
TerminatorKind::InlineAsm { .. } => "InlineAsm",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Action to be taken when a stack unwind happens.
|
/// Action to be taken when a stack unwind happens.
|
||||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, TyEncodable, TyDecodable, Hash, HashStable)]
|
#[derive(Copy, Clone, Debug, PartialEq, Eq, TyEncodable, TyDecodable, Hash, HashStable)]
|
||||||
#[derive(TypeFoldable, TypeVisitable)]
|
#[derive(TypeFoldable, TypeVisitable)]
|
||||||
|
@ -118,7 +118,7 @@ use rustc_middle::mir::spanview::{self, SpanViewable};
|
|||||||
|
|
||||||
use rustc_data_structures::fx::FxHashMap;
|
use rustc_data_structures::fx::FxHashMap;
|
||||||
use rustc_middle::mir::coverage::*;
|
use rustc_middle::mir::coverage::*;
|
||||||
use rustc_middle::mir::{self, BasicBlock, TerminatorKind};
|
use rustc_middle::mir::{self, BasicBlock};
|
||||||
use rustc_middle::ty::TyCtxt;
|
use rustc_middle::ty::TyCtxt;
|
||||||
use rustc_span::Span;
|
use rustc_span::Span;
|
||||||
|
|
||||||
@ -796,7 +796,7 @@ fn bcb_to_string_sections<'tcx>(
|
|||||||
}
|
}
|
||||||
let non_term_blocks = bcb_data.basic_blocks[0..len - 1]
|
let non_term_blocks = bcb_data.basic_blocks[0..len - 1]
|
||||||
.iter()
|
.iter()
|
||||||
.map(|&bb| format!("{:?}: {}", bb, term_type(&mir_body[bb].terminator().kind)))
|
.map(|&bb| format!("{:?}: {}", bb, mir_body[bb].terminator().kind.name()))
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
if non_term_blocks.len() > 0 {
|
if non_term_blocks.len() > 0 {
|
||||||
sections.push(non_term_blocks.join("\n"));
|
sections.push(non_term_blocks.join("\n"));
|
||||||
@ -804,28 +804,7 @@ fn bcb_to_string_sections<'tcx>(
|
|||||||
sections.push(format!(
|
sections.push(format!(
|
||||||
"{:?}: {}",
|
"{:?}: {}",
|
||||||
bcb_data.basic_blocks.last().unwrap(),
|
bcb_data.basic_blocks.last().unwrap(),
|
||||||
term_type(&bcb_data.terminator(mir_body).kind)
|
bcb_data.terminator(mir_body).kind.name(),
|
||||||
));
|
));
|
||||||
sections
|
sections
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a simple string representation of a `TerminatorKind` variant, independent of any
|
|
||||||
/// values it might hold.
|
|
||||||
pub(super) fn term_type(kind: &TerminatorKind<'_>) -> &'static str {
|
|
||||||
match kind {
|
|
||||||
TerminatorKind::Goto { .. } => "Goto",
|
|
||||||
TerminatorKind::SwitchInt { .. } => "SwitchInt",
|
|
||||||
TerminatorKind::Resume => "Resume",
|
|
||||||
TerminatorKind::Terminate => "Terminate",
|
|
||||||
TerminatorKind::Return => "Return",
|
|
||||||
TerminatorKind::Unreachable => "Unreachable",
|
|
||||||
TerminatorKind::Drop { .. } => "Drop",
|
|
||||||
TerminatorKind::Call { .. } => "Call",
|
|
||||||
TerminatorKind::Assert { .. } => "Assert",
|
|
||||||
TerminatorKind::Yield { .. } => "Yield",
|
|
||||||
TerminatorKind::GeneratorDrop => "GeneratorDrop",
|
|
||||||
TerminatorKind::FalseEdge { .. } => "FalseEdge",
|
|
||||||
TerminatorKind::FalseUnwind { .. } => "FalseUnwind",
|
|
||||||
TerminatorKind::InlineAsm { .. } => "InlineAsm",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
use super::debug::term_type;
|
|
||||||
use super::graph::{BasicCoverageBlock, BasicCoverageBlockData, CoverageGraph, START_BCB};
|
use super::graph::{BasicCoverageBlock, BasicCoverageBlockData, CoverageGraph, START_BCB};
|
||||||
|
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
@ -40,7 +39,7 @@ impl CoverageStatement {
|
|||||||
"{}: @{}.{}: {:?}",
|
"{}: @{}.{}: {:?}",
|
||||||
source_range_no_file(tcx, span),
|
source_range_no_file(tcx, span),
|
||||||
bb.index(),
|
bb.index(),
|
||||||
term_type(&term.kind),
|
term.kind.name(),
|
||||||
term.kind
|
term.kind
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,6 @@
|
|||||||
//! to: `rustc_span::create_default_session_globals_then(|| { test_here(); })`.
|
//! to: `rustc_span::create_default_session_globals_then(|| { test_here(); })`.
|
||||||
|
|
||||||
use super::counters;
|
use super::counters;
|
||||||
use super::debug;
|
|
||||||
use super::graph;
|
use super::graph;
|
||||||
use super::spans;
|
use super::spans;
|
||||||
|
|
||||||
@ -188,12 +187,12 @@ fn debug_basic_blocks(mir_body: &Body<'_>) -> String {
|
|||||||
| TerminatorKind::Goto { target }
|
| TerminatorKind::Goto { target }
|
||||||
| TerminatorKind::InlineAsm { destination: Some(target), .. }
|
| TerminatorKind::InlineAsm { destination: Some(target), .. }
|
||||||
| TerminatorKind::Yield { resume: target, .. } => {
|
| TerminatorKind::Yield { resume: target, .. } => {
|
||||||
format!("{}{:?}:{} -> {:?}", sp, bb, debug::term_type(kind), target)
|
format!("{}{:?}:{} -> {:?}", sp, bb, kind.name(), target)
|
||||||
}
|
}
|
||||||
TerminatorKind::SwitchInt { targets, .. } => {
|
TerminatorKind::SwitchInt { targets, .. } => {
|
||||||
format!("{}{:?}:{} -> {:?}", sp, bb, debug::term_type(kind), targets)
|
format!("{}{:?}:{} -> {:?}", sp, bb, kind.name(), targets)
|
||||||
}
|
}
|
||||||
_ => format!("{}{:?}:{}", sp, bb, debug::term_type(kind)),
|
_ => format!("{}{:?}:{}", sp, bb, kind.name()),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
@ -215,7 +214,7 @@ fn print_mir_graphviz(name: &str, mir_body: &Body<'_>) {
|
|||||||
" {:?} [label=\"{:?}: {}\"];\n{}",
|
" {:?} [label=\"{:?}: {}\"];\n{}",
|
||||||
bb,
|
bb,
|
||||||
bb,
|
bb,
|
||||||
debug::term_type(&data.terminator().kind),
|
data.terminator().kind.name(),
|
||||||
mir_body
|
mir_body
|
||||||
.basic_blocks
|
.basic_blocks
|
||||||
.successors(bb)
|
.successors(bb)
|
||||||
@ -244,7 +243,7 @@ fn print_coverage_graphviz(
|
|||||||
" {:?} [label=\"{:?}: {}\"];\n{}",
|
" {:?} [label=\"{:?}: {}\"];\n{}",
|
||||||
bcb,
|
bcb,
|
||||||
bcb,
|
bcb,
|
||||||
debug::term_type(&bcb_data.terminator(mir_body).kind),
|
bcb_data.terminator(mir_body).kind.name(),
|
||||||
basic_coverage_blocks
|
basic_coverage_blocks
|
||||||
.successors(bcb)
|
.successors(bcb)
|
||||||
.map(|successor| { format!(" {:?} -> {:?};", bcb, successor) })
|
.map(|successor| { format!(" {:?} -> {:?};", bcb, successor) })
|
||||||
|
Loading…
x
Reference in New Issue
Block a user