1
1
use marker_api:: ast:: {
2
- generic:: {
3
- GenericParamKind , GenericParams , LifetimeClause , LifetimeParam , TraitBound , TyClause , TyParam , TyParamBound ,
4
- WhereClauseKind ,
5
- } ,
2
+ generic:: { GenericParamKind , GenericParams , LifetimeClause , LifetimeParam , TyClause , TyParam , WhereClauseKind } ,
6
3
item:: {
7
4
AdtKind , AssocItemKind , CommonItemData , ConstItem , EnumItem , EnumVariant , ExternBlockItem , ExternCrateItem ,
8
5
ExternItemKind , Field , FnItem , ImplItem , ItemKind , ModItem , StaticItem , StructItem , TraitItem , TyAliasItem ,
@@ -16,7 +13,7 @@ use rustc_hir as hir;
16
13
use crate :: context:: RustcContext ;
17
14
18
15
use super :: {
19
- generic:: { to_api_lifetime, to_api_trait_ref} ,
16
+ generic:: { conv_ast_bound , to_api_lifetime, to_api_trait_ref} ,
20
17
to_api_abi, to_api_body_id, to_api_path, to_generic_id, to_item_id, to_rustc_item_id, to_span_id, to_symbol_id,
21
18
ty:: TyConverter ,
22
19
} ;
@@ -115,7 +112,7 @@ impl<'ast, 'tcx> ItemConverter<'ast, 'tcx> {
115
112
data,
116
113
matches ! ( unsafety, hir:: Unsafety :: Unsafe ) ,
117
114
self . conv_generic ( generics) ,
118
- self . conv_generic_bounds ( bounds) ,
115
+ conv_ast_bound ( self . cx , bounds) ,
119
116
self . conv_trait_items ( items) ,
120
117
)
121
118
} ) ) ,
@@ -219,7 +216,7 @@ impl<'ast, 'tcx> ItemConverter<'ast, 'tcx> {
219
216
TyAliasItem :: new (
220
217
data,
221
218
self . conv_generic ( trait_item. generics ) ,
222
- self . conv_generic_bounds ( bounds) ,
219
+ conv_ast_bound ( self . cx , bounds) ,
223
220
ty. map ( |ty| self . conv_ty ( ty) ) ,
224
221
)
225
222
} ) ) ,
@@ -310,31 +307,6 @@ impl<'ast, 'tcx> ItemConverter<'ast, 'tcx> {
310
307
self . cx . storage . alloc_slice_iter ( params. into_iter ( ) )
311
308
}
312
309
313
- fn conv_generic_bounds ( & self , bounds : hir:: GenericBounds < ' tcx > ) -> & ' ast [ TyParamBound < ' ast > ] {
314
- if bounds. is_empty ( ) {
315
- return & [ ] ;
316
- }
317
-
318
- let bounds: Vec < _ > = bounds
319
- . iter ( )
320
- . filter_map ( |bound| match bound {
321
- hir:: GenericBound :: Trait ( trait_ref, modifier) => Some ( TyParamBound :: TraitBound ( self . alloc ( || {
322
- TraitBound :: new (
323
- !matches ! ( modifier, hir:: TraitBoundModifier :: None ) ,
324
- to_api_trait_ref ( self . cx , & trait_ref. trait_ref ) ,
325
- to_span_id ( bound. span ( ) ) ,
326
- )
327
- } ) ) ) ,
328
- hir:: GenericBound :: LangItemTrait ( _, _, _, _) => todo ! ( ) ,
329
- hir:: GenericBound :: Outlives ( rust_lt) => {
330
- to_api_lifetime ( self . cx , rust_lt) . map ( |api_lt| TyParamBound :: Lifetime ( self . alloc ( || api_lt) ) )
331
- } ,
332
- } )
333
- . collect ( ) ;
334
-
335
- self . cx . storage . alloc_slice_iter ( bounds. into_iter ( ) )
336
- }
337
-
338
310
fn conv_generic ( & self , rustc_generics : & hir:: Generics < ' tcx > ) -> GenericParams < ' ast > {
339
311
// FIXME: Update implementation to store the parameter bounds in the parameters
340
312
let clauses: Vec < _ > = rustc_generics
@@ -348,7 +320,7 @@ impl<'ast, 'tcx> ItemConverter<'ast, 'tcx> {
348
320
let params = GenericParams :: new ( self . conv_generic_params ( ty_bound. bound_generic_params ) , & [ ] ) ;
349
321
let ty = self . conv_ty ( ty_bound. bounded_ty ) ;
350
322
Some ( WhereClauseKind :: Ty ( self . alloc ( || {
351
- TyClause :: new ( Some ( params) , ty, self . conv_generic_bounds ( predicate. bounds ( ) ) )
323
+ TyClause :: new ( Some ( params) , ty, conv_ast_bound ( self . cx , predicate. bounds ( ) ) )
352
324
} ) ) )
353
325
} ,
354
326
hir:: WherePredicate :: RegionPredicate ( lifetime_bound) => {
0 commit comments