@@ -10,7 +10,6 @@ use rustc_ast::ast;
10
10
use rustc_hir:: def:: CtorKind ;
11
11
use rustc_middle:: ty:: TyCtxt ;
12
12
use rustc_span:: def_id:: { DefId , CRATE_DEF_INDEX } ;
13
- use rustc_span:: symbol:: Symbol ;
14
13
use rustc_span:: Pos ;
15
14
16
15
use rustdoc_json_types:: * ;
@@ -34,23 +33,26 @@ impl JsonRenderer<'_> {
34
33
did. map ( |did| ( link. clone ( ) , from_def_id ( did) ) )
35
34
} )
36
35
. 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 {
39
45
clean:: StrippedItem ( _) => return None ,
40
- kind => from_clean_item_kind ( kind , self . tcx , & name ) ,
46
+ _ => from_clean_item ( item , self . tcx ) ,
41
47
} ;
42
48
Some ( Item {
43
49
id : from_def_id ( def_id) ,
44
50
crate_id : def_id. krate . as_u32 ( ) ,
45
51
name : name. map ( |sym| sym. to_string ( ) ) ,
46
52
span : self . convert_span ( span) ,
47
53
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,
54
56
deprecation : deprecation. map ( from_deprecation) ,
55
57
inner,
56
58
links,
@@ -172,10 +174,12 @@ crate fn from_def_id(did: DefId) -> Id {
172
174
Id ( format ! ( "{}:{}" , did. krate. as_u32( ) , u32 :: from( did. index) ) )
173
175
}
174
176
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 {
176
178
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 ) } ) ,
179
183
ImportItem ( i) => ItemEnum :: Import ( i. into_tcx ( tcx) ) ,
180
184
StructItem ( s) => ItemEnum :: Struct ( s. into_tcx ( tcx) ) ,
181
185
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
214
218
}
215
219
}
216
220
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
-
223
221
impl FromWithTcx < clean:: Struct > for Struct {
224
222
fn from_tcx ( struct_ : clean:: Struct , tcx : TyCtxt < ' _ > ) -> Self {
225
223
let clean:: Struct { struct_type, generics, fields, fields_stripped } = struct_;
0 commit comments