@@ -32,6 +32,13 @@ pub enum FnCtxt {
32
32
Assoc ( AssocCtxt ) ,
33
33
}
34
34
35
+ #[ derive( Copy , Clone , Debug ) ]
36
+ pub enum BoundCtxt {
37
+ Normal ,
38
+ TraitObject ,
39
+ SuperTraits ,
40
+ }
41
+
35
42
#[ derive( Copy , Clone , Debug ) ]
36
43
pub enum FnKind < ' a > {
37
44
/// E.g., `fn foo()`, `fn foo(&self)`, or `extern "Abi" fn foo()`.
@@ -139,7 +146,7 @@ pub trait Visitor<'ast>: Sized {
139
146
fn visit_trait_ref ( & mut self , t : & ' ast TraitRef ) {
140
147
walk_trait_ref ( self , t)
141
148
}
142
- fn visit_param_bound ( & mut self , bounds : & ' ast GenericBound ) {
149
+ fn visit_param_bound ( & mut self , bounds : & ' ast GenericBound , _ctxt : BoundCtxt ) {
143
150
walk_param_bound ( self , bounds)
144
151
}
145
152
fn visit_poly_trait_ref ( & mut self , t : & ' ast PolyTraitRef , m : & ' ast TraitBoundModifier ) {
@@ -311,7 +318,7 @@ pub fn walk_item<'a, V: Visitor<'a>>(visitor: &mut V, item: &'a Item) {
311
318
ItemKind :: GlobalAsm ( ref asm) => walk_inline_asm ( visitor, asm) ,
312
319
ItemKind :: TyAlias ( box TyAlias { ref generics, ref bounds, ref ty, .. } ) => {
313
320
visitor. visit_generics ( generics) ;
314
- walk_list ! ( visitor, visit_param_bound, bounds) ;
321
+ walk_list ! ( visitor, visit_param_bound, bounds, BoundCtxt :: Normal ) ;
315
322
walk_list ! ( visitor, visit_ty, ty) ;
316
323
}
317
324
ItemKind :: Enum ( ref enum_definition, ref generics) => {
@@ -346,12 +353,12 @@ pub fn walk_item<'a, V: Visitor<'a>>(visitor: &mut V, item: &'a Item) {
346
353
ref items,
347
354
} ) => {
348
355
visitor. visit_generics ( generics) ;
349
- walk_list ! ( visitor, visit_param_bound, bounds) ;
356
+ walk_list ! ( visitor, visit_param_bound, bounds, BoundCtxt :: SuperTraits ) ;
350
357
walk_list ! ( visitor, visit_assoc_item, items, AssocCtxt :: Trait ) ;
351
358
}
352
359
ItemKind :: TraitAlias ( ref generics, ref bounds) => {
353
360
visitor. visit_generics ( generics) ;
354
- walk_list ! ( visitor, visit_param_bound, bounds) ;
361
+ walk_list ! ( visitor, visit_param_bound, bounds, BoundCtxt :: Normal ) ;
355
362
}
356
363
ItemKind :: MacCall ( ref mac) => visitor. visit_mac_call ( mac) ,
357
364
ItemKind :: MacroDef ( ref ts) => visitor. visit_mac_def ( ts, item. id ) ,
@@ -416,8 +423,11 @@ pub fn walk_ty<'a, V: Visitor<'a>>(visitor: &mut V, typ: &'a Ty) {
416
423
visitor. visit_ty ( ty) ;
417
424
visitor. visit_anon_const ( length)
418
425
}
419
- TyKind :: TraitObject ( ref bounds, ..) | TyKind :: ImplTrait ( _, ref bounds) => {
420
- walk_list ! ( visitor, visit_param_bound, bounds) ;
426
+ TyKind :: TraitObject ( ref bounds, ..) => {
427
+ walk_list ! ( visitor, visit_param_bound, bounds, BoundCtxt :: TraitObject ) ;
428
+ }
429
+ TyKind :: ImplTrait ( _, ref bounds) => {
430
+ walk_list ! ( visitor, visit_param_bound, bounds, BoundCtxt :: Normal ) ;
421
431
}
422
432
TyKind :: Typeof ( ref expression) => visitor. visit_anon_const ( expression) ,
423
433
TyKind :: Infer | TyKind :: ImplicitSelf | TyKind :: Err => { }
@@ -503,7 +513,7 @@ pub fn walk_assoc_constraint<'a, V: Visitor<'a>>(visitor: &mut V, constraint: &'
503
513
Term :: Const ( c) => visitor. visit_anon_const ( c) ,
504
514
} ,
505
515
AssocConstraintKind :: Bound { ref bounds } => {
506
- walk_list ! ( visitor, visit_param_bound, bounds) ;
516
+ walk_list ! ( visitor, visit_param_bound, bounds, BoundCtxt :: Normal ) ;
507
517
}
508
518
}
509
519
}
@@ -566,7 +576,7 @@ pub fn walk_foreign_item<'a, V: Visitor<'a>>(visitor: &mut V, item: &'a ForeignI
566
576
}
567
577
ForeignItemKind :: TyAlias ( box TyAlias { generics, bounds, ty, .. } ) => {
568
578
visitor. visit_generics ( generics) ;
569
- walk_list ! ( visitor, visit_param_bound, bounds) ;
579
+ walk_list ! ( visitor, visit_param_bound, bounds, BoundCtxt :: Normal ) ;
570
580
walk_list ! ( visitor, visit_ty, ty) ;
571
581
}
572
582
ForeignItemKind :: MacCall ( mac) => {
@@ -585,7 +595,7 @@ pub fn walk_param_bound<'a, V: Visitor<'a>>(visitor: &mut V, bound: &'a GenericB
585
595
pub fn walk_generic_param < ' a , V : Visitor < ' a > > ( visitor : & mut V , param : & ' a GenericParam ) {
586
596
visitor. visit_ident ( param. ident ) ;
587
597
walk_list ! ( visitor, visit_attribute, param. attrs. iter( ) ) ;
588
- walk_list ! ( visitor, visit_param_bound, & param. bounds) ;
598
+ walk_list ! ( visitor, visit_param_bound, & param. bounds, BoundCtxt :: Normal ) ;
589
599
match param. kind {
590
600
GenericParamKind :: Lifetime => ( ) ,
591
601
GenericParamKind :: Type { ref default } => walk_list ! ( visitor, visit_ty, default ) ,
@@ -612,14 +622,14 @@ pub fn walk_where_predicate<'a, V: Visitor<'a>>(visitor: &mut V, predicate: &'a
612
622
..
613
623
} ) => {
614
624
visitor. visit_ty ( bounded_ty) ;
615
- walk_list ! ( visitor, visit_param_bound, bounds) ;
625
+ walk_list ! ( visitor, visit_param_bound, bounds, BoundCtxt :: Normal ) ;
616
626
walk_list ! ( visitor, visit_generic_param, bound_generic_params) ;
617
627
}
618
628
WherePredicate :: RegionPredicate ( WhereRegionPredicate {
619
629
ref lifetime, ref bounds, ..
620
630
} ) => {
621
631
visitor. visit_lifetime ( lifetime) ;
622
- walk_list ! ( visitor, visit_param_bound, bounds) ;
632
+ walk_list ! ( visitor, visit_param_bound, bounds, BoundCtxt :: Normal ) ;
623
633
}
624
634
WherePredicate :: EqPredicate ( WhereEqPredicate { ref lhs_ty, ref rhs_ty, .. } ) => {
625
635
visitor. visit_ty ( lhs_ty) ;
@@ -672,7 +682,7 @@ pub fn walk_assoc_item<'a, V: Visitor<'a>>(visitor: &mut V, item: &'a AssocItem,
672
682
}
673
683
AssocItemKind :: TyAlias ( box TyAlias { generics, bounds, ty, .. } ) => {
674
684
visitor. visit_generics ( generics) ;
675
- walk_list ! ( visitor, visit_param_bound, bounds) ;
685
+ walk_list ! ( visitor, visit_param_bound, bounds, BoundCtxt :: Normal ) ;
676
686
walk_list ! ( visitor, visit_ty, ty) ;
677
687
}
678
688
AssocItemKind :: MacCall ( mac) => {
0 commit comments