@@ -3076,6 +3076,45 @@ impl<'a> LoweringContext<'a> {
3076
3076
}
3077
3077
}
3078
3078
3079
+ /// Lowers `impl Trait` items and appends them to the list
3080
+ fn lower_impl_trait_ids (
3081
+ & mut self ,
3082
+ decl : & FnDecl ,
3083
+ ids : & mut SmallVector < hir:: ItemId > ,
3084
+ ) {
3085
+ struct IdVisitor < ' a > { ids : & ' a mut SmallVector < hir:: ItemId > }
3086
+ impl < ' a , ' b > Visitor < ' a > for IdVisitor < ' b > {
3087
+ fn visit_ty ( & mut self , ty : & ' a Ty ) {
3088
+ match ty. node {
3089
+ | TyKind :: Typeof ( _)
3090
+ | TyKind :: BareFn ( _)
3091
+ => return ,
3092
+
3093
+ TyKind :: ImplTrait ( id, _) => self . ids . push ( hir:: ItemId { id } ) ,
3094
+ _ => { } ,
3095
+ }
3096
+ visit:: walk_ty ( self , ty) ;
3097
+ }
3098
+ fn visit_path_segment (
3099
+ & mut self ,
3100
+ path_span : Span ,
3101
+ path_segment : & ' v PathSegment ,
3102
+ ) {
3103
+ if let Some ( ref p) = path_segment. parameters {
3104
+ if let PathParameters :: Parenthesized ( ..) = * * p {
3105
+ return ;
3106
+ }
3107
+ }
3108
+ visit:: walk_path_segment ( self , path_span, path_segment)
3109
+ }
3110
+ }
3111
+ let mut visitor = IdVisitor { ids } ;
3112
+ match decl. output {
3113
+ FunctionRetTy :: Default ( _) => { } ,
3114
+ FunctionRetTy :: Ty ( ref ty) => visitor. visit_ty ( ty) ,
3115
+ }
3116
+ }
3117
+
3079
3118
fn lower_item_id ( & mut self , i : & Item ) -> SmallVector < hir:: ItemId > {
3080
3119
match i. node {
3081
3120
ItemKind :: Use ( ref use_tree) => {
@@ -3085,21 +3124,18 @@ impl<'a> LoweringContext<'a> {
3085
3124
}
3086
3125
ItemKind :: MacroDef ( ..) => SmallVector :: new ( ) ,
3087
3126
ItemKind :: Fn ( ref decl, ..) => {
3088
- struct IdVisitor { ids : SmallVector < hir:: ItemId > }
3089
- impl < ' a > Visitor < ' a > for IdVisitor {
3090
- fn visit_ty ( & mut self , ty : & ' a Ty ) {
3091
- if let TyKind :: ImplTrait ( id, _) = ty. node {
3092
- self . ids . push ( hir:: ItemId { id } ) ;
3093
- }
3094
- visit:: walk_ty ( self , ty) ;
3127
+ let mut ids = SmallVector :: one ( hir:: ItemId { id : i. id } ) ;
3128
+ self . lower_impl_trait_ids ( decl, & mut ids) ;
3129
+ ids
3130
+ } ,
3131
+ ItemKind :: Impl ( .., ref items) => {
3132
+ let mut ids = SmallVector :: one ( hir:: ItemId { id : i. id } ) ;
3133
+ for item in items {
3134
+ if let ImplItemKind :: Method ( ref sig, _) = item. node {
3135
+ self . lower_impl_trait_ids ( & sig. decl , & mut ids) ;
3095
3136
}
3096
3137
}
3097
- let mut visitor = IdVisitor { ids : SmallVector :: one ( hir:: ItemId { id : i. id } ) } ;
3098
- match decl. output {
3099
- FunctionRetTy :: Default ( _) => { } ,
3100
- FunctionRetTy :: Ty ( ref ty) => visitor. visit_ty ( ty) ,
3101
- }
3102
- visitor. ids
3138
+ ids
3103
3139
} ,
3104
3140
_ => SmallVector :: one ( hir:: ItemId { id : i. id } ) ,
3105
3141
}
0 commit comments