@@ -238,7 +238,7 @@ fn from_clean_item(item: clean::Item, tcx: TyCtxt<'_>) -> ItemEnum {
238238
239239 match * item. kind {
240240 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 } )
242242 }
243243 ImportItem ( i) => ItemEnum :: Import ( i. into_tcx ( tcx) ) ,
244244 StructItem ( s) => ItemEnum :: Struct ( s. into_tcx ( tcx) ) ,
@@ -282,7 +282,7 @@ fn from_clean_item(item: clean::Item, tcx: TyCtxt<'_>) -> ItemEnum {
282282 match * inner {
283283 ModuleItem ( m) => ItemEnum :: Module ( Module {
284284 is_crate,
285- items : ids ( m. items , tcx) ,
285+ items : ids ( & m. items , tcx) ,
286286 is_stripped : true ,
287287 } ) ,
288288 // `convert_item` early returns `None` for stripped items we're not including
@@ -301,10 +301,10 @@ impl FromWithTcx<clean::Struct> for Struct {
301301 let fields_stripped = struct_. has_stripped_entries ( ) ;
302302 let clean:: Struct { struct_type, generics, fields } = struct_;
303303 Struct {
304- struct_type : from_ctor_kind ( struct_type) ,
304+ kind : from_ctor_kind ( struct_type) ,
305305 generics : generics. into_tcx ( tcx) ,
306306 fields_stripped,
307- fields : ids ( fields, tcx) ,
307+ fields : ids ( & fields, tcx) ,
308308 impls : Vec :: new ( ) , // Added in JsonRenderer::item
309309 }
310310 }
@@ -317,17 +317,17 @@ impl FromWithTcx<clean::Union> for Union {
317317 Union {
318318 generics : generics. into_tcx ( tcx) ,
319319 fields_stripped,
320- fields : ids ( fields, tcx) ,
320+ fields : ids ( & fields, tcx) ,
321321 impls : Vec :: new ( ) , // Added in JsonRenderer::item
322322 }
323323 }
324324}
325325
326- pub ( crate ) fn from_ctor_kind ( struct_type : CtorKind ) -> StructType {
326+ pub ( crate ) fn from_ctor_kind ( struct_type : CtorKind ) -> StructKind {
327327 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 ,
331331 }
332332}
333333
@@ -551,7 +551,7 @@ impl FromWithTcx<clean::Trait> for Trait {
551551 Trait {
552552 is_auto,
553553 is_unsafe,
554- items : ids ( items, tcx) ,
554+ items : ids ( & items, tcx) ,
555555 generics : generics. into_tcx ( tcx) ,
556556 bounds : bounds. into_tcx ( tcx) ,
557557 implementations : Vec :: new ( ) , // Added in JsonRenderer::item
@@ -591,7 +591,7 @@ impl FromWithTcx<clean::Impl> for Impl {
591591 . collect ( ) ,
592592 trait_ : trait_. map ( |path| path. into_tcx ( tcx) ) ,
593593 for_ : for_. into_tcx ( tcx) ,
594- items : ids ( items, tcx) ,
594+ items : ids ( & items, tcx) ,
595595 negative : negative_polarity,
596596 synthetic,
597597 blanket_impl : blanket_impl. map ( |x| x. into_tcx ( tcx) ) ,
@@ -634,42 +634,28 @@ impl FromWithTcx<clean::Enum> for Enum {
634634 Enum {
635635 generics : generics. into_tcx ( tcx) ,
636636 variants_stripped,
637- variants : ids ( variants, tcx) ,
637+ variants : ids ( & variants, tcx) ,
638638 impls : Vec :: new ( ) , // Added in JsonRenderer::item
639639 }
640640 }
641641}
642642
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-
657643impl FromWithTcx < clean:: Variant > for Variant {
658644 fn from_tcx ( variant : clean:: Variant , tcx : TyCtxt < ' _ > ) -> Self {
659645 use clean:: Variant :: * ;
646+
660647 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+ } ,
673659 }
674660 }
675661}
@@ -773,7 +759,7 @@ impl FromWithTcx<ItemType> for ItemKind {
773759 }
774760}
775761
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 > {
777763 items
778764 . into_iter ( )
779765 . filter ( |x| !x. is_stripped ( ) && !x. is_keyword ( ) )
0 commit comments