@@ -27,12 +27,8 @@ impl JsonRenderer<'_> {
2727 let deprecation = item. deprecation ( self . tcx ) ;
2828 let clean:: Item { source, name, attrs, kind, visibility, def_id } = item;
2929 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- } ,
3430 clean:: StrippedItem ( _) => return None ,
35- x => from_clean_item_kind ( x, self . tcx ) ,
31+ x => from_clean_item_kind ( x, self . tcx , & name ) ,
3632 } ;
3733 Some ( Item {
3834 id : from_def_id ( def_id) ,
@@ -155,7 +151,7 @@ crate fn from_def_id(did: DefId) -> Id {
155151 Id ( format ! ( "{}:{}" , did. krate. as_u32( ) , u32 :: from( did. index) ) )
156152}
157153
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 {
159155 use clean:: ItemKind :: * ;
160156 match item {
161157 ModuleItem ( m) => ItemEnum :: ModuleItem ( m. into ( ) ) ,
@@ -185,11 +181,14 @@ fn from_clean_item_kind(item: clean::ItemKind, tcx: TyCtxt<'_>) -> ItemEnum {
185181 bounds : g. into_iter ( ) . map ( Into :: into) . collect ( ) ,
186182 default : t. map ( Into :: into) ,
187183 } ,
188- StrippedItem ( inner) => from_clean_item_kind ( * inner, tcx) ,
184+ StrippedItem ( inner) => from_clean_item_kind ( * inner, tcx, name ) ,
189185 PrimitiveItem ( _) | KeywordItem ( _) => {
190186 panic ! ( "{:?} is not supported for JSON output" , item)
191187 }
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+ } ,
193192 }
194193}
195194
0 commit comments