@@ -2785,6 +2785,45 @@ impl<'a> LoweringContext<'a> {
2785
2785
}
2786
2786
}
2787
2787
2788
+ /// Lowers `impl Trait` items and appends them to the list
2789
+ fn lower_impl_trait_ids (
2790
+ & mut self ,
2791
+ decl : & FnDecl ,
2792
+ ids : & mut SmallVector < hir:: ItemId > ,
2793
+ ) {
2794
+ struct IdVisitor < ' a > { ids : & ' a mut SmallVector < hir:: ItemId > }
2795
+ impl < ' a , ' b > Visitor < ' a > for IdVisitor < ' b > {
2796
+ fn visit_ty ( & mut self , ty : & ' a Ty ) {
2797
+ match ty. node {
2798
+ | TyKind :: Typeof ( _)
2799
+ | TyKind :: BareFn ( _)
2800
+ => return ,
2801
+
2802
+ TyKind :: ImplTrait ( id, _) => self . ids . push ( hir:: ItemId { id } ) ,
2803
+ _ => { } ,
2804
+ }
2805
+ visit:: walk_ty ( self , ty) ;
2806
+ }
2807
+ fn visit_path_segment (
2808
+ & mut self ,
2809
+ path_span : Span ,
2810
+ path_segment : & ' v PathSegment ,
2811
+ ) {
2812
+ if let Some ( ref p) = path_segment. parameters {
2813
+ if let PathParameters :: Parenthesized ( ..) = * * p {
2814
+ return ;
2815
+ }
2816
+ }
2817
+ visit:: walk_path_segment ( self , path_span, path_segment)
2818
+ }
2819
+ }
2820
+ let mut visitor = IdVisitor { ids } ;
2821
+ match decl. output {
2822
+ FunctionRetTy :: Default ( _) => { } ,
2823
+ FunctionRetTy :: Ty ( ref ty) => visitor. visit_ty ( ty) ,
2824
+ }
2825
+ }
2826
+
2788
2827
fn lower_item_id ( & mut self , i : & Item ) -> SmallVector < hir:: ItemId > {
2789
2828
match i. node {
2790
2829
ItemKind :: Use ( ref use_tree) => {
@@ -2794,38 +2833,18 @@ impl<'a> LoweringContext<'a> {
2794
2833
}
2795
2834
ItemKind :: MacroDef ( ..) => SmallVector :: new ( ) ,
2796
2835
ItemKind :: Fn ( ref decl, ..) => {
2797
- struct IdVisitor { ids : SmallVector < hir:: ItemId > }
2798
- impl < ' a > Visitor < ' a > for IdVisitor {
2799
- fn visit_ty ( & mut self , ty : & ' a Ty ) {
2800
- match ty. node {
2801
- | TyKind :: Typeof ( _)
2802
- | TyKind :: BareFn ( _)
2803
- => return ,
2804
-
2805
- TyKind :: ImplTrait ( id, _) => self . ids . push ( hir:: ItemId { id } ) ,
2806
- _ => { } ,
2807
- }
2808
- visit:: walk_ty ( self , ty) ;
2809
- }
2810
- fn visit_path_segment (
2811
- & mut self ,
2812
- path_span : Span ,
2813
- path_segment : & ' v PathSegment ,
2814
- ) {
2815
- if let Some ( ref p) = path_segment. parameters {
2816
- if let PathParameters :: Parenthesized ( ..) = * * p {
2817
- return ;
2818
- }
2819
- }
2820
- visit:: walk_path_segment ( self , path_span, path_segment)
2836
+ let mut ids = SmallVector :: one ( hir:: ItemId { id : i. id } ) ;
2837
+ self . lower_impl_trait_ids ( decl, & mut ids) ;
2838
+ ids
2839
+ } ,
2840
+ ItemKind :: Impl ( .., ref items) => {
2841
+ let mut ids = SmallVector :: one ( hir:: ItemId { id : i. id } ) ;
2842
+ for item in items {
2843
+ if let ImplItemKind :: Method ( ref sig, _) = item. node {
2844
+ self . lower_impl_trait_ids ( & sig. decl , & mut ids) ;
2821
2845
}
2822
2846
}
2823
- let mut visitor = IdVisitor { ids : SmallVector :: one ( hir:: ItemId { id : i. id } ) } ;
2824
- match decl. output {
2825
- FunctionRetTy :: Default ( _) => { } ,
2826
- FunctionRetTy :: Ty ( ref ty) => visitor. visit_ty ( ty) ,
2827
- }
2828
- visitor. ids
2847
+ ids
2829
2848
} ,
2830
2849
_ => SmallVector :: one ( hir:: ItemId { id : i. id } ) ,
2831
2850
}
0 commit comments