@@ -27,12 +27,8 @@ impl JsonRenderer<'_> {
27
27
let deprecation = item. deprecation ( self . tcx ) ;
28
28
let clean:: Item { source, name, attrs, kind, visibility, def_id } = item;
29
29
let inner = match * kind {
30
- clean:: ItemKind :: ExternCrateItem { ref src } => ItemEnum :: ExternCrateItem {
31
- name : name. as_ref ( ) . unwrap ( ) . to_string ( ) ,
32
- rename : src. map ( |x| x. to_string ( ) ) ,
33
- } ,
34
30
clean:: StrippedItem ( _) => return None ,
35
- x => from_clean_item_kind ( x, self . tcx ) ,
31
+ x => from_clean_item_kind ( x, self . tcx , & name ) ,
36
32
} ;
37
33
Some ( Item {
38
34
id : from_def_id ( def_id) ,
@@ -155,7 +151,7 @@ crate fn from_def_id(did: DefId) -> Id {
155
151
Id ( format ! ( "{}:{}" , did. krate. as_u32( ) , u32 :: from( did. index) ) )
156
152
}
157
153
158
- fn from_clean_item_kind ( item : clean:: ItemKind , tcx : TyCtxt < ' _ > ) -> ItemEnum {
154
+ fn from_clean_item_kind ( item : clean:: ItemKind , tcx : TyCtxt < ' _ > , name : & Option < Symbol > ) -> ItemEnum {
159
155
use clean:: ItemKind :: * ;
160
156
match item {
161
157
ModuleItem ( m) => ItemEnum :: ModuleItem ( m. into ( ) ) ,
@@ -185,11 +181,14 @@ fn from_clean_item_kind(item: clean::ItemKind, tcx: TyCtxt<'_>) -> ItemEnum {
185
181
bounds : g. into_iter ( ) . map ( Into :: into) . collect ( ) ,
186
182
default : t. map ( Into :: into) ,
187
183
} ,
188
- StrippedItem ( inner) => from_clean_item_kind ( * inner, tcx) ,
184
+ StrippedItem ( inner) => from_clean_item_kind ( * inner, tcx, name ) ,
189
185
PrimitiveItem ( _) | KeywordItem ( _) => {
190
186
panic ! ( "{:?} is not supported for JSON output" , item)
191
187
}
192
- ExternCrateItem { .. } => unreachable ! ( ) ,
188
+ ExternCrateItem { ref src } => ItemEnum :: ExternCrateItem {
189
+ name : name. as_ref ( ) . unwrap ( ) . to_string ( ) ,
190
+ rename : src. map ( |x| x. to_string ( ) ) ,
191
+ } ,
193
192
}
194
193
}
195
194
0 commit comments