Skip to content

Commit a124924

Browse files
committed
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>) { ```
1 parent 0b6f079 commit a124924

35 files changed

+117
-119
lines changed

compiler/rustc_mir_transform/src/add_retag.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ fn is_stable(place: PlaceRef<'_>) -> bool {
3434
}
3535

3636
/// Determine whether this type may be a reference (or box), and thus needs retagging.
37-
fn may_be_reference(ty: Ty<'tcx>) -> bool {
37+
fn may_be_reference(ty: Ty<'_>) -> bool {
3838
match ty.kind() {
3939
// Primitive types that are not references
4040
ty::Bool

compiler/rustc_mir_transform/src/check_const_item_mutation.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ struct ConstMutationChecker<'a, 'tcx> {
2323
target_local: Option<Local>,
2424
}
2525

26-
impl<'a, 'tcx> ConstMutationChecker<'a, 'tcx> {
26+
impl<'tcx> ConstMutationChecker<'_, 'tcx> {
2727
fn is_const_item(&self, local: Local) -> Option<DefId> {
2828
if let Some(box LocalInfo::ConstRef { def_id }) = self.body.local_decls[local].local_info {
2929
Some(def_id)
@@ -95,7 +95,7 @@ impl<'a, 'tcx> ConstMutationChecker<'a, 'tcx> {
9595
}
9696
}
9797

98-
impl<'a, 'tcx> Visitor<'tcx> for ConstMutationChecker<'a, 'tcx> {
98+
impl<'tcx> Visitor<'tcx> for ConstMutationChecker<'_, 'tcx> {
9999
fn visit_statement(&mut self, stmt: &Statement<'tcx>, loc: Location) {
100100
if let StatementKind::Assign(box (lhs, _)) = &stmt.kind {
101101
// Check for assignment to fields of a constant

compiler/rustc_mir_transform/src/check_packed_ref.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ fn builtin_derive_def_id(tcx: TyCtxt<'_>, def_id: DefId) -> Option<DefId> {
6666
}
6767
}
6868

69-
impl<'a, 'tcx> Visitor<'tcx> for PackedRefChecker<'a, 'tcx> {
69+
impl<'tcx> Visitor<'tcx> for PackedRefChecker<'_, 'tcx> {
7070
fn visit_terminator(&mut self, terminator: &Terminator<'tcx>, location: Location) {
7171
// Make sure we know where in the MIR we are.
7272
self.source_info = terminator.source_info;

compiler/rustc_mir_transform/src/check_unsafety.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ impl<'a, 'tcx> UnsafetyChecker<'a, 'tcx> {
4646
}
4747
}
4848

49-
impl<'a, 'tcx> Visitor<'tcx> for UnsafetyChecker<'a, 'tcx> {
49+
impl<'tcx> Visitor<'tcx> for UnsafetyChecker<'_, 'tcx> {
5050
fn visit_terminator(&mut self, terminator: &Terminator<'tcx>, location: Location) {
5151
self.source_info = terminator.source_info;
5252
match terminator.kind {
@@ -244,7 +244,7 @@ impl<'a, 'tcx> Visitor<'tcx> for UnsafetyChecker<'a, 'tcx> {
244244
}
245245
}
246246

247-
impl<'a, 'tcx> UnsafetyChecker<'a, 'tcx> {
247+
impl<'tcx> UnsafetyChecker<'_, 'tcx> {
248248
fn require_unsafe(&mut self, kind: UnsafetyViolationKind, details: UnsafetyViolationDetails) {
249249
// Violations can turn out to be `UnsafeFn` during analysis, but they should not start out as such.
250250
assert_ne!(kind, UnsafetyViolationKind::UnsafeFn);
@@ -397,7 +397,7 @@ struct UnusedUnsafeVisitor<'a> {
397397
unsafe_blocks: &'a mut Vec<(hir::HirId, bool)>,
398398
}
399399

400-
impl<'a, 'tcx> intravisit::Visitor<'tcx> for UnusedUnsafeVisitor<'a> {
400+
impl<'tcx> intravisit::Visitor<'tcx> for UnusedUnsafeVisitor<'_> {
401401
type Map = intravisit::ErasedMap<'tcx>;
402402

403403
fn nested_visit_map(&mut self) -> intravisit::NestedVisitorMap<Self::Map> {

compiler/rustc_mir_transform/src/const_debuginfo.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ fn find_optimization_oportunities<'tcx>(body: &Body<'tcx>) -> Vec<(Local, Consta
8989
eligable_locals
9090
}
9191

92-
impl<'tcx> Visitor<'tcx> for LocalUseVisitor {
92+
impl Visitor<'_> for LocalUseVisitor {
9393
fn visit_local(&mut self, local: &Local, context: PlaceContext, location: Location) {
9494
if context.is_mutating_use() {
9595
self.local_mutating_uses[*local] = self.local_mutating_uses[*local].saturating_add(1);

compiler/rustc_mir_transform/src/const_goto.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ impl<'tcx> MirPass<'tcx> for ConstGoto {
5454
}
5555
}
5656

57-
impl<'a, 'tcx> Visitor<'tcx> for ConstGotoOptimizationFinder<'a, 'tcx> {
57+
impl<'tcx> Visitor<'tcx> for ConstGotoOptimizationFinder<'_, 'tcx> {
5858
fn visit_terminator(&mut self, terminator: &Terminator<'tcx>, location: Location) {
5959
let _: Option<_> = try {
6060
let target = terminator.kind.as_goto()?;

compiler/rustc_mir_transform/src/const_prop.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ struct ConstPropMachine<'mir, 'tcx> {
171171
can_const_prop: IndexVec<Local, ConstPropMode>,
172172
}
173173

174-
impl<'mir, 'tcx> ConstPropMachine<'mir, 'tcx> {
174+
impl ConstPropMachine<'_, '_> {
175175
fn new(
176176
only_propagate_inside_block_locals: BitSet<Local>,
177177
can_const_prop: IndexVec<Local, ConstPropMode>,
@@ -308,14 +308,14 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for ConstPropMachine<'mir, 'tcx>
308308
}
309309

310310
#[inline(always)]
311-
fn stack(
311+
fn stack<'a>(
312312
ecx: &'a InterpCx<'mir, 'tcx, Self>,
313313
) -> &'a [Frame<'mir, 'tcx, Self::PointerTag, Self::FrameExtra>] {
314314
&ecx.machine.stack
315315
}
316316

317317
#[inline(always)]
318-
fn stack_mut(
318+
fn stack_mut<'a>(
319319
ecx: &'a mut InterpCx<'mir, 'tcx, Self>,
320320
) -> &'a mut Vec<Frame<'mir, 'tcx, Self::PointerTag, Self::FrameExtra>> {
321321
&mut ecx.machine.stack
@@ -336,7 +336,7 @@ struct ConstPropagator<'mir, 'tcx> {
336336
source_info: Option<SourceInfo>,
337337
}
338338

339-
impl<'mir, 'tcx> LayoutOfHelpers<'tcx> for ConstPropagator<'mir, 'tcx> {
339+
impl<'tcx> LayoutOfHelpers<'tcx> for ConstPropagator<'_, 'tcx> {
340340
type LayoutOfResult = Result<TyAndLayout<'tcx>, LayoutError<'tcx>>;
341341

342342
#[inline]
@@ -345,21 +345,21 @@ impl<'mir, 'tcx> LayoutOfHelpers<'tcx> for ConstPropagator<'mir, 'tcx> {
345345
}
346346
}
347347

348-
impl<'mir, 'tcx> HasDataLayout for ConstPropagator<'mir, 'tcx> {
348+
impl HasDataLayout for ConstPropagator<'_, '_> {
349349
#[inline]
350350
fn data_layout(&self) -> &TargetDataLayout {
351351
&self.tcx.data_layout
352352
}
353353
}
354354

355-
impl<'mir, 'tcx> ty::layout::HasTyCtxt<'tcx> for ConstPropagator<'mir, 'tcx> {
355+
impl<'tcx> ty::layout::HasTyCtxt<'tcx> for ConstPropagator<'_, 'tcx> {
356356
#[inline]
357357
fn tcx(&self) -> TyCtxt<'tcx> {
358358
self.tcx
359359
}
360360
}
361361

362-
impl<'mir, 'tcx> ty::layout::HasParamEnv<'tcx> for ConstPropagator<'mir, 'tcx> {
362+
impl<'tcx> ty::layout::HasParamEnv<'tcx> for ConstPropagator<'_, 'tcx> {
363363
#[inline]
364364
fn param_env(&self) -> ty::ParamEnv<'tcx> {
365365
self.param_env
@@ -971,7 +971,7 @@ struct CanConstProp {
971971

972972
impl CanConstProp {
973973
/// Returns true if `local` can be propagated
974-
fn check(
974+
fn check<'tcx>(
975975
tcx: TyCtxt<'tcx>,
976976
param_env: ParamEnv<'tcx>,
977977
body: &Body<'tcx>,
@@ -1019,7 +1019,7 @@ impl CanConstProp {
10191019
}
10201020
}
10211021

1022-
impl<'tcx> Visitor<'tcx> for CanConstProp {
1022+
impl Visitor<'_> for CanConstProp {
10231023
fn visit_local(&mut self, &local: &Local, context: PlaceContext, _: Location) {
10241024
use rustc_middle::mir::visit::PlaceContext::*;
10251025
match context {
@@ -1079,7 +1079,7 @@ impl<'tcx> Visitor<'tcx> for CanConstProp {
10791079
}
10801080
}
10811081

1082-
impl<'mir, 'tcx> MutVisitor<'tcx> for ConstPropagator<'mir, 'tcx> {
1082+
impl<'tcx> MutVisitor<'tcx> for ConstPropagator<'_, 'tcx> {
10831083
fn tcx(&self) -> TyCtxt<'tcx> {
10841084
self.tcx
10851085
}

compiler/rustc_mir_transform/src/coverage/debug.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ impl UsedExpressions {
629629
}
630630

631631
/// Generates the MIR pass `CoverageSpan`-specific spanview dump file.
632-
pub(super) fn dump_coverage_spanview(
632+
pub(super) fn dump_coverage_spanview<'tcx>(
633633
tcx: TyCtxt<'tcx>,
634634
mir_body: &mir::Body<'tcx>,
635635
basic_coverage_blocks: &CoverageGraph,
@@ -651,7 +651,7 @@ pub(super) fn dump_coverage_spanview(
651651
}
652652

653653
/// Converts the computed `BasicCoverageBlockData`s into `SpanViewable`s.
654-
fn span_viewables(
654+
fn span_viewables<'tcx>(
655655
tcx: TyCtxt<'tcx>,
656656
mir_body: &mir::Body<'tcx>,
657657
basic_coverage_blocks: &CoverageGraph,
@@ -670,7 +670,7 @@ fn span_viewables(
670670
}
671671

672672
/// Generates the MIR pass coverage-specific graphviz dump file.
673-
pub(super) fn dump_coverage_graphviz(
673+
pub(super) fn dump_coverage_graphviz<'tcx>(
674674
tcx: TyCtxt<'tcx>,
675675
mir_body: &mir::Body<'tcx>,
676676
pass_name: &str,
@@ -750,7 +750,7 @@ pub(super) fn dump_coverage_graphviz(
750750
.expect("Unexpected error writing BasicCoverageBlock graphviz DOT file");
751751
}
752752

753-
fn bcb_to_string_sections(
753+
fn bcb_to_string_sections<'tcx>(
754754
tcx: TyCtxt<'tcx>,
755755
mir_body: &mir::Body<'tcx>,
756756
debug_counters: &DebugCounters,
@@ -817,7 +817,7 @@ fn bcb_to_string_sections(
817817

818818
/// Returns a simple string representation of a `TerminatorKind` variant, independent of any
819819
/// values it might hold.
820-
pub(super) fn term_type(kind: &TerminatorKind<'tcx>) -> &'static str {
820+
pub(super) fn term_type(kind: &TerminatorKind<'_>) -> &'static str {
821821
match kind {
822822
TerminatorKind::Goto { .. } => "Goto",
823823
TerminatorKind::SwitchInt { .. } => "SwitchInt",

compiler/rustc_mir_transform/src/coverage/graph.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub(super) struct CoverageGraph {
2727
}
2828

2929
impl CoverageGraph {
30-
pub fn from_mir(mir_body: &mir::Body<'tcx>) -> Self {
30+
pub fn from_mir(mir_body: &mir::Body<'_>) -> Self {
3131
let (bcbs, bb_to_bcb) = Self::compute_basic_coverage_blocks(mir_body);
3232

3333
// Pre-transform MIR `BasicBlock` successors and predecessors into the BasicCoverageBlock
@@ -74,7 +74,7 @@ impl CoverageGraph {
7474
}
7575

7676
fn compute_basic_coverage_blocks(
77-
mir_body: &mir::Body<'tcx>,
77+
mir_body: &mir::Body<'_>,
7878
) -> (
7979
IndexVec<BasicCoverageBlock, BasicCoverageBlockData>,
8080
IndexVec<BasicBlock, Option<BasicCoverageBlock>>,
@@ -267,7 +267,7 @@ impl graph::WithSuccessors for CoverageGraph {
267267
}
268268
}
269269

270-
impl graph::GraphPredecessors<'graph> for CoverageGraph {
270+
impl<'graph> graph::GraphPredecessors<'graph> for CoverageGraph {
271271
type Item = BasicCoverageBlock;
272272
type Iter = std::iter::Copied<std::slice::Iter<'graph, BasicCoverageBlock>>;
273273
}

compiler/rustc_mir_transform/src/coverage/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ impl<'a, 'tcx> Instrumentor<'a, 'tcx> {
443443
}
444444

445445
fn inject_edge_counter_basic_block(
446-
mir_body: &mut mir::Body<'tcx>,
446+
mir_body: &mut mir::Body<'_>,
447447
from_bb: BasicBlock,
448448
to_bb: BasicBlock,
449449
) -> BasicBlock {
@@ -466,7 +466,7 @@ fn inject_edge_counter_basic_block(
466466
}
467467

468468
fn inject_statement(
469-
mir_body: &mut mir::Body<'tcx>,
469+
mir_body: &mut mir::Body<'_>,
470470
counter_kind: CoverageKind,
471471
bb: BasicBlock,
472472
some_code_region: Option<CodeRegion>,
@@ -488,7 +488,7 @@ fn inject_statement(
488488
}
489489

490490
// Non-code expressions are injected into the coverage map, without generating executable code.
491-
fn inject_intermediate_expression(mir_body: &mut mir::Body<'tcx>, expression: CoverageKind) {
491+
fn inject_intermediate_expression(mir_body: &mut mir::Body<'_>, expression: CoverageKind) {
492492
debug_assert!(matches!(expression, CoverageKind::Expression { .. }));
493493
debug!(" injecting non-code expression {:?}", expression);
494494
let inject_in_bb = mir::START_BLOCK;

0 commit comments

Comments
 (0)