@@ -10,7 +10,6 @@ use rustc_ast::ast;
1010use rustc_hir:: def:: CtorKind ;
1111use rustc_middle:: ty:: TyCtxt ;
1212use rustc_span:: def_id:: { DefId , CRATE_DEF_INDEX } ;
13- use rustc_span:: symbol:: Symbol ;
1413use rustc_span:: Pos ;
1514
1615use rustdoc_json_types:: * ;
@@ -34,23 +33,26 @@ impl JsonRenderer<'_> {
3433 did. map ( |did| ( link. clone ( ) , from_def_id ( did) ) )
3534 } )
3635 . collect ( ) ;
37- let clean:: Item { span, name, attrs, kind, visibility, def_id } = item;
38- let inner = match * kind {
36+ let docs = item. attrs . collapsed_doc_value ( ) ;
37+ let attrs = item
38+ . attrs
39+ . other_attrs
40+ . iter ( )
41+ . map ( rustc_ast_pretty:: pprust:: attribute_to_string)
42+ . collect ( ) ;
43+ let clean:: Item { span, name, attrs : _, kind : _, visibility, def_id } = item;
44+ let inner = match * item. kind {
3945 clean:: StrippedItem ( _) => return None ,
40- kind => from_clean_item_kind ( kind , self . tcx , & name ) ,
46+ _ => from_clean_item ( item , self . tcx ) ,
4147 } ;
4248 Some ( Item {
4349 id : from_def_id ( def_id) ,
4450 crate_id : def_id. krate . as_u32 ( ) ,
4551 name : name. map ( |sym| sym. to_string ( ) ) ,
4652 span : self . convert_span ( span) ,
4753 visibility : self . convert_visibility ( visibility) ,
48- docs : attrs. collapsed_doc_value ( ) ,
49- attrs : attrs
50- . other_attrs
51- . iter ( )
52- . map ( rustc_ast_pretty:: pprust:: attribute_to_string)
53- . collect ( ) ,
54+ docs,
55+ attrs,
5456 deprecation : deprecation. map ( from_deprecation) ,
5557 inner,
5658 links,
@@ -172,10 +174,12 @@ crate fn from_def_id(did: DefId) -> Id {
172174 Id ( format ! ( "{}:{}" , did. krate. as_u32( ) , u32 :: from( did. index) ) )
173175}
174176
175- fn from_clean_item_kind ( item : clean:: ItemKind , tcx : TyCtxt < ' _ > , name : & Option < Symbol > ) -> ItemEnum {
177+ fn from_clean_item ( item : clean:: Item , tcx : TyCtxt < ' _ > ) -> ItemEnum {
176178 use clean:: ItemKind :: * ;
177- match item {
178- ModuleItem ( m) => ItemEnum :: Module ( m. into_tcx ( tcx) ) ,
179+ let name = item. name ;
180+ let is_crate = item. is_crate ( ) ;
181+ match * item. kind {
182+ ModuleItem ( m) => ItemEnum :: Module ( Module { is_crate, items : ids ( m. items ) } ) ,
179183 ImportItem ( i) => ItemEnum :: Import ( i. into_tcx ( tcx) ) ,
180184 StructItem ( s) => ItemEnum :: Struct ( s. into_tcx ( tcx) ) ,
181185 UnionItem ( u) => ItemEnum :: Union ( u. into_tcx ( tcx) ) ,
@@ -214,12 +218,6 @@ fn from_clean_item_kind(item: clean::ItemKind, tcx: TyCtxt<'_>, name: &Option<Sy
214218 }
215219}
216220
217- impl FromWithTcx < clean:: Module > for Module {
218- fn from_tcx ( module : clean:: Module , _tcx : TyCtxt < ' _ > ) -> Self {
219- Module { is_crate : module. is_crate , items : ids ( module. items ) }
220- }
221- }
222-
223221impl FromWithTcx < clean:: Struct > for Struct {
224222 fn from_tcx ( struct_ : clean:: Struct , tcx : TyCtxt < ' _ > ) -> Self {
225223 let clean:: Struct { struct_type, generics, fields, fields_stripped } = struct_;
0 commit comments