@@ -32,6 +32,25 @@ pub enum FnCtxt {
3232    Assoc ( AssocCtxt ) , 
3333} 
3434
35+ #[ derive( Copy ,  Clone ,  Debug ) ]  
36+ pub  enum  BoundKind  { 
37+     /// Trait bounds in generics bounds and type/trait alias. 
38+      /// E.g., `<T: Bound>`, `type A: Bound`, or `where T: Bound`. 
39+      Bound , 
40+ 
41+     /// Trait bounds in `impl` type. 
42+      /// E.g., `type Foo = impl Bound1 + Bound2 + Bound3`. 
43+      Impl , 
44+ 
45+     /// Trait bounds in trait object type. 
46+      /// E.g., `dyn Bound1 + Bound2 + Bound3`. 
47+      TraitObject , 
48+ 
49+     /// Super traits of a trait. 
50+      /// E.g., `trait A: B` 
51+      SuperTraits , 
52+ } 
53+ 
3554#[ derive( Copy ,  Clone ,  Debug ) ]  
3655pub  enum  FnKind < ' a >  { 
3756    /// E.g., `fn foo()`, `fn foo(&self)`, or `extern "Abi" fn foo()`. 
@@ -139,7 +158,7 @@ pub trait Visitor<'ast>: Sized {
139158    fn  visit_trait_ref ( & mut  self ,  t :  & ' ast  TraitRef )  { 
140159        walk_trait_ref ( self ,  t) 
141160    } 
142-     fn  visit_param_bound ( & mut  self ,  bounds :  & ' ast  GenericBound )  { 
161+     fn  visit_param_bound ( & mut  self ,  bounds :  & ' ast  GenericBound ,   _ctxt :   BoundKind )  { 
143162        walk_param_bound ( self ,  bounds) 
144163    } 
145164    fn  visit_poly_trait_ref ( & mut  self ,  t :  & ' ast  PolyTraitRef ,  m :  & ' ast  TraitBoundModifier )  { 
@@ -311,7 +330,7 @@ pub fn walk_item<'a, V: Visitor<'a>>(visitor: &mut V, item: &'a Item) {
311330        ItemKind :: GlobalAsm ( ref  asm)  => walk_inline_asm ( visitor,  asm) , 
312331        ItemKind :: TyAlias ( box TyAlias  {  ref  generics,  ref  bounds,  ref  ty,  .. } )  => { 
313332            visitor. visit_generics ( generics) ; 
314-             walk_list ! ( visitor,  visit_param_bound,  bounds) ; 
333+             walk_list ! ( visitor,  visit_param_bound,  bounds,   BoundKind :: Bound ) ; 
315334            walk_list ! ( visitor,  visit_ty,  ty) ; 
316335        } 
317336        ItemKind :: Enum ( ref  enum_definition,  ref  generics)  => { 
@@ -346,12 +365,12 @@ pub fn walk_item<'a, V: Visitor<'a>>(visitor: &mut V, item: &'a Item) {
346365            ref  items, 
347366        } )  => { 
348367            visitor. visit_generics ( generics) ; 
349-             walk_list ! ( visitor,  visit_param_bound,  bounds) ; 
368+             walk_list ! ( visitor,  visit_param_bound,  bounds,   BoundKind :: SuperTraits ) ; 
350369            walk_list ! ( visitor,  visit_assoc_item,  items,  AssocCtxt :: Trait ) ; 
351370        } 
352371        ItemKind :: TraitAlias ( ref  generics,  ref  bounds)  => { 
353372            visitor. visit_generics ( generics) ; 
354-             walk_list ! ( visitor,  visit_param_bound,  bounds) ; 
373+             walk_list ! ( visitor,  visit_param_bound,  bounds,   BoundKind :: Bound ) ; 
355374        } 
356375        ItemKind :: MacCall ( ref  mac)  => visitor. visit_mac_call ( mac) , 
357376        ItemKind :: MacroDef ( ref  ts)  => visitor. visit_mac_def ( ts,  item. id ) , 
@@ -416,8 +435,11 @@ pub fn walk_ty<'a, V: Visitor<'a>>(visitor: &mut V, typ: &'a Ty) {
416435            visitor. visit_ty ( ty) ; 
417436            visitor. visit_anon_const ( length) 
418437        } 
419-         TyKind :: TraitObject ( ref  bounds,  ..)  | TyKind :: ImplTrait ( _,  ref  bounds)  => { 
420-             walk_list ! ( visitor,  visit_param_bound,  bounds) ; 
438+         TyKind :: TraitObject ( ref  bounds,  ..)  => { 
439+             walk_list ! ( visitor,  visit_param_bound,  bounds,  BoundKind :: TraitObject ) ; 
440+         } 
441+         TyKind :: ImplTrait ( _,  ref  bounds)  => { 
442+             walk_list ! ( visitor,  visit_param_bound,  bounds,  BoundKind :: Impl ) ; 
421443        } 
422444        TyKind :: Typeof ( ref  expression)  => visitor. visit_anon_const ( expression) , 
423445        TyKind :: Infer  | TyKind :: ImplicitSelf  | TyKind :: Err  => { } 
@@ -503,7 +525,7 @@ pub fn walk_assoc_constraint<'a, V: Visitor<'a>>(visitor: &mut V, constraint: &'
503525            Term :: Const ( c)  => visitor. visit_anon_const ( c) , 
504526        } , 
505527        AssocConstraintKind :: Bound  {  ref  bounds }  => { 
506-             walk_list ! ( visitor,  visit_param_bound,  bounds) ; 
528+             walk_list ! ( visitor,  visit_param_bound,  bounds,   BoundKind :: Bound ) ; 
507529        } 
508530    } 
509531} 
@@ -566,7 +588,7 @@ pub fn walk_foreign_item<'a, V: Visitor<'a>>(visitor: &mut V, item: &'a ForeignI
566588        } 
567589        ForeignItemKind :: TyAlias ( box TyAlias  {  generics,  bounds,  ty,  .. } )  => { 
568590            visitor. visit_generics ( generics) ; 
569-             walk_list ! ( visitor,  visit_param_bound,  bounds) ; 
591+             walk_list ! ( visitor,  visit_param_bound,  bounds,   BoundKind :: Bound ) ; 
570592            walk_list ! ( visitor,  visit_ty,  ty) ; 
571593        } 
572594        ForeignItemKind :: MacCall ( mac)  => { 
@@ -585,7 +607,7 @@ pub fn walk_param_bound<'a, V: Visitor<'a>>(visitor: &mut V, bound: &'a GenericB
585607pub  fn  walk_generic_param < ' a ,  V :  Visitor < ' a > > ( visitor :  & mut  V ,  param :  & ' a  GenericParam )  { 
586608    visitor. visit_ident ( param. ident ) ; 
587609    walk_list ! ( visitor,  visit_attribute,  param. attrs. iter( ) ) ; 
588-     walk_list ! ( visitor,  visit_param_bound,  & param. bounds) ; 
610+     walk_list ! ( visitor,  visit_param_bound,  & param. bounds,   BoundKind :: Bound ) ; 
589611    match  param. kind  { 
590612        GenericParamKind :: Lifetime  => ( ) , 
591613        GenericParamKind :: Type  {  ref  default }  => walk_list ! ( visitor,  visit_ty,  default ) , 
@@ -612,14 +634,14 @@ pub fn walk_where_predicate<'a, V: Visitor<'a>>(visitor: &mut V, predicate: &'a
612634            ..
613635        } )  => { 
614636            visitor. visit_ty ( bounded_ty) ; 
615-             walk_list ! ( visitor,  visit_param_bound,  bounds) ; 
637+             walk_list ! ( visitor,  visit_param_bound,  bounds,   BoundKind :: Bound ) ; 
616638            walk_list ! ( visitor,  visit_generic_param,  bound_generic_params) ; 
617639        } 
618640        WherePredicate :: RegionPredicate ( WhereRegionPredicate  { 
619641            ref  lifetime,  ref  bounds,  ..
620642        } )  => { 
621643            visitor. visit_lifetime ( lifetime) ; 
622-             walk_list ! ( visitor,  visit_param_bound,  bounds) ; 
644+             walk_list ! ( visitor,  visit_param_bound,  bounds,   BoundKind :: Bound ) ; 
623645        } 
624646        WherePredicate :: EqPredicate ( WhereEqPredicate  {  ref  lhs_ty,  ref  rhs_ty,  .. } )  => { 
625647            visitor. visit_ty ( lhs_ty) ; 
@@ -672,7 +694,7 @@ pub fn walk_assoc_item<'a, V: Visitor<'a>>(visitor: &mut V, item: &'a AssocItem,
672694        } 
673695        AssocItemKind :: TyAlias ( box TyAlias  {  generics,  bounds,  ty,  .. } )  => { 
674696            visitor. visit_generics ( generics) ; 
675-             walk_list ! ( visitor,  visit_param_bound,  bounds) ; 
697+             walk_list ! ( visitor,  visit_param_bound,  bounds,   BoundKind :: Bound ) ; 
676698            walk_list ! ( visitor,  visit_ty,  ty) ; 
677699        } 
678700        AssocItemKind :: MacCall ( mac)  => { 
0 commit comments