@@ -238,7 +238,7 @@ fn from_clean_item(item: clean::Item, tcx: TyCtxt<'_>) -> ItemEnum {
238
238
239
239
match * item. kind {
240
240
ModuleItem ( m) => {
241
- ItemEnum :: Module ( Module { is_crate, items : ids ( m. items , tcx) , is_stripped : false } )
241
+ ItemEnum :: Module ( Module { is_crate, items : ids ( & m. items , tcx) , is_stripped : false } )
242
242
}
243
243
ImportItem ( i) => ItemEnum :: Import ( i. into_tcx ( tcx) ) ,
244
244
StructItem ( s) => ItemEnum :: Struct ( s. into_tcx ( tcx) ) ,
@@ -282,7 +282,7 @@ fn from_clean_item(item: clean::Item, tcx: TyCtxt<'_>) -> ItemEnum {
282
282
match * inner {
283
283
ModuleItem ( m) => ItemEnum :: Module ( Module {
284
284
is_crate,
285
- items : ids ( m. items , tcx) ,
285
+ items : ids ( & m. items , tcx) ,
286
286
is_stripped : true ,
287
287
} ) ,
288
288
// `convert_item` early returns `None` for stripped items we're not including
@@ -301,10 +301,10 @@ impl FromWithTcx<clean::Struct> for Struct {
301
301
let fields_stripped = struct_. has_stripped_entries ( ) ;
302
302
let clean:: Struct { struct_type, generics, fields } = struct_;
303
303
Struct {
304
- struct_type : from_ctor_kind ( struct_type) ,
304
+ kind : from_ctor_kind ( struct_type) ,
305
305
generics : generics. into_tcx ( tcx) ,
306
306
fields_stripped,
307
- fields : ids ( fields, tcx) ,
307
+ fields : ids ( & fields, tcx) ,
308
308
impls : Vec :: new ( ) , // Added in JsonRenderer::item
309
309
}
310
310
}
@@ -317,17 +317,17 @@ impl FromWithTcx<clean::Union> for Union {
317
317
Union {
318
318
generics : generics. into_tcx ( tcx) ,
319
319
fields_stripped,
320
- fields : ids ( fields, tcx) ,
320
+ fields : ids ( & fields, tcx) ,
321
321
impls : Vec :: new ( ) , // Added in JsonRenderer::item
322
322
}
323
323
}
324
324
}
325
325
326
- pub ( crate ) fn from_ctor_kind ( struct_type : CtorKind ) -> StructType {
326
+ pub ( crate ) fn from_ctor_kind ( struct_type : CtorKind ) -> StructKind {
327
327
match struct_type {
328
- CtorKind :: Fictive => StructType :: Plain ,
329
- CtorKind :: Fn => StructType :: Tuple ,
330
- CtorKind :: Const => StructType :: Unit ,
328
+ CtorKind :: Fictive => StructKind :: Struct ,
329
+ CtorKind :: Fn => StructKind :: Tuple ,
330
+ CtorKind :: Const => StructKind :: Unit ,
331
331
}
332
332
}
333
333
@@ -551,7 +551,7 @@ impl FromWithTcx<clean::Trait> for Trait {
551
551
Trait {
552
552
is_auto,
553
553
is_unsafe,
554
- items : ids ( items, tcx) ,
554
+ items : ids ( & items, tcx) ,
555
555
generics : generics. into_tcx ( tcx) ,
556
556
bounds : bounds. into_tcx ( tcx) ,
557
557
implementations : Vec :: new ( ) , // Added in JsonRenderer::item
@@ -591,7 +591,7 @@ impl FromWithTcx<clean::Impl> for Impl {
591
591
. collect ( ) ,
592
592
trait_ : trait_. map ( |path| path. into_tcx ( tcx) ) ,
593
593
for_ : for_. into_tcx ( tcx) ,
594
- items : ids ( items, tcx) ,
594
+ items : ids ( & items, tcx) ,
595
595
negative : negative_polarity,
596
596
synthetic,
597
597
blanket_impl : blanket_impl. map ( |x| x. into_tcx ( tcx) ) ,
@@ -634,42 +634,28 @@ impl FromWithTcx<clean::Enum> for Enum {
634
634
Enum {
635
635
generics : generics. into_tcx ( tcx) ,
636
636
variants_stripped,
637
- variants : ids ( variants, tcx) ,
637
+ variants : ids ( & variants, tcx) ,
638
638
impls : Vec :: new ( ) , // Added in JsonRenderer::item
639
639
}
640
640
}
641
641
}
642
642
643
- impl FromWithTcx < clean:: VariantStruct > for Struct {
644
- fn from_tcx ( struct_ : clean:: VariantStruct , tcx : TyCtxt < ' _ > ) -> Self {
645
- let fields_stripped = struct_. has_stripped_entries ( ) ;
646
- let clean:: VariantStruct { struct_type, fields } = struct_;
647
- Struct {
648
- struct_type : from_ctor_kind ( struct_type) ,
649
- generics : Generics { params : vec ! [ ] , where_predicates : vec ! [ ] } ,
650
- fields_stripped,
651
- fields : ids ( fields, tcx) ,
652
- impls : Vec :: new ( ) ,
653
- }
654
- }
655
- }
656
-
657
643
impl FromWithTcx < clean:: Variant > for Variant {
658
644
fn from_tcx ( variant : clean:: Variant , tcx : TyCtxt < ' _ > ) -> Self {
659
645
use clean:: Variant :: * ;
646
+
660
647
match variant {
661
- CLike => Variant :: Plain ,
662
- Tuple ( fields) => Variant :: Tuple (
663
- fields
664
- . into_iter ( )
665
- . filter_map ( |f| match * f. kind {
666
- clean:: StructFieldItem ( ty) => Some ( ty. into_tcx ( tcx) ) ,
667
- clean:: StrippedItem ( _) => None ,
668
- _ => unreachable ! ( ) ,
669
- } )
670
- . collect ( ) ,
671
- ) ,
672
- Struct ( s) => Variant :: Struct ( ids ( s. fields , tcx) ) ,
648
+ CLike => Variant { kind : StructKind :: Unit , fields : Vec :: new ( ) , fields_stripped : false } ,
649
+ Tuple ( fields) => Variant {
650
+ kind : StructKind :: Tuple ,
651
+ fields : ids ( & fields, tcx) ,
652
+ fields_stripped : fields. iter ( ) . any ( |i| i. is_stripped ( ) ) ,
653
+ } ,
654
+ Struct ( s) => Variant {
655
+ kind : StructKind :: Struct ,
656
+ fields : ids ( & s. fields , tcx) ,
657
+ fields_stripped : s. has_stripped_entries ( ) ,
658
+ } ,
673
659
}
674
660
}
675
661
}
@@ -773,7 +759,7 @@ impl FromWithTcx<ItemType> for ItemKind {
773
759
}
774
760
}
775
761
776
- fn ids ( items : impl IntoIterator < Item = clean:: Item > , tcx : TyCtxt < ' _ > ) -> Vec < Id > {
762
+ fn ids < ' a > ( items : impl IntoIterator < Item = & ' a clean:: Item > , tcx : TyCtxt < ' _ > ) -> Vec < Id > {
777
763
items
778
764
. into_iter ( )
779
765
. filter ( |x| !x. is_stripped ( ) && !x. is_keyword ( ) )
0 commit comments