@@ -25,32 +25,37 @@ impl JsonRenderer<'_> {
2525 let item_type = ItemType :: from ( & item) ;
2626 let deprecation = item. deprecation ( self . tcx ) ;
2727 let clean:: Item { source, name, attrs, kind, visibility, def_id } = item;
28- match * kind {
29- clean:: StrippedItem ( _) => None ,
30- kind => Some ( Item {
31- id : from_def_id ( def_id) ,
32- crate_id : def_id. krate . as_u32 ( ) ,
33- name : name. map ( |sym| sym. to_string ( ) ) ,
34- source : self . convert_span ( source) ,
35- visibility : self . convert_visibility ( visibility) ,
36- docs : attrs. collapsed_doc_value ( ) ,
37- links : attrs
38- . links
39- . into_iter ( )
40- . filter_map ( |clean:: ItemLink { link, did, .. } | {
41- did. map ( |did| ( link, from_def_id ( did) ) )
42- } )
43- . collect ( ) ,
44- attrs : attrs
45- . other_attrs
46- . iter ( )
47- . map ( rustc_ast_pretty:: pprust:: attribute_to_string)
48- . collect ( ) ,
49- deprecation : deprecation. map ( from_deprecation) ,
50- kind : item_type. into ( ) ,
51- inner : from_clean_item_kind ( kind, self . tcx ) ,
52- } ) ,
53- }
28+ let inner = match * kind {
29+ clean:: ItemKind :: ExternCrateItem { ref src } => ItemEnum :: ExternCrateItem {
30+ name : name. as_ref ( ) . unwrap ( ) . to_string ( ) ,
31+ rename : src. map ( |x| x. to_string ( ) ) ,
32+ } ,
33+ clean:: StrippedItem ( _) => return None ,
34+ x => from_clean_item_kind ( x, self . tcx ) ,
35+ } ;
36+ Some ( Item {
37+ id : from_def_id ( def_id) ,
38+ crate_id : def_id. krate . as_u32 ( ) ,
39+ name : name. map ( |sym| sym. to_string ( ) ) ,
40+ source : self . convert_span ( source) ,
41+ visibility : self . convert_visibility ( visibility) ,
42+ docs : attrs. collapsed_doc_value ( ) ,
43+ links : attrs
44+ . links
45+ . into_iter ( )
46+ . filter_map ( |clean:: ItemLink { link, did, .. } | {
47+ did. map ( |did| ( link, from_def_id ( did) ) )
48+ } )
49+ . collect ( ) ,
50+ attrs : attrs
51+ . other_attrs
52+ . iter ( )
53+ . map ( rustc_ast_pretty:: pprust:: attribute_to_string)
54+ . collect ( ) ,
55+ deprecation : deprecation. map ( from_deprecation) ,
56+ kind : item_type. into ( ) ,
57+ inner,
58+ } )
5459 }
5560
5661 fn convert_span ( & self , span : clean:: Span ) -> Option < Span > {
@@ -153,9 +158,6 @@ fn from_clean_item_kind(item: clean::ItemKind, tcx: TyCtxt<'_>) -> ItemEnum {
153158 use clean:: ItemKind :: * ;
154159 match item {
155160 ModuleItem ( m) => ItemEnum :: ModuleItem ( m. into ( ) ) ,
156- ExternCrateItem ( c, a) => {
157- ItemEnum :: ExternCrateItem { name : c. to_string ( ) , rename : a. map ( |x| x. to_string ( ) ) }
158- }
159161 ImportItem ( i) => ItemEnum :: ImportItem ( i. into ( ) ) ,
160162 StructItem ( s) => ItemEnum :: StructItem ( s. into ( ) ) ,
161163 UnionItem ( u) => ItemEnum :: UnionItem ( u. into ( ) ) ,
@@ -186,6 +188,7 @@ fn from_clean_item_kind(item: clean::ItemKind, tcx: TyCtxt<'_>) -> ItemEnum {
186188 PrimitiveItem ( _) | KeywordItem ( _) => {
187189 panic ! ( "{:?} is not supported for JSON output" , item)
188190 }
191+ ExternCrateItem { .. } => unreachable ! ( ) ,
189192 }
190193}
191194
0 commit comments