@@ -55,8 +55,11 @@ pub enum FnKind<'a> {
55
55
/// new default implementation gets introduced.)
56
56
pub trait Visitor < ' v > {
57
57
58
- fn visit_ident ( & mut self , _sp : Span , _ident : Ident ) {
59
- /*! Visit the idents */
58
+ fn visit_name ( & mut self , _span : Span , _name : Name ) {
59
+ // Nothing to do.
60
+ }
61
+ fn visit_ident ( & mut self , span : Span , ident : Ident ) {
62
+ self . visit_name ( span, ident. name ) ;
60
63
}
61
64
fn visit_mod ( & mut self , m : & ' v Mod , _s : Span , _n : NodeId ) { walk_mod ( self , m) }
62
65
fn visit_view_item ( & mut self , i : & ' v ViewItem ) { walk_view_item ( self , i) }
@@ -102,11 +105,11 @@ pub trait Visitor<'v> {
102
105
None => ( )
103
106
}
104
107
}
105
- fn visit_lifetime_ref ( & mut self , _lifetime : & ' v Lifetime ) {
106
- /*! Visits a reference to a lifetime */
108
+ fn visit_lifetime_ref ( & mut self , lifetime : & ' v Lifetime ) {
109
+ self . visit_name ( lifetime. span , lifetime . name )
107
110
}
108
- fn visit_lifetime_decl ( & mut self , _lifetime : & ' v LifetimeDef ) {
109
- /*! Visits a declaration of a lifetime */
111
+ fn visit_lifetime_def ( & mut self , lifetime : & ' v LifetimeDef ) {
112
+ walk_lifetime_def ( self , lifetime)
110
113
}
111
114
fn visit_explicit_self ( & mut self , es : & ' v ExplicitSelf ) {
112
115
walk_explicit_self ( self , es)
@@ -207,6 +210,14 @@ pub fn walk_local<'v, V: Visitor<'v>>(visitor: &mut V, local: &'v Local) {
207
210
walk_expr_opt ( visitor, & local. init ) ;
208
211
}
209
212
213
+ pub fn walk_lifetime_def < ' v , V : Visitor < ' v > > ( visitor : & mut V ,
214
+ lifetime_def : & ' v LifetimeDef ) {
215
+ visitor. visit_lifetime_ref ( & lifetime_def. lifetime ) ;
216
+ for bound in lifetime_def. bounds . iter ( ) {
217
+ visitor. visit_lifetime_ref ( bound) ;
218
+ }
219
+ }
220
+
210
221
pub fn walk_explicit_self < ' v , V : Visitor < ' v > > ( visitor : & mut V ,
211
222
explicit_self : & ' v ExplicitSelf ) {
212
223
match explicit_self. node {
@@ -424,7 +435,7 @@ pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty) {
424
435
pub fn walk_lifetime_decls_helper < ' v , V : Visitor < ' v > > ( visitor : & mut V ,
425
436
lifetimes : & ' v Vec < LifetimeDef > ) {
426
437
for l in lifetimes. iter ( ) {
427
- visitor. visit_lifetime_decl ( l) ;
438
+ visitor. visit_lifetime_def ( l) ;
428
439
}
429
440
}
430
441
@@ -555,6 +566,7 @@ pub fn walk_ty_param_bound<'v, V: Visitor<'v>>(visitor: &mut V,
555
566
556
567
pub fn walk_generics < ' v , V : Visitor < ' v > > ( visitor : & mut V , generics : & ' v Generics ) {
557
568
for type_parameter in generics. ty_params . iter ( ) {
569
+ visitor. visit_ident ( type_parameter. span , type_parameter. ident ) ;
558
570
walk_ty_param_bounds_helper ( visitor, & type_parameter. bounds ) ;
559
571
match type_parameter. default {
560
572
Some ( ref ty) => visitor. visit_ty ( & * * ty) ,
0 commit comments