@@ -113,10 +113,11 @@ pub enum LifetimeCtxt {
113113}
114114
115115pub trait WalkItemKind : Sized {
116+ type Ctxt ;
116117fn walk < ' a , V : Visitor < ' a > > (
117118& ' a self ,
118119item : & ' a Item < Self > ,
119- ctxt : AssocCtxt ,
120+ ctxt : Self :: Ctxt ,
120121visitor : & mut V ,
121122) -> V :: Result ;
122123}
@@ -337,10 +338,11 @@ pub fn walk_trait_ref<'a, V: Visitor<'a>>(visitor: &mut V, trait_ref: &'a TraitR
337338}
338339
339340impl WalkItemKind for ItemKind {
341+ type Ctxt = ( ) ;
340342fn walk < ' a , V : Visitor < ' a > > (
341343& ' a self ,
342344item : & ' a Item < Self > ,
343- _ctxt : AssocCtxt ,
345+ _ctxt : Self :: Ctxt ,
344346visitor : & mut V ,
345347) -> V :: Result {
346348let Item { id, span, vis, ident, .. } = item;
@@ -449,9 +451,9 @@ impl WalkItemKind for ItemKind {
449451
450452pub fn walk_item < ' a , V : Visitor < ' a > > (
451453visitor : & mut V ,
452- item : & ' a Item < impl WalkItemKind > ,
454+ item : & ' a Item < impl WalkItemKind < Ctxt = ( ) > > ,
453455) -> V :: Result {
454- walk_assoc_item ( visitor, item, AssocCtxt :: Trait /*ignored*/ )
456+ walk_assoc_item ( visitor, item, ( ) )
455457}
456458
457459pub fn walk_enum_def < ' a , V : Visitor < ' a > > (
@@ -681,10 +683,11 @@ pub fn walk_pat<'a, V: Visitor<'a>>(visitor: &mut V, pattern: &'a Pat) -> V::Res
681683}
682684
683685impl WalkItemKind for ForeignItemKind {
686+ type Ctxt = ( ) ;
684687fn walk < ' a , V : Visitor < ' a > > (
685688& ' a self ,
686689item : & ' a Item < Self > ,
687- _ctxt : AssocCtxt ,
690+ _ctxt : Self :: Ctxt ,
688691visitor : & mut V ,
689692) -> V :: Result {
690693let Item { id, span, ident, vis, .. } = item;
@@ -844,10 +847,11 @@ pub fn walk_fn<'a, V: Visitor<'a>>(visitor: &mut V, kind: FnKind<'a>) -> V::Resu
844847}
845848
846849impl WalkItemKind for AssocItemKind {
850+ type Ctxt = AssocCtxt ;
847851fn walk < ' a , V : Visitor < ' a > > (
848852& ' a self ,
849853item : & ' a Item < Self > ,
850- ctxt : AssocCtxt ,
854+ ctxt : Self :: Ctxt ,
851855visitor : & mut V ,
852856) -> V :: Result {
853857let Item { id, span, ident, vis, .. } = item;
@@ -906,10 +910,10 @@ impl WalkItemKind for AssocItemKind {
906910}
907911}
908912
909- pub fn walk_assoc_item < ' a , V : Visitor < ' a > > (
913+ pub fn walk_assoc_item < ' a , V : Visitor < ' a > , K : WalkItemKind > (
910914visitor : & mut V ,
911- item : & ' a Item < impl WalkItemKind > ,
912- ctxt : AssocCtxt ,
915+ item : & ' a Item < K > ,
916+ ctxt : K :: Ctxt ,
913917) -> V :: Result {
914918let Item { id : _, span : _, ident, vis, attrs, kind, tokens : _ } = item;
915919walk_list ! ( visitor, visit_attribute, attrs) ;
0 commit comments