@@ -78,6 +78,9 @@ pub trait Visitor<'v> {
78
78
fn visit_ty_method ( & mut self , t : & ' v TypeMethod ) { walk_ty_method ( self , t) }
79
79
fn visit_trait_item ( & mut self , t : & ' v TraitItem ) { walk_trait_item ( self , t) }
80
80
fn visit_trait_ref ( & mut self , t : & ' v TraitRef ) { walk_trait_ref ( self , t) }
81
+ fn visit_ty_param_bound ( & mut self , bounds : & ' v TyParamBound ) {
82
+ walk_ty_param_bound ( self , bounds)
83
+ }
81
84
fn visit_poly_trait_ref ( & mut self , t : & ' v PolyTraitRef ) {
82
85
walk_poly_trait_ref ( self , t)
83
86
}
@@ -119,6 +122,12 @@ pub trait Visitor<'v> {
119
122
fn visit_path ( & mut self , path : & ' v Path , _id : ast:: NodeId ) {
120
123
walk_path ( self , path)
121
124
}
125
+ fn visit_path_segment ( & mut self , path_span : Span , path_segment : & ' v PathSegment ) {
126
+ walk_path_segment ( self , path_span, path_segment)
127
+ }
128
+ fn visit_path_parameters ( & mut self , path_span : Span , path_parameters : & ' v PathParameters ) {
129
+ walk_path_parameters ( self , path_span, path_parameters)
130
+ }
122
131
fn visit_attribute ( & mut self , _attr : & ' v Attribute ) { }
123
132
}
124
133
@@ -170,7 +179,7 @@ pub fn walk_view_item<'v, V: Visitor<'v>>(visitor: &mut V, vi: &'v ViewItem) {
170
179
ViewPathGlob ( ref path, id) => {
171
180
visitor. visit_path ( path, id) ;
172
181
}
173
- ViewPathList ( ref path , ref list, _) => {
182
+ ViewPathList ( ref prefix , ref list, _) => {
174
183
for id in list. iter ( ) {
175
184
match id. node {
176
185
PathListIdent { name, .. } => {
@@ -179,7 +188,10 @@ pub fn walk_view_item<'v, V: Visitor<'v>>(visitor: &mut V, vi: &'v ViewItem) {
179
188
PathListMod { .. } => ( )
180
189
}
181
190
}
182
- walk_path ( visitor, path) ;
191
+
192
+ // Note that the `prefix` here is not a complete
193
+ // path, so we don't use `visit_path`.
194
+ walk_path ( visitor, prefix) ;
183
195
}
184
196
}
185
197
}
@@ -212,7 +224,7 @@ pub fn walk_poly_trait_ref<'v, V>(visitor: &mut V,
212
224
trait_ref : & ' v PolyTraitRef )
213
225
where V : Visitor < ' v >
214
226
{
215
- walk_lifetime_decls ( visitor, & trait_ref. bound_lifetimes ) ;
227
+ walk_lifetime_decls_helper ( visitor, & trait_ref. bound_lifetimes ) ;
216
228
visitor. visit_trait_ref ( & trait_ref. trait_ref ) ;
217
229
}
218
230
@@ -290,7 +302,7 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item) {
290
302
}
291
303
ItemTrait ( ref generics, _, ref bounds, ref methods) => {
292
304
visitor. visit_generics ( generics) ;
293
- walk_ty_param_bounds ( visitor, bounds) ;
305
+ walk_ty_param_bounds_helper ( visitor, bounds) ;
294
306
for method in methods. iter ( ) {
295
307
visitor. visit_trait_item ( method)
296
308
}
@@ -363,29 +375,29 @@ pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty) {
363
375
visitor. visit_ty ( & * argument. ty )
364
376
}
365
377
walk_fn_ret_ty ( visitor, & function_declaration. decl . output ) ;
366
- walk_ty_param_bounds ( visitor, & function_declaration. bounds ) ;
367
- walk_lifetime_decls ( visitor, & function_declaration. lifetimes ) ;
378
+ walk_ty_param_bounds_helper ( visitor, & function_declaration. bounds ) ;
379
+ walk_lifetime_decls_helper ( visitor, & function_declaration. lifetimes ) ;
368
380
}
369
381
TyProc ( ref function_declaration) => {
370
382
for argument in function_declaration. decl . inputs . iter ( ) {
371
383
visitor. visit_ty ( & * argument. ty )
372
384
}
373
385
walk_fn_ret_ty ( visitor, & function_declaration. decl . output ) ;
374
- walk_ty_param_bounds ( visitor, & function_declaration. bounds ) ;
375
- walk_lifetime_decls ( visitor, & function_declaration. lifetimes ) ;
386
+ walk_ty_param_bounds_helper ( visitor, & function_declaration. bounds ) ;
387
+ walk_lifetime_decls_helper ( visitor, & function_declaration. lifetimes ) ;
376
388
}
377
389
TyBareFn ( ref function_declaration) => {
378
390
for argument in function_declaration. decl . inputs . iter ( ) {
379
391
visitor. visit_ty ( & * argument. ty )
380
392
}
381
393
walk_fn_ret_ty ( visitor, & function_declaration. decl . output ) ;
382
- walk_lifetime_decls ( visitor, & function_declaration. lifetimes ) ;
394
+ walk_lifetime_decls_helper ( visitor, & function_declaration. lifetimes ) ;
383
395
}
384
396
TyPath ( ref path, ref opt_bounds, id) => {
385
397
visitor. visit_path ( path, id) ;
386
398
match * opt_bounds {
387
399
Some ( ref bounds) => {
388
- walk_ty_param_bounds ( visitor, bounds) ;
400
+ walk_ty_param_bounds_helper ( visitor, bounds) ;
389
401
}
390
402
None => { }
391
403
}
@@ -399,8 +411,8 @@ pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty) {
399
411
visitor. visit_ty ( & * * ty) ;
400
412
visitor. visit_expr ( & * * expression)
401
413
}
402
- TyPolyTraitRef ( ref poly_trait_ref ) => {
403
- visitor . visit_poly_trait_ref ( & * * poly_trait_ref )
414
+ TyPolyTraitRef ( ref bounds ) => {
415
+ walk_ty_param_bounds_helper ( visitor , bounds )
404
416
}
405
417
TyTypeof ( ref expression) => {
406
418
visitor. visit_expr ( & * * expression)
@@ -409,33 +421,44 @@ pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty) {
409
421
}
410
422
}
411
423
412
- fn walk_lifetime_decls < ' v , V : Visitor < ' v > > ( visitor : & mut V ,
413
- lifetimes : & ' v Vec < LifetimeDef > ) {
424
+ pub fn walk_lifetime_decls_helper < ' v , V : Visitor < ' v > > ( visitor : & mut V ,
425
+ lifetimes : & ' v Vec < LifetimeDef > ) {
414
426
for l in lifetimes. iter ( ) {
415
427
visitor. visit_lifetime_decl ( l) ;
416
428
}
417
429
}
418
430
419
431
pub fn walk_path < ' v , V : Visitor < ' v > > ( visitor : & mut V , path : & ' v Path ) {
420
432
for segment in path. segments . iter ( ) {
421
- visitor. visit_ident ( path. span , segment. identifier ) ;
433
+ visitor. visit_path_segment ( path. span , segment) ;
434
+ }
435
+ }
422
436
423
- match segment. parameters {
424
- ast:: AngleBracketedParameters ( ref data) => {
425
- for typ in data. types . iter ( ) {
426
- visitor. visit_ty ( & * * typ) ;
427
- }
428
- for lifetime in data. lifetimes . iter ( ) {
429
- visitor. visit_lifetime_ref ( lifetime) ;
430
- }
437
+ pub fn walk_path_segment < ' v , V : Visitor < ' v > > ( visitor : & mut V ,
438
+ path_span : Span ,
439
+ segment : & ' v PathSegment ) {
440
+ visitor. visit_ident ( path_span, segment. identifier ) ;
441
+ visitor. visit_path_parameters ( path_span, & segment. parameters ) ;
442
+ }
443
+
444
+ pub fn walk_path_parameters < ' v , V : Visitor < ' v > > ( visitor : & mut V ,
445
+ _path_span : Span ,
446
+ path_parameters : & ' v PathParameters ) {
447
+ match * path_parameters {
448
+ ast:: AngleBracketedParameters ( ref data) => {
449
+ for typ in data. types . iter ( ) {
450
+ visitor. visit_ty ( & * * typ) ;
431
451
}
432
- ast:: ParenthesizedParameters ( ref data) => {
433
- for typ in data. inputs . iter ( ) {
434
- visitor. visit_ty ( & * * typ) ;
435
- }
436
- for typ in data. output . iter ( ) {
437
- visitor. visit_ty ( & * * typ) ;
438
- }
452
+ for lifetime in data. lifetimes . iter ( ) {
453
+ visitor. visit_lifetime_ref ( lifetime) ;
454
+ }
455
+ }
456
+ ast:: ParenthesizedParameters ( ref data) => {
457
+ for typ in data. inputs . iter ( ) {
458
+ visitor. visit_ty ( & * * typ) ;
459
+ }
460
+ for typ in data. output . iter ( ) {
461
+ visitor. visit_ty ( & * * typ) ;
439
462
}
440
463
}
441
464
}
@@ -511,32 +534,37 @@ pub fn walk_foreign_item<'v, V: Visitor<'v>>(visitor: &mut V,
511
534
}
512
535
}
513
536
514
- pub fn walk_ty_param_bounds < ' v , V : Visitor < ' v > > ( visitor : & mut V ,
515
- bounds : & ' v OwnedSlice < TyParamBound > ) {
537
+ pub fn walk_ty_param_bounds_helper < ' v , V : Visitor < ' v > > ( visitor : & mut V ,
538
+ bounds : & ' v OwnedSlice < TyParamBound > ) {
516
539
for bound in bounds. iter ( ) {
517
- match * bound {
518
- TraitTyParamBound ( ref typ) => {
519
- visitor. visit_poly_trait_ref ( typ)
520
- }
521
- RegionTyParamBound ( ref lifetime) => {
522
- visitor. visit_lifetime_ref ( lifetime) ;
523
- }
540
+ visitor. visit_ty_param_bound ( bound)
541
+ }
542
+ }
543
+
544
+ pub fn walk_ty_param_bound < ' v , V : Visitor < ' v > > ( visitor : & mut V ,
545
+ bound : & ' v TyParamBound ) {
546
+ match * bound {
547
+ TraitTyParamBound ( ref typ) => {
548
+ visitor. visit_poly_trait_ref ( typ) ;
549
+ }
550
+ RegionTyParamBound ( ref lifetime) => {
551
+ visitor. visit_lifetime_ref ( lifetime) ;
524
552
}
525
553
}
526
554
}
527
555
528
556
pub fn walk_generics < ' v , V : Visitor < ' v > > ( visitor : & mut V , generics : & ' v Generics ) {
529
557
for type_parameter in generics. ty_params . iter ( ) {
530
- walk_ty_param_bounds ( visitor, & type_parameter. bounds ) ;
558
+ walk_ty_param_bounds_helper ( visitor, & type_parameter. bounds ) ;
531
559
match type_parameter. default {
532
560
Some ( ref ty) => visitor. visit_ty ( & * * ty) ,
533
561
None => { }
534
562
}
535
563
}
536
- walk_lifetime_decls ( visitor, & generics. lifetimes ) ;
564
+ walk_lifetime_decls_helper ( visitor, & generics. lifetimes ) ;
537
565
for predicate in generics. where_clause . predicates . iter ( ) {
538
566
visitor. visit_ident ( predicate. span , predicate. ident ) ;
539
- walk_ty_param_bounds ( visitor, & predicate. bounds ) ;
567
+ walk_ty_param_bounds_helper ( visitor, & predicate. bounds ) ;
540
568
}
541
569
}
542
570
0 commit comments