diff --git a/compiler/rustc_middle/src/thir/visit.rs b/compiler/rustc_middle/src/thir/visit.rs
index 4943c11848b..ade3ea289cc 100644
--- a/compiler/rustc_middle/src/thir/visit.rs
+++ b/compiler/rustc_middle/src/thir/visit.rs
@@ -3,26 +3,26 @@ use super::{
PatKind, Stmt, StmtKind, Thir,
};
-pub trait Visitor<'a, 'tcx: 'a>: Sized {
- fn thir(&self) -> &'a Thir<'tcx>;
+pub trait Visitor<'thir, 'tcx: 'thir>: Sized {
+ fn thir(&self) -> &'thir Thir<'tcx>;
- fn visit_expr(&mut self, expr: &Expr<'tcx>) {
+ fn visit_expr(&mut self, expr: &'thir Expr<'tcx>) {
walk_expr(self, expr);
}
- fn visit_stmt(&mut self, stmt: &Stmt<'tcx>) {
+ fn visit_stmt(&mut self, stmt: &'thir Stmt<'tcx>) {
walk_stmt(self, stmt);
}
- fn visit_block(&mut self, block: &Block) {
+ fn visit_block(&mut self, block: &'thir Block) {
walk_block(self, block);
}
- fn visit_arm(&mut self, arm: &Arm<'tcx>) {
+ fn visit_arm(&mut self, arm: &'thir Arm<'tcx>) {
walk_arm(self, arm);
}
- fn visit_pat(&mut self, pat: &Pat<'tcx>) {
+ fn visit_pat(&mut self, pat: &'thir Pat<'tcx>) {
walk_pat(self, pat);
}
@@ -36,7 +36,10 @@ pub trait Visitor<'a, 'tcx: 'a>: Sized {
// other `visit*` functions.
}
-pub fn walk_expr<'a, 'tcx: 'a, V: Visitor<'a, 'tcx>>(visitor: &mut V, expr: &Expr<'tcx>) {
+pub fn walk_expr<'thir, 'tcx: 'thir, V: Visitor<'thir, 'tcx>>(
+ visitor: &mut V,
+ expr: &'thir Expr<'tcx>,
+) {
use ExprKind::*;
match expr.kind {
Scope { value, region_scope: _, lint_level: _ } => {
@@ -168,7 +171,10 @@ pub fn walk_expr<'a, 'tcx: 'a, V: Visitor<'a, 'tcx>>(visitor: &mut V, expr: &Exp
}
}
-pub fn walk_stmt<'a, 'tcx: 'a, V: Visitor<'a, 'tcx>>(visitor: &mut V, stmt: &Stmt<'tcx>) {
+pub fn walk_stmt<'thir, 'tcx: 'thir, V: Visitor<'thir, 'tcx>>(
+ visitor: &mut V,
+ stmt: &'thir Stmt<'tcx>,
+) {
match &stmt.kind {
StmtKind::Expr { expr, scope: _ } => visitor.visit_expr(&visitor.thir()[*expr]),
StmtKind::Let {
@@ -191,7 +197,10 @@ pub fn walk_stmt<'a, 'tcx: 'a, V: Visitor<'a, 'tcx>>(visitor: &mut V, stmt: &Stm
}
}
-pub fn walk_block<'a, 'tcx: 'a, V: Visitor<'a, 'tcx>>(visitor: &mut V, block: &Block) {
+pub fn walk_block<'thir, 'tcx: 'thir, V: Visitor<'thir, 'tcx>>(
+ visitor: &mut V,
+ block: &'thir Block,
+) {
for &stmt in &*block.stmts {
visitor.visit_stmt(&visitor.thir()[stmt]);
}
@@ -200,7 +209,10 @@ pub fn walk_block<'a, 'tcx: 'a, V: Visitor<'a, 'tcx>>(visitor: &mut V, block: &B
}
}
-pub fn walk_arm<'a, 'tcx: 'a, V: Visitor<'a, 'tcx>>(visitor: &mut V, arm: &Arm<'tcx>) {
+pub fn walk_arm<'thir, 'tcx: 'thir, V: Visitor<'thir, 'tcx>>(
+ visitor: &mut V,
+ arm: &'thir Arm<'tcx>,
+) {
match arm.guard {
Some(Guard::If(expr)) => visitor.visit_expr(&visitor.thir()[expr]),
Some(Guard::IfLet(ref pat, expr)) => {
@@ -213,7 +225,10 @@ pub fn walk_arm<'a, 'tcx: 'a, V: Visitor<'a, 'tcx>>(visitor: &mut V, arm: &Arm<'
visitor.visit_expr(&visitor.thir()[arm.body]);
}
-pub fn walk_pat<'a, 'tcx: 'a, V: Visitor<'a, 'tcx>>(visitor: &mut V, pat: &Pat<'tcx>) {
+pub fn walk_pat<'thir, 'tcx: 'thir, V: Visitor<'thir, 'tcx>>(
+ visitor: &mut V,
+ pat: &'thir Pat<'tcx>,
+) {
use PatKind::*;
match &pat.kind {
AscribeUserType { subpattern, ascription: _ }
diff --git a/compiler/rustc_mir_build/src/check_unsafety.rs b/compiler/rustc_mir_build/src/check_unsafety.rs
index 62190848dd5..d529c5ea159 100644
--- a/compiler/rustc_mir_build/src/check_unsafety.rs
+++ b/compiler/rustc_mir_build/src/check_unsafety.rs
@@ -175,7 +175,7 @@ impl<'a, 'tcx> Visitor<'a, 'tcx> for LayoutConstrainedPlaceVisitor<'a, 'tcx> {
self.thir
}
- fn visit_expr(&mut self, expr: &Expr<'tcx>) {
+ fn visit_expr(&mut self, expr: &'a Expr<'tcx>) {
match expr.kind {
ExprKind::Field { lhs, .. } => {
if let ty::Adt(adt_def, _) = self.thir[lhs].ty.kind() {
@@ -206,7 +206,7 @@ impl<'a, 'tcx> Visitor<'a, 'tcx> for UnsafetyVisitor<'a, 'tcx> {
self.thir
}
- fn visit_block(&mut self, block: &Block) {
+ fn visit_block(&mut self, block: &'a Block) {
match block.safety_mode {
// compiler-generated unsafe code should not count towards the usefulness of
// an outer unsafe block
@@ -234,7 +234,7 @@ impl<'a, 'tcx> Visitor<'a, 'tcx> for UnsafetyVisitor<'a, 'tcx> {
}
}
- fn visit_pat(&mut self, pat: &Pat<'tcx>) {
+ fn visit_pat(&mut self, pat: &'a Pat<'tcx>) {
if self.in_union_destructure {
match pat.kind {
// binding to a variable allows getting stuff out of variable
@@ -319,7 +319,7 @@ impl<'a, 'tcx> Visitor<'a, 'tcx> for UnsafetyVisitor<'a, 'tcx> {
}
}
- fn visit_expr(&mut self, expr: &Expr<'tcx>) {
+ fn visit_expr(&mut self, expr: &'a Expr<'tcx>) {
// could we be in the LHS of an assignment to a field?
match expr.kind {
ExprKind::Field { .. }
diff --git a/compiler/rustc_mir_build/src/thir/pattern/check_match.rs b/compiler/rustc_mir_build/src/thir/pattern/check_match.rs
index fcccdf105f6..0e85b3452d3 100644
--- a/compiler/rustc_mir_build/src/thir/pattern/check_match.rs
+++ b/compiler/rustc_mir_build/src/thir/pattern/check_match.rs
@@ -98,7 +98,7 @@ impl<'thir, 'tcx> Visitor<'thir, 'tcx> for MatchVisitor<'thir, '_, 'tcx> {
}
#[instrument(level = "trace", skip(self))]
- fn visit_arm(&mut self, arm: &Arm<'tcx>) {
+ fn visit_arm(&mut self, arm: &'thir Arm<'tcx>) {
self.with_lint_level(arm.lint_level, |this| {
match arm.guard {
Some(Guard::If(expr)) => {
@@ -121,7 +121,7 @@ impl<'thir, 'tcx> Visitor<'thir, 'tcx> for MatchVisitor<'thir, '_, 'tcx> {
}
#[instrument(level = "trace", skip(self))]
- fn visit_expr(&mut self, ex: &Expr<'tcx>) {
+ fn visit_expr(&mut self, ex: &'thir Expr<'tcx>) {
match ex.kind {
ExprKind::Scope { value, lint_level, .. } => {
self.with_lint_level(lint_level, |this| {
@@ -174,7 +174,7 @@ impl<'thir, 'tcx> Visitor<'thir, 'tcx> for MatchVisitor<'thir, '_, 'tcx> {
self.with_let_source(LetSource::None, |this| visit::walk_expr(this, ex));
}
- fn visit_stmt(&mut self, stmt: &Stmt<'tcx>) {
+ fn visit_stmt(&mut self, stmt: &'thir Stmt<'tcx>) {
match stmt.kind {
StmtKind::Let {
box ref pattern, initializer, else_block, lint_level, span, ..
@@ -224,7 +224,7 @@ impl<'thir, 'p, 'tcx> MatchVisitor<'thir, 'p, 'tcx> {
/// subexpressions we are not handling ourselves.
fn visit_land(
&mut self,
- ex: &Expr<'tcx>,
+ ex: &'thir Expr<'tcx>,
accumulator: &mut Vec