1
Fork 0

Remove unnecessary lifetime from CheckLoopVisitor.

This commit is contained in:
Nicholas Nethercote 2024-09-12 10:39:01 +10:00
parent 5138399885
commit 0b59bba6ec

View file

@ -64,8 +64,8 @@ impl fmt::Display for BreakContextKind {
} }
#[derive(Clone)] #[derive(Clone)]
struct CheckLoopVisitor<'a, 'tcx> { struct CheckLoopVisitor<'tcx> {
sess: &'a Session, sess: &'tcx Session,
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
// Keep track of a stack of contexts, so that suggestions // Keep track of a stack of contexts, so that suggestions
// are not made for contexts where it would be incorrect, // are not made for contexts where it would be incorrect,
@ -90,7 +90,7 @@ pub(crate) fn provide(providers: &mut Providers) {
*providers = Providers { check_mod_loops, ..*providers }; *providers = Providers { check_mod_loops, ..*providers };
} }
impl<'a, 'hir> Visitor<'hir> for CheckLoopVisitor<'a, 'hir> { impl<'hir> Visitor<'hir> for CheckLoopVisitor<'hir> {
type NestedFilter = nested_filter::OnlyBodies; type NestedFilter = nested_filter::OnlyBodies;
fn nested_visit_map(&mut self) -> Self::Map { fn nested_visit_map(&mut self) -> Self::Map {
@ -129,7 +129,7 @@ impl<'a, 'hir> Visitor<'hir> for CheckLoopVisitor<'a, 'hir> {
hir::ExprKind::If(cond, then, else_opt) => { hir::ExprKind::If(cond, then, else_opt) => {
self.visit_expr(cond); self.visit_expr(cond);
let get_block = |ck_loop: &CheckLoopVisitor<'a, 'hir>, let get_block = |ck_loop: &CheckLoopVisitor<'hir>,
expr: &hir::Expr<'hir>| expr: &hir::Expr<'hir>|
-> Option<&hir::Block<'hir>> { -> Option<&hir::Block<'hir>> {
if let hir::ExprKind::Block(b, None) = expr.kind if let hir::ExprKind::Block(b, None) = expr.kind
@ -306,10 +306,10 @@ impl<'a, 'hir> Visitor<'hir> for CheckLoopVisitor<'a, 'hir> {
} }
} }
impl<'a, 'hir> CheckLoopVisitor<'a, 'hir> { impl<'hir> CheckLoopVisitor<'hir> {
fn with_context<F>(&mut self, cx: Context, f: F) fn with_context<F>(&mut self, cx: Context, f: F)
where where
F: FnOnce(&mut CheckLoopVisitor<'a, 'hir>), F: FnOnce(&mut CheckLoopVisitor<'hir>),
{ {
self.cx_stack.push(cx); self.cx_stack.push(cx);
f(self); f(self);