Remove in_band_lifetimes from rustc_mir_transform
This one is a heavy `'tcx` user.
Two interesting ones:
This one had the `'tcx` declared on the function, despite the trait taking a `'tcx`:
```diff
-impl Visitor<'_> for UsedLocals {
+impl<'tcx> Visitor<'tcx> for UsedLocals {
fn visit_statement(&mut self, statement: &Statement<'tcx>, location: Location) {
```
This one use in-band for one, and underscore for the other:
```diff
-pub fn remove_dead_blocks(tcx: TyCtxt<'tcx>, body: &mut Body<'_>) {
+pub fn remove_dead_blocks<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
```
This commit is contained in:
@@ -629,7 +629,7 @@ impl UsedExpressions {
|
||||
}
|
||||
|
||||
/// Generates the MIR pass `CoverageSpan`-specific spanview dump file.
|
||||
pub(super) fn dump_coverage_spanview(
|
||||
pub(super) fn dump_coverage_spanview<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
mir_body: &mir::Body<'tcx>,
|
||||
basic_coverage_blocks: &CoverageGraph,
|
||||
@@ -651,7 +651,7 @@ pub(super) fn dump_coverage_spanview(
|
||||
}
|
||||
|
||||
/// Converts the computed `BasicCoverageBlockData`s into `SpanViewable`s.
|
||||
fn span_viewables(
|
||||
fn span_viewables<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
mir_body: &mir::Body<'tcx>,
|
||||
basic_coverage_blocks: &CoverageGraph,
|
||||
@@ -670,7 +670,7 @@ fn span_viewables(
|
||||
}
|
||||
|
||||
/// Generates the MIR pass coverage-specific graphviz dump file.
|
||||
pub(super) fn dump_coverage_graphviz(
|
||||
pub(super) fn dump_coverage_graphviz<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
mir_body: &mir::Body<'tcx>,
|
||||
pass_name: &str,
|
||||
@@ -750,7 +750,7 @@ pub(super) fn dump_coverage_graphviz(
|
||||
.expect("Unexpected error writing BasicCoverageBlock graphviz DOT file");
|
||||
}
|
||||
|
||||
fn bcb_to_string_sections(
|
||||
fn bcb_to_string_sections<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
mir_body: &mir::Body<'tcx>,
|
||||
debug_counters: &DebugCounters,
|
||||
@@ -817,7 +817,7 @@ fn bcb_to_string_sections(
|
||||
|
||||
/// Returns a simple string representation of a `TerminatorKind` variant, independent of any
|
||||
/// values it might hold.
|
||||
pub(super) fn term_type(kind: &TerminatorKind<'tcx>) -> &'static str {
|
||||
pub(super) fn term_type(kind: &TerminatorKind<'_>) -> &'static str {
|
||||
match kind {
|
||||
TerminatorKind::Goto { .. } => "Goto",
|
||||
TerminatorKind::SwitchInt { .. } => "SwitchInt",
|
||||
|
||||
@@ -27,7 +27,7 @@ pub(super) struct CoverageGraph {
|
||||
}
|
||||
|
||||
impl CoverageGraph {
|
||||
pub fn from_mir(mir_body: &mir::Body<'tcx>) -> Self {
|
||||
pub fn from_mir(mir_body: &mir::Body<'_>) -> Self {
|
||||
let (bcbs, bb_to_bcb) = Self::compute_basic_coverage_blocks(mir_body);
|
||||
|
||||
// Pre-transform MIR `BasicBlock` successors and predecessors into the BasicCoverageBlock
|
||||
@@ -74,7 +74,7 @@ impl CoverageGraph {
|
||||
}
|
||||
|
||||
fn compute_basic_coverage_blocks(
|
||||
mir_body: &mir::Body<'tcx>,
|
||||
mir_body: &mir::Body<'_>,
|
||||
) -> (
|
||||
IndexVec<BasicCoverageBlock, BasicCoverageBlockData>,
|
||||
IndexVec<BasicBlock, Option<BasicCoverageBlock>>,
|
||||
@@ -267,7 +267,7 @@ impl graph::WithSuccessors for CoverageGraph {
|
||||
}
|
||||
}
|
||||
|
||||
impl graph::GraphPredecessors<'graph> for CoverageGraph {
|
||||
impl<'graph> graph::GraphPredecessors<'graph> for CoverageGraph {
|
||||
type Item = BasicCoverageBlock;
|
||||
type Iter = std::iter::Copied<std::slice::Iter<'graph, BasicCoverageBlock>>;
|
||||
}
|
||||
|
||||
@@ -443,7 +443,7 @@ impl<'a, 'tcx> Instrumentor<'a, 'tcx> {
|
||||
}
|
||||
|
||||
fn inject_edge_counter_basic_block(
|
||||
mir_body: &mut mir::Body<'tcx>,
|
||||
mir_body: &mut mir::Body<'_>,
|
||||
from_bb: BasicBlock,
|
||||
to_bb: BasicBlock,
|
||||
) -> BasicBlock {
|
||||
@@ -466,7 +466,7 @@ fn inject_edge_counter_basic_block(
|
||||
}
|
||||
|
||||
fn inject_statement(
|
||||
mir_body: &mut mir::Body<'tcx>,
|
||||
mir_body: &mut mir::Body<'_>,
|
||||
counter_kind: CoverageKind,
|
||||
bb: BasicBlock,
|
||||
some_code_region: Option<CodeRegion>,
|
||||
@@ -488,7 +488,7 @@ fn inject_statement(
|
||||
}
|
||||
|
||||
// Non-code expressions are injected into the coverage map, without generating executable code.
|
||||
fn inject_intermediate_expression(mir_body: &mut mir::Body<'tcx>, expression: CoverageKind) {
|
||||
fn inject_intermediate_expression(mir_body: &mut mir::Body<'_>, expression: CoverageKind) {
|
||||
debug_assert!(matches!(expression, CoverageKind::Expression { .. }));
|
||||
debug!(" injecting non-code expression {:?}", expression);
|
||||
let inject_in_bb = mir::START_BLOCK;
|
||||
|
||||
@@ -137,7 +137,7 @@ fn coverageinfo<'tcx>(tcx: TyCtxt<'tcx>, instance_def: ty::InstanceDef<'tcx>) ->
|
||||
coverage_visitor.info
|
||||
}
|
||||
|
||||
fn covered_file_name<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> Option<Symbol> {
|
||||
fn covered_file_name(tcx: TyCtxt<'_>, def_id: DefId) -> Option<Symbol> {
|
||||
if tcx.is_mir_available(def_id) {
|
||||
let body = mir_body(tcx, def_id);
|
||||
for bb_data in body.basic_blocks().iter() {
|
||||
|
||||
@@ -21,7 +21,7 @@ pub(super) enum CoverageStatement {
|
||||
}
|
||||
|
||||
impl CoverageStatement {
|
||||
pub fn format(&self, tcx: TyCtxt<'tcx>, mir_body: &'a mir::Body<'tcx>) -> String {
|
||||
pub fn format<'tcx>(&self, tcx: TyCtxt<'tcx>, mir_body: &mir::Body<'tcx>) -> String {
|
||||
match *self {
|
||||
Self::Statement(bb, span, stmt_index) => {
|
||||
let stmt = &mir_body[bb].statements[stmt_index];
|
||||
@@ -86,7 +86,7 @@ impl CoverageSpan {
|
||||
}
|
||||
|
||||
pub fn for_statement(
|
||||
statement: &Statement<'tcx>,
|
||||
statement: &Statement<'_>,
|
||||
span: Span,
|
||||
expn_span: Span,
|
||||
bcb: BasicCoverageBlock,
|
||||
@@ -151,7 +151,7 @@ impl CoverageSpan {
|
||||
self.bcb == other.bcb
|
||||
}
|
||||
|
||||
pub fn format(&self, tcx: TyCtxt<'tcx>, mir_body: &'a mir::Body<'tcx>) -> String {
|
||||
pub fn format<'tcx>(&self, tcx: TyCtxt<'tcx>, mir_body: &mir::Body<'tcx>) -> String {
|
||||
format!(
|
||||
"{}\n {}",
|
||||
source_range_no_file(tcx, &self.span),
|
||||
@@ -159,10 +159,10 @@ impl CoverageSpan {
|
||||
)
|
||||
}
|
||||
|
||||
pub fn format_coverage_statements(
|
||||
pub fn format_coverage_statements<'tcx>(
|
||||
&self,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
mir_body: &'a mir::Body<'tcx>,
|
||||
mir_body: &mir::Body<'tcx>,
|
||||
) -> String {
|
||||
let mut sorted_coverage_statements = self.coverage_statements.clone();
|
||||
sorted_coverage_statements.sort_unstable_by_key(|covstmt| match *covstmt {
|
||||
@@ -803,7 +803,7 @@ impl<'a, 'tcx> CoverageSpans<'a, 'tcx> {
|
||||
|
||||
/// If the MIR `Statement` has a span contributive to computing coverage spans,
|
||||
/// return it; otherwise return `None`.
|
||||
pub(super) fn filtered_statement_span(statement: &'a Statement<'tcx>) -> Option<Span> {
|
||||
pub(super) fn filtered_statement_span(statement: &Statement<'_>) -> Option<Span> {
|
||||
match statement.kind {
|
||||
// These statements have spans that are often outside the scope of the executed source code
|
||||
// for their parent `BasicBlock`.
|
||||
@@ -847,7 +847,7 @@ pub(super) fn filtered_statement_span(statement: &'a Statement<'tcx>) -> Option<
|
||||
|
||||
/// If the MIR `Terminator` has a span contributive to computing coverage spans,
|
||||
/// return it; otherwise return `None`.
|
||||
pub(super) fn filtered_terminator_span(terminator: &'a Terminator<'tcx>) -> Option<Span> {
|
||||
pub(super) fn filtered_terminator_span(terminator: &Terminator<'_>) -> Option<Span> {
|
||||
match terminator.kind {
|
||||
// These terminators have spans that don't positively contribute to computing a reasonable
|
||||
// span of actually executed source code. (For example, SwitchInt terminators extracted from
|
||||
|
||||
@@ -180,7 +180,7 @@ impl<'tcx> MockBlocks<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
fn debug_basic_blocks(mir_body: &Body<'tcx>) -> String {
|
||||
fn debug_basic_blocks<'tcx>(mir_body: &Body<'tcx>) -> String {
|
||||
format!(
|
||||
"{:?}",
|
||||
mir_body
|
||||
@@ -273,7 +273,7 @@ fn print_coverage_graphviz(
|
||||
}
|
||||
|
||||
/// Create a mock `Body` with a simple flow.
|
||||
fn goto_switchint() -> Body<'a> {
|
||||
fn goto_switchint<'a>() -> Body<'a> {
|
||||
let mut blocks = MockBlocks::new();
|
||||
let start = blocks.call(None);
|
||||
let goto = blocks.goto(Some(start));
|
||||
@@ -363,7 +363,7 @@ fn test_covgraph_goto_switchint() {
|
||||
}
|
||||
|
||||
/// Create a mock `Body` with a loop.
|
||||
fn switchint_then_loop_else_return() -> Body<'a> {
|
||||
fn switchint_then_loop_else_return<'a>() -> Body<'a> {
|
||||
let mut blocks = MockBlocks::new();
|
||||
let start = blocks.call(None);
|
||||
let switchint = blocks.switchint(Some(start));
|
||||
@@ -449,7 +449,7 @@ fn test_covgraph_switchint_then_loop_else_return() {
|
||||
}
|
||||
|
||||
/// Create a mock `Body` with nested loops.
|
||||
fn switchint_loop_then_inner_loop_else_break() -> Body<'a> {
|
||||
fn switchint_loop_then_inner_loop_else_break<'a>() -> Body<'a> {
|
||||
let mut blocks = MockBlocks::new();
|
||||
let start = blocks.call(None);
|
||||
let switchint = blocks.switchint(Some(start));
|
||||
|
||||
Reference in New Issue
Block a user