@@ -32,6 +32,13 @@ pub enum FnCtxt {
3232 Assoc ( AssocCtxt ) ,
3333}
3434
35+ #[ derive( Copy , Clone , Debug ) ]
36+ pub enum BoundCtxt {
37+ Normal ,
38+ TraitObject ,
39+ SuperTraits ,
40+ }
41+
3542#[ derive( Copy , Clone , Debug ) ]
3643pub enum FnKind < ' a > {
3744 /// E.g., `fn foo()`, `fn foo(&self)`, or `extern "Abi" fn foo()`.
@@ -139,7 +146,7 @@ pub trait Visitor<'ast>: Sized {
139146 fn visit_trait_ref ( & mut self , t : & ' ast TraitRef ) {
140147 walk_trait_ref ( self , t)
141148 }
142- fn visit_param_bound ( & mut self , bounds : & ' ast GenericBound ) {
149+ fn visit_param_bound ( & mut self , bounds : & ' ast GenericBound , _ctxt : BoundCtxt ) {
143150 walk_param_bound ( self , bounds)
144151 }
145152 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) {
311318 ItemKind :: GlobalAsm ( ref asm) => walk_inline_asm ( visitor, asm) ,
312319 ItemKind :: TyAlias ( box TyAlias { ref generics, ref bounds, ref ty, .. } ) => {
313320 visitor. visit_generics ( generics) ;
314- walk_list ! ( visitor, visit_param_bound, bounds) ;
321+ walk_list ! ( visitor, visit_param_bound, bounds, BoundCtxt :: Normal ) ;
315322 walk_list ! ( visitor, visit_ty, ty) ;
316323 }
317324 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) {
346353 ref items,
347354 } ) => {
348355 visitor. visit_generics ( generics) ;
349- walk_list ! ( visitor, visit_param_bound, bounds) ;
356+ walk_list ! ( visitor, visit_param_bound, bounds, BoundCtxt :: SuperTraits ) ;
350357 walk_list ! ( visitor, visit_assoc_item, items, AssocCtxt :: Trait ) ;
351358 }
352359 ItemKind :: TraitAlias ( ref generics, ref bounds) => {
353360 visitor. visit_generics ( generics) ;
354- walk_list ! ( visitor, visit_param_bound, bounds) ;
361+ walk_list ! ( visitor, visit_param_bound, bounds, BoundCtxt :: Normal ) ;
355362 }
356363 ItemKind :: MacCall ( ref mac) => visitor. visit_mac_call ( mac) ,
357364 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) {
416423 visitor. visit_ty ( ty) ;
417424 visitor. visit_anon_const ( length)
418425 }
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 ) ;
421431 }
422432 TyKind :: Typeof ( ref expression) => visitor. visit_anon_const ( expression) ,
423433 TyKind :: Infer | TyKind :: ImplicitSelf | TyKind :: Err => { }
@@ -503,7 +513,7 @@ pub fn walk_assoc_constraint<'a, V: Visitor<'a>>(visitor: &mut V, constraint: &'
503513 Term :: Const ( c) => visitor. visit_anon_const ( c) ,
504514 } ,
505515 AssocConstraintKind :: Bound { ref bounds } => {
506- walk_list ! ( visitor, visit_param_bound, bounds) ;
516+ walk_list ! ( visitor, visit_param_bound, bounds, BoundCtxt :: Normal ) ;
507517 }
508518 }
509519}
@@ -566,7 +576,7 @@ pub fn walk_foreign_item<'a, V: Visitor<'a>>(visitor: &mut V, item: &'a ForeignI
566576 }
567577 ForeignItemKind :: TyAlias ( box TyAlias { generics, bounds, ty, .. } ) => {
568578 visitor. visit_generics ( generics) ;
569- walk_list ! ( visitor, visit_param_bound, bounds) ;
579+ walk_list ! ( visitor, visit_param_bound, bounds, BoundCtxt :: Normal ) ;
570580 walk_list ! ( visitor, visit_ty, ty) ;
571581 }
572582 ForeignItemKind :: MacCall ( mac) => {
@@ -585,7 +595,7 @@ pub fn walk_param_bound<'a, V: Visitor<'a>>(visitor: &mut V, bound: &'a GenericB
585595pub fn walk_generic_param < ' a , V : Visitor < ' a > > ( visitor : & mut V , param : & ' a GenericParam ) {
586596 visitor. visit_ident ( param. ident ) ;
587597 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 ) ;
589599 match param. kind {
590600 GenericParamKind :: Lifetime => ( ) ,
591601 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
612622 ..
613623 } ) => {
614624 visitor. visit_ty ( bounded_ty) ;
615- walk_list ! ( visitor, visit_param_bound, bounds) ;
625+ walk_list ! ( visitor, visit_param_bound, bounds, BoundCtxt :: Normal ) ;
616626 walk_list ! ( visitor, visit_generic_param, bound_generic_params) ;
617627 }
618628 WherePredicate :: RegionPredicate ( WhereRegionPredicate {
619629 ref lifetime, ref bounds, ..
620630 } ) => {
621631 visitor. visit_lifetime ( lifetime) ;
622- walk_list ! ( visitor, visit_param_bound, bounds) ;
632+ walk_list ! ( visitor, visit_param_bound, bounds, BoundCtxt :: Normal ) ;
623633 }
624634 WherePredicate :: EqPredicate ( WhereEqPredicate { ref lhs_ty, ref rhs_ty, .. } ) => {
625635 visitor. visit_ty ( lhs_ty) ;
@@ -672,7 +682,7 @@ pub fn walk_assoc_item<'a, V: Visitor<'a>>(visitor: &mut V, item: &'a AssocItem,
672682 }
673683 AssocItemKind :: TyAlias ( box TyAlias { generics, bounds, ty, .. } ) => {
674684 visitor. visit_generics ( generics) ;
675- walk_list ! ( visitor, visit_param_bound, bounds) ;
685+ walk_list ! ( visitor, visit_param_bound, bounds, BoundCtxt :: Normal ) ;
676686 walk_list ! ( visitor, visit_ty, ty) ;
677687 }
678688 AssocItemKind :: MacCall ( mac) => {
0 commit comments