Skip to content

Commit e3b2d1b

Browse files
committed
Unify visit_lifetime
1 parent e14ad3d commit e3b2d1b

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

compiler/rustc_ast/src/visitors.rs

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@ macro_rules! mutability_dependent {
1515
fn visit_assoc_item(&mut self, i: &'ast AssocItem, ctxt: AssocCtxt) -> Self::Result {
1616
walk_assoc_item(self, i, ctxt)
1717
}
18-
// FIXME: inconsistent
19-
fn visit_lifetime(&mut self, lifetime: &'ast Lifetime, _: LifetimeCtxt) -> Self::Result {
20-
walk_lifetime(self, lifetime)
21-
}
2218
fn visit_mac_def(&mut self, _mac: &'ast MacroDef, _id: NodeId) -> Self::Result {
2319
Self::Result::output()
2420
}
@@ -98,10 +94,6 @@ macro_rules! mutability_dependent {
9894
noop_filter_map_expr(self, e)
9995
}
10096

101-
fn visit_lifetime(&mut self, l: &mut Lifetime) {
102-
walk_lifetime(self, l);
103-
}
104-
10597
fn visit_macro_def(&mut self, def: &mut MacroDef) {
10698
walk_macro_def(self, def);
10799
}
@@ -358,6 +350,10 @@ macro_rules! make_ast_visitor {
358350
fn visit_path(&mut self, path: ref_t!(Path), _id: NodeId) -> result!() {
359351
walk_path(self, path)
360352
}
353+
354+
fn visit_lifetime(&mut self, lifetime: ref_t!(Lifetime), _: LifetimeCtxt) -> result!() {
355+
walk_lifetime(self, lifetime)
356+
}
361357
}
362358

363359
macro_rules! visit_span {
@@ -1759,7 +1755,7 @@ pub mod mut_visit {
17591755
use crate::ptr::P;
17601756
use crate::token::{self, Token};
17611757
use crate::tokenstream::*;
1762-
use crate::visit::{AssocCtxt, BoundKind};
1758+
use crate::visit::{AssocCtxt, BoundKind, LifetimeCtxt};
17631759

17641760
pub trait ExpectOne<A: Array> {
17651761
fn expect_one(self, err: &'static str) -> A::Item;
@@ -1905,7 +1901,7 @@ pub mod mut_visit {
19051901
TyKind::Slice(ty) => vis.visit_ty(ty),
19061902
TyKind::Ptr(mt) => vis.visit_mt(mt),
19071903
TyKind::Ref(lt, mt) => {
1908-
visit_opt(lt, |lt| vis.visit_lifetime(lt));
1904+
visit_opt(lt, |lt| vis.visit_lifetime(lt, LifetimeCtxt::Ref));
19091905
vis.visit_mt(mt);
19101906
}
19111907
TyKind::BareFn(bft) => {
@@ -1955,7 +1951,7 @@ pub mod mut_visit {
19551951

19561952
fn walk_generic_arg<T: MutVisitor>(vis: &mut T, arg: &mut GenericArg) {
19571953
match arg {
1958-
GenericArg::Lifetime(lt) => vis.visit_lifetime(lt),
1954+
GenericArg::Lifetime(lt) => vis.visit_lifetime(lt, LifetimeCtxt::GenericArg),
19591955
GenericArg::Type(ty) => vis.visit_ty(ty),
19601956
GenericArg::Const(ct) => vis.visit_anon_const(ct),
19611957
}
@@ -2234,7 +2230,7 @@ pub mod mut_visit {
22342230
fn walk_precise_capturing_arg<T: MutVisitor>(vis: &mut T, arg: &mut PreciseCapturingArg) {
22352231
match arg {
22362232
PreciseCapturingArg::Lifetime(lt) => {
2237-
vis.visit_lifetime(lt);
2233+
vis.visit_lifetime(lt, LifetimeCtxt::GenericArg);
22382234
}
22392235
PreciseCapturingArg::Arg(path, id) => {
22402236
vis.visit_id(id);
@@ -2283,7 +2279,7 @@ pub mod mut_visit {
22832279
}
22842280
WherePredicate::RegionPredicate(rp) => {
22852281
let WhereRegionPredicate { span, lifetime, bounds } = rp;
2286-
vis.visit_lifetime(lifetime);
2282+
vis.visit_lifetime(lifetime, LifetimeCtxt::Bound);
22872283
visit_vec(bounds, |bound| vis.visit_param_bound(bound, BoundKind::Bound));
22882284
vis.visit_span(span);
22892285
}

0 commit comments

Comments
 (0)