Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lifetime cleanups #130294

Merged
merged 10 commits into from
Sep 14, 2024
12 changes: 6 additions & 6 deletions compiler/rustc_passes/src/loops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ impl fmt::Display for BreakContextKind {
}

#[derive(Clone)]
struct CheckLoopVisitor<'a, 'tcx> {
sess: &'a Session,
struct CheckLoopVisitor<'tcx> {
sess: &'tcx Session,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can get the session from the tcx, the field can be removed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added a commit doing that.

tcx: TyCtxt<'tcx>,
// Keep track of a stack of contexts, so that suggestions
// are not made for contexts where it would be incorrect,
Expand All @@ -90,7 +90,7 @@ pub(crate) fn provide(providers: &mut 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;

fn nested_visit_map(&mut self) -> Self::Map {
Expand Down Expand Up @@ -129,7 +129,7 @@ impl<'a, 'hir> Visitor<'hir> for CheckLoopVisitor<'a, 'hir> {
hir::ExprKind::If(cond, then, else_opt) => {
self.visit_expr(cond);

let get_block = |ck_loop: &CheckLoopVisitor<'a, 'hir>,
let get_block = |ck_loop: &CheckLoopVisitor<'hir>,
expr: &hir::Expr<'hir>|
-> Option<&hir::Block<'hir>> {
if let hir::ExprKind::Block(b, None) = expr.kind
Expand Down Expand Up @@ -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)
where
F: FnOnce(&mut CheckLoopVisitor<'a, 'hir>),
F: FnOnce(&mut CheckLoopVisitor<'hir>),
{
self.cx_stack.push(cx);
f(self);
Expand Down