@@ -113,10 +113,11 @@ pub enum LifetimeCtxt {
113
113
}
114
114
115
115
pub trait WalkItemKind : Sized {
116
+ type Ctxt ;
116
117
fn walk < ' a , V : Visitor < ' a > > (
117
118
& ' a self ,
118
119
item : & ' a Item < Self > ,
119
- ctxt : AssocCtxt ,
120
+ ctxt : Self :: Ctxt ,
120
121
visitor : & mut V ,
121
122
) -> V :: Result ;
122
123
}
@@ -337,10 +338,11 @@ pub fn walk_trait_ref<'a, V: Visitor<'a>>(visitor: &mut V, trait_ref: &'a TraitR
337
338
}
338
339
339
340
impl WalkItemKind for ItemKind {
341
+ type Ctxt = ( ) ;
340
342
fn walk < ' a , V : Visitor < ' a > > (
341
343
& ' a self ,
342
344
item : & ' a Item < Self > ,
343
- _ctxt : AssocCtxt ,
345
+ _ctxt : Self :: Ctxt ,
344
346
visitor : & mut V ,
345
347
) -> V :: Result {
346
348
let Item { id, span, vis, ident, .. } = item;
@@ -449,9 +451,9 @@ impl WalkItemKind for ItemKind {
449
451
450
452
pub fn walk_item < ' a , V : Visitor < ' a > > (
451
453
visitor : & mut V ,
452
- item : & ' a Item < impl WalkItemKind > ,
454
+ item : & ' a Item < impl WalkItemKind < Ctxt = ( ) > > ,
453
455
) -> V :: Result {
454
- walk_assoc_item ( visitor, item, AssocCtxt :: Trait /*ignored*/ )
456
+ walk_assoc_item ( visitor, item, ( ) )
455
457
}
456
458
457
459
pub 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
681
683
}
682
684
683
685
impl WalkItemKind for ForeignItemKind {
686
+ type Ctxt = ( ) ;
684
687
fn walk < ' a , V : Visitor < ' a > > (
685
688
& ' a self ,
686
689
item : & ' a Item < Self > ,
687
- _ctxt : AssocCtxt ,
690
+ _ctxt : Self :: Ctxt ,
688
691
visitor : & mut V ,
689
692
) -> V :: Result {
690
693
let 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
844
847
}
845
848
846
849
impl WalkItemKind for AssocItemKind {
850
+ type Ctxt = AssocCtxt ;
847
851
fn walk < ' a , V : Visitor < ' a > > (
848
852
& ' a self ,
849
853
item : & ' a Item < Self > ,
850
- ctxt : AssocCtxt ,
854
+ ctxt : Self :: Ctxt ,
851
855
visitor : & mut V ,
852
856
) -> V :: Result {
853
857
let Item { id, span, ident, vis, .. } = item;
@@ -906,10 +910,10 @@ impl WalkItemKind for AssocItemKind {
906
910
}
907
911
}
908
912
909
- pub fn walk_assoc_item < ' a , V : Visitor < ' a > > (
913
+ pub fn walk_assoc_item < ' a , V : Visitor < ' a > , K : WalkItemKind > (
910
914
visitor : & mut V ,
911
- item : & ' a Item < impl WalkItemKind > ,
912
- ctxt : AssocCtxt ,
915
+ item : & ' a Item < K > ,
916
+ ctxt : K :: Ctxt ,
913
917
) -> V :: Result {
914
918
let Item { id : _, span : _, ident, vis, attrs, kind, tokens : _ } = item;
915
919
walk_list ! ( visitor, visit_attribute, attrs) ;
0 commit comments