From 0541a0c8c36a700e48ed5b7184686b515dbc5bf3 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 7 Feb 2023 17:07:49 +0100 Subject: [PATCH 1/4] Allow reexports of items with same name but different types to both appear --- src/librustdoc/json/conversions.rs | 102 +++++++++++++++-------------- src/librustdoc/json/mod.rs | 15 ++--- 2 files changed, 60 insertions(+), 57 deletions(-) diff --git a/src/librustdoc/json/conversions.rs b/src/librustdoc/json/conversions.rs index bd95ec18650b3..22db2390d080f 100644 --- a/src/librustdoc/json/conversions.rs +++ b/src/librustdoc/json/conversions.rs @@ -38,7 +38,7 @@ impl JsonRenderer<'_> { Some(UrlFragment::UserWritten(_)) | None => *page_id, }; - (link.clone(), from_item_id(id.into(), self.tcx)) + (link.clone(), id_from_item_inner(id.into(), self.tcx, None)) }) .collect(); let docs = item.attrs.collapsed_doc_value(); @@ -50,7 +50,8 @@ impl JsonRenderer<'_> { .collect(); let span = item.span(self.tcx); let visibility = item.visibility(self.tcx); - let clean::Item { name, attrs: _, kind: _, item_id, cfg: _, .. } = item; + let clean::Item { name, item_id, .. } = item; + let id = id_from_item(&item, self.tcx); let inner = match *item.kind { clean::KeywordItem => return None, clean::StrippedItem(ref inner) => { @@ -69,7 +70,7 @@ impl JsonRenderer<'_> { _ => from_clean_item(item, self.tcx), }; Some(Item { - id: from_item_id_with_name(item_id, self.tcx, name), + id, crate_id: item_id.krate().as_u32(), name: name.map(|sym| sym.to_string()), span: span.and_then(|span| self.convert_span(span)), @@ -107,7 +108,7 @@ impl JsonRenderer<'_> { Some(ty::Visibility::Public) => Visibility::Public, Some(ty::Visibility::Restricted(did)) if did.is_crate_root() => Visibility::Crate, Some(ty::Visibility::Restricted(did)) => Visibility::Restricted { - parent: from_item_id(did.into(), self.tcx), + parent: id_from_item_inner(did.into(), self.tcx, None), path: self.tcx.def_path(did).to_string_no_crate_verbose(), }, } @@ -207,51 +208,58 @@ impl FromWithTcx for TypeBindingKind { /// It generates an ID as follows: /// /// `CRATE_ID:ITEM_ID[:NAME_ID]` (if there is no name, NAME_ID is not generated). -pub(crate) fn from_item_id(item_id: ItemId, tcx: TyCtxt<'_>) -> Id { - from_item_id_with_name(item_id, tcx, None) -} - -// FIXME: this function (and appending the name at the end of the ID) should be removed when -// reexports are not inlined anymore for json format. It should be done in #93518. -pub(crate) fn from_item_id_with_name(item_id: ItemId, tcx: TyCtxt<'_>, name: Option) -> Id { - struct DisplayDefId<'a>(DefId, TyCtxt<'a>, Option); +pub(crate) fn id_from_item_inner(item_id: ItemId, tcx: TyCtxt<'_>, extra: Option<&Id>) -> Id { + struct DisplayDefId<'a, 'b>(DefId, TyCtxt<'a>, Option<&'b Id>); - impl<'a> fmt::Display for DisplayDefId<'a> { + impl<'a, 'b> fmt::Display for DisplayDefId<'a, 'b> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let DisplayDefId(def_id, tcx, name) = self; - let name = match name { - Some(name) => format!(":{}", name.as_u32()), - None => { - // We need this workaround because primitive types' DefId actually refers to - // their parent module, which isn't present in the output JSON items. So - // instead, we directly get the primitive symbol and convert it to u32 to - // generate the ID. - if matches!(tcx.def_kind(def_id), DefKind::Mod) && - let Some(prim) = tcx.get_attrs(*def_id, sym::doc) - .flat_map(|attr| attr.meta_item_list().unwrap_or_default()) - .filter(|attr| attr.has_name(sym::primitive)) - .find_map(|attr| attr.value_str()) { - format!(":{}", prim.as_u32()) - } else { - tcx - .opt_item_name(*def_id) - .map(|n| format!(":{}", n.as_u32())) - .unwrap_or_default() - } - } + let DisplayDefId(def_id, tcx, extra) = self; + // We need this workaround because primitive types' DefId actually refers to + // their parent module, which isn't present in the output JSON items. So + // instead, we directly get the primitive symbol and convert it to u32 to + // generate the ID. + let s; + let extra = if let Some(e) = extra { + s = format!("-{}", e.0); + &s + } else { + "" + }; + let name = if matches!(tcx.def_kind(def_id), DefKind::Mod) && + let Some(prim) = tcx.get_attrs(*def_id, sym::doc) + .flat_map(|attr| attr.meta_item_list().unwrap_or_default()) + .filter(|attr| attr.has_name(sym::primitive)) + .find_map(|attr| attr.value_str()) { + format!(":{}", prim.as_u32()) + } else { + tcx + .opt_item_name(*def_id) + .map(|n| format!(":{}", n.as_u32())) + .unwrap_or_default() }; - write!(f, "{}:{}{}", self.0.krate.as_u32(), u32::from(self.0.index), name) + write!(f, "{}:{}{name}{extra}", self.0.krate.as_u32(), u32::from(self.0.index)) } } match item_id { - ItemId::DefId(did) => Id(format!("{}", DisplayDefId(did, tcx, name))), + ItemId::DefId(did) => Id(format!("{}", DisplayDefId(did, tcx, extra))), ItemId::Blanket { for_, impl_id } => { - Id(format!("b:{}-{}", DisplayDefId(impl_id, tcx, None), DisplayDefId(for_, tcx, name))) + Id(format!("b:{}-{}", DisplayDefId(impl_id, tcx, None), DisplayDefId(for_, tcx, extra))) } ItemId::Auto { for_, trait_ } => { - Id(format!("a:{}-{}", DisplayDefId(trait_, tcx, None), DisplayDefId(for_, tcx, name))) + Id(format!("a:{}-{}", DisplayDefId(trait_, tcx, None), DisplayDefId(for_, tcx, extra))) + } + } +} + +pub(crate) fn id_from_item(item: &clean::Item, tcx: TyCtxt<'_>) -> Id { + match *item.kind { + clean::ItemKind::ImportItem(ref import) => { + let extra = + import.source.did.map(ItemId::from).map(|i| id_from_item_inner(i, tcx, None)); + id_from_item_inner(item.item_id, tcx, extra.as_ref()) } + _ => id_from_item_inner(item.item_id, tcx, None), } } @@ -525,7 +533,7 @@ impl FromWithTcx for Path { fn from_tcx(path: clean::Path, tcx: TyCtxt<'_>) -> Path { Path { name: path.whole_name(), - id: from_item_id(path.def_id().into(), tcx), + id: id_from_item_inner(path.def_id().into(), tcx, None), args: path.segments.last().map(|args| Box::new(args.clone().args.into_tcx(tcx))), } } @@ -702,7 +710,7 @@ impl FromWithTcx for Import { Import { source: import.source.path.whole_name(), name, - id: import.source.did.map(ItemId::from).map(|i| from_item_id(i, tcx)), + id: import.source.did.map(ItemId::from).map(|i| id_from_item_inner(i, tcx, None)), glob, } } @@ -791,7 +799,7 @@ fn ids(items: impl IntoIterator, tcx: TyCtxt<'_>) -> Vec items .into_iter() .filter(|x| !x.is_stripped() && !x.is_keyword()) - .map(|i| from_item_id_with_name(i.item_id, tcx, i.name)) + .map(|i| id_from_item(&i, tcx)) .collect() } @@ -801,12 +809,10 @@ fn ids_keeping_stripped( ) -> Vec> { items .into_iter() - .map(|i| { - if !i.is_stripped() && !i.is_keyword() { - Some(from_item_id_with_name(i.item_id, tcx, i.name)) - } else { - None - } - }) + .map( + |i| { + if !i.is_stripped() && !i.is_keyword() { Some(id_from_item(&i, tcx)) } else { None } + }, + ) .collect() } diff --git a/src/librustdoc/json/mod.rs b/src/librustdoc/json/mod.rs index e3788fe57d013..10900efd488e0 100644 --- a/src/librustdoc/json/mod.rs +++ b/src/librustdoc/json/mod.rs @@ -28,7 +28,7 @@ use crate::docfs::PathError; use crate::error::Error; use crate::formats::cache::Cache; use crate::formats::FormatRenderer; -use crate::json::conversions::{from_item_id, from_item_id_with_name, IntoWithTcx}; +use crate::json::conversions::{id_from_item, id_from_item_inner, IntoWithTcx}; use crate::{clean, try_err}; #[derive(Clone)] @@ -58,7 +58,7 @@ impl<'tcx> JsonRenderer<'tcx> { .map(|i| { let item = &i.impl_item; self.item(item.clone()).unwrap(); - from_item_id_with_name(item.item_id, self.tcx, item.name) + id_from_item(&item, self.tcx) }) .collect() }) @@ -89,7 +89,7 @@ impl<'tcx> JsonRenderer<'tcx> { if item.item_id.is_local() || is_primitive_impl { self.item(item.clone()).unwrap(); - Some(from_item_id_with_name(item.item_id, self.tcx, item.name)) + Some(id_from_item(&item, self.tcx)) } else { None } @@ -150,7 +150,6 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> { // Flatten items that recursively store other items item.kind.inner_items().for_each(|i| self.item(i.clone()).unwrap()); - let name = item.name; let item_id = item.item_id; if let Some(mut new_item) = self.convert_item(item) { let can_be_ignored = match new_item.inner { @@ -193,10 +192,7 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> { | types::ItemEnum::Macro(_) | types::ItemEnum::ProcMacro(_) => false, }; - let removed = self - .index - .borrow_mut() - .insert(from_item_id_with_name(item_id, self.tcx, name), new_item.clone()); + let removed = self.index.borrow_mut().insert(new_item.id.clone(), new_item.clone()); // FIXME(adotinthevoid): Currently, the index is duplicated. This is a sanity check // to make sure the items are unique. The main place this happens is when an item, is @@ -207,6 +203,7 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> { if !can_be_ignored { assert_eq!(old_item, new_item); } + trace!("replaced {:?}\nwith {:?}", old_item, new_item); } } @@ -246,7 +243,7 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> { .chain(&self.cache.external_paths) .map(|(&k, &(ref path, kind))| { ( - from_item_id(k.into(), self.tcx), + id_from_item_inner(k.into(), self.tcx, None), types::ItemSummary { crate_id: k.krate.as_u32(), path: path.iter().map(|s| s.to_string()).collect(), From 7d47d7cbaa9e8d163818fbd006ffa5382e3e66c4 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 7 Feb 2023 17:08:59 +0100 Subject: [PATCH 2/4] Add regression test for #107677 --- .../reexport/same_name_different_types.rs | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 tests/rustdoc-json/reexport/same_name_different_types.rs diff --git a/tests/rustdoc-json/reexport/same_name_different_types.rs b/tests/rustdoc-json/reexport/same_name_different_types.rs new file mode 100644 index 0000000000000..2314a4eb90940 --- /dev/null +++ b/tests/rustdoc-json/reexport/same_name_different_types.rs @@ -0,0 +1,25 @@ +// Regression test for . + +#![feature(no_core)] +#![no_core] + +pub mod nested { + // @set foo_struct = "$.index[*][?(@.docs == 'Foo the struct')].id" + + /// Foo the struct + pub struct Foo {} + + // @set foo_fn = "$.index[*][?(@.docs == 'Foo the function')].id" + + #[allow(non_snake_case)] + /// Foo the function + pub fn Foo() {} +} + +// @ismany "$.index[*][?(@.inner.name == 'Foo' && @.kind == 'import')].inner.id" $foo_fn $foo_struct +// @ismany "$.index[*][?(@.inner.name == 'Bar' && @.kind == 'import')].inner.id" $foo_fn $foo_struct + +// @count "$.index[*][?(@.inner.name == 'Foo' && @.kind == 'import')]" 2 +pub use nested::Foo; +// @count "$.index[*][?(@.inner.name == 'Bar' && @.kind == 'import')]" 2 +pub use Foo as Bar; From 3adc0812542e6c9b13c78b85407dcc9d54885e0e Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 8 Feb 2023 18:16:41 +0100 Subject: [PATCH 3/4] Fix bad handling of primitive types --- src/librustdoc/json/conversions.rs | 76 ++++++++++++++++++------------ src/librustdoc/json/mod.rs | 2 +- 2 files changed, 48 insertions(+), 30 deletions(-) diff --git a/src/librustdoc/json/conversions.rs b/src/librustdoc/json/conversions.rs index 22db2390d080f..89e61404ed0a0 100644 --- a/src/librustdoc/json/conversions.rs +++ b/src/librustdoc/json/conversions.rs @@ -38,7 +38,7 @@ impl JsonRenderer<'_> { Some(UrlFragment::UserWritten(_)) | None => *page_id, }; - (link.clone(), id_from_item_inner(id.into(), self.tcx, None)) + (link.clone(), id_from_item_inner(id.into(), self.tcx, None, None)) }) .collect(); let docs = item.attrs.collapsed_doc_value(); @@ -108,7 +108,7 @@ impl JsonRenderer<'_> { Some(ty::Visibility::Public) => Visibility::Public, Some(ty::Visibility::Restricted(did)) if did.is_crate_root() => Visibility::Crate, Some(ty::Visibility::Restricted(did)) => Visibility::Restricted { - parent: id_from_item_inner(did.into(), self.tcx, None), + parent: id_from_item_inner(did.into(), self.tcx, None, None), path: self.tcx.def_path(did).to_string_no_crate_verbose(), }, } @@ -208,12 +208,17 @@ impl FromWithTcx for TypeBindingKind { /// It generates an ID as follows: /// /// `CRATE_ID:ITEM_ID[:NAME_ID]` (if there is no name, NAME_ID is not generated). -pub(crate) fn id_from_item_inner(item_id: ItemId, tcx: TyCtxt<'_>, extra: Option<&Id>) -> Id { - struct DisplayDefId<'a, 'b>(DefId, TyCtxt<'a>, Option<&'b Id>); +pub(crate) fn id_from_item_inner( + item_id: ItemId, + tcx: TyCtxt<'_>, + extra: Option<&Id>, + name: Option, +) -> Id { + struct DisplayDefId<'a, 'b>(DefId, TyCtxt<'a>, Option<&'b Id>, Option); impl<'a, 'b> fmt::Display for DisplayDefId<'a, 'b> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let DisplayDefId(def_id, tcx, extra) = self; + let DisplayDefId(def_id, tcx, extra, name) = self; // We need this workaround because primitive types' DefId actually refers to // their parent module, which isn't present in the output JSON items. So // instead, we directly get the primitive symbol and convert it to u32 to @@ -225,30 +230,43 @@ pub(crate) fn id_from_item_inner(item_id: ItemId, tcx: TyCtxt<'_>, extra: Option } else { "" }; - let name = if matches!(tcx.def_kind(def_id), DefKind::Mod) && - let Some(prim) = tcx.get_attrs(*def_id, sym::doc) - .flat_map(|attr| attr.meta_item_list().unwrap_or_default()) - .filter(|attr| attr.has_name(sym::primitive)) - .find_map(|attr| attr.value_str()) { - format!(":{}", prim.as_u32()) - } else { - tcx - .opt_item_name(*def_id) - .map(|n| format!(":{}", n.as_u32())) - .unwrap_or_default() + let name = match name { + Some(name) => format!(":{}", name.as_u32()), + None => { + // We need this workaround because primitive types' DefId actually refers to + // their parent module, which isn't present in the output JSON items. So + // instead, we directly get the primitive symbol and convert it to u32 to + // generate the ID. + if matches!(tcx.def_kind(def_id), DefKind::Mod) && + let Some(prim) = tcx.get_attrs(*def_id, sym::doc) + .flat_map(|attr| attr.meta_item_list().unwrap_or_default()) + .filter(|attr| attr.has_name(sym::primitive)) + .find_map(|attr| attr.value_str()) { + format!(":{}", prim.as_u32()) + } else { + tcx + .opt_item_name(*def_id) + .map(|n| format!(":{}", n.as_u32())) + .unwrap_or_default() + } + } }; - write!(f, "{}:{}{name}{extra}", self.0.krate.as_u32(), u32::from(self.0.index)) + write!(f, "{}:{}{name}{extra}", def_id.krate.as_u32(), u32::from(def_id.index)) } } match item_id { - ItemId::DefId(did) => Id(format!("{}", DisplayDefId(did, tcx, extra))), - ItemId::Blanket { for_, impl_id } => { - Id(format!("b:{}-{}", DisplayDefId(impl_id, tcx, None), DisplayDefId(for_, tcx, extra))) - } - ItemId::Auto { for_, trait_ } => { - Id(format!("a:{}-{}", DisplayDefId(trait_, tcx, None), DisplayDefId(for_, tcx, extra))) - } + ItemId::DefId(did) => Id(format!("{}", DisplayDefId(did, tcx, extra, name))), + ItemId::Blanket { for_, impl_id } => Id(format!( + "b:{}-{}", + DisplayDefId(impl_id, tcx, None, None), + DisplayDefId(for_, tcx, extra, name) + )), + ItemId::Auto { for_, trait_ } => Id(format!( + "a:{}-{}", + DisplayDefId(trait_, tcx, None, None), + DisplayDefId(for_, tcx, extra, name) + )), } } @@ -256,10 +274,10 @@ pub(crate) fn id_from_item(item: &clean::Item, tcx: TyCtxt<'_>) -> Id { match *item.kind { clean::ItemKind::ImportItem(ref import) => { let extra = - import.source.did.map(ItemId::from).map(|i| id_from_item_inner(i, tcx, None)); - id_from_item_inner(item.item_id, tcx, extra.as_ref()) + import.source.did.map(ItemId::from).map(|i| id_from_item_inner(i, tcx, None, None)); + id_from_item_inner(item.item_id, tcx, extra.as_ref(), item.name) } - _ => id_from_item_inner(item.item_id, tcx, None), + _ => id_from_item_inner(item.item_id, tcx, None, item.name), } } @@ -533,7 +551,7 @@ impl FromWithTcx for Path { fn from_tcx(path: clean::Path, tcx: TyCtxt<'_>) -> Path { Path { name: path.whole_name(), - id: id_from_item_inner(path.def_id().into(), tcx, None), + id: id_from_item_inner(path.def_id().into(), tcx, None, None), args: path.segments.last().map(|args| Box::new(args.clone().args.into_tcx(tcx))), } } @@ -710,7 +728,7 @@ impl FromWithTcx for Import { Import { source: import.source.path.whole_name(), name, - id: import.source.did.map(ItemId::from).map(|i| id_from_item_inner(i, tcx, None)), + id: import.source.did.map(ItemId::from).map(|i| id_from_item_inner(i, tcx, None, None)), glob, } } diff --git a/src/librustdoc/json/mod.rs b/src/librustdoc/json/mod.rs index 10900efd488e0..a0785f32cf203 100644 --- a/src/librustdoc/json/mod.rs +++ b/src/librustdoc/json/mod.rs @@ -243,7 +243,7 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> { .chain(&self.cache.external_paths) .map(|(&k, &(ref path, kind))| { ( - id_from_item_inner(k.into(), self.tcx, None), + id_from_item_inner(k.into(), self.tcx, None, None), types::ItemSummary { crate_id: k.krate.as_u32(), path: path.iter().map(|s| s.to_string()).collect(), From 1ae875f0a30b7a71755fac43a8c6fe00dd205d33 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 14 Feb 2023 14:22:25 +0100 Subject: [PATCH 4/4] Improve code readability --- src/librustdoc/json/conversions.rs | 27 +++++++++++++++++++-------- src/librustdoc/json/mod.rs | 4 ++-- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/librustdoc/json/conversions.rs b/src/librustdoc/json/conversions.rs index 89e61404ed0a0..d5e9010eb4ed9 100644 --- a/src/librustdoc/json/conversions.rs +++ b/src/librustdoc/json/conversions.rs @@ -38,7 +38,7 @@ impl JsonRenderer<'_> { Some(UrlFragment::UserWritten(_)) | None => *page_id, }; - (link.clone(), id_from_item_inner(id.into(), self.tcx, None, None)) + (link.clone(), id_from_item_default(id.into(), self.tcx)) }) .collect(); let docs = item.attrs.collapsed_doc_value(); @@ -108,7 +108,7 @@ impl JsonRenderer<'_> { Some(ty::Visibility::Public) => Visibility::Public, Some(ty::Visibility::Restricted(did)) if did.is_crate_root() => Visibility::Crate, Some(ty::Visibility::Restricted(did)) => Visibility::Restricted { - parent: id_from_item_inner(did.into(), self.tcx, None, None), + parent: id_from_item_default(did.into(), self.tcx), path: self.tcx.def_path(did).to_string_no_crate_verbose(), }, } @@ -205,14 +205,25 @@ impl FromWithTcx for TypeBindingKind { } } +#[inline] +pub(crate) fn id_from_item_default(item_id: ItemId, tcx: TyCtxt<'_>) -> Id { + id_from_item_inner(item_id, tcx, None, None) +} + /// It generates an ID as follows: /// -/// `CRATE_ID:ITEM_ID[:NAME_ID]` (if there is no name, NAME_ID is not generated). +/// `CRATE_ID:ITEM_ID[:NAME_ID][-EXTRA]`: +/// * If there is no `name`, `NAME_ID` is not generated. +/// * If there is no `extra`, `EXTRA` is not generated. +/// +/// * `name` is the item's name if available (it's not for impl blocks for example). +/// * `extra` is used for reexports: it contains the ID of the reexported item. It is used to allow +/// to have items with the same name but different types to both appear in the generated JSON. pub(crate) fn id_from_item_inner( item_id: ItemId, tcx: TyCtxt<'_>, - extra: Option<&Id>, name: Option, + extra: Option<&Id>, ) -> Id { struct DisplayDefId<'a, 'b>(DefId, TyCtxt<'a>, Option<&'b Id>, Option); @@ -275,9 +286,9 @@ pub(crate) fn id_from_item(item: &clean::Item, tcx: TyCtxt<'_>) -> Id { clean::ItemKind::ImportItem(ref import) => { let extra = import.source.did.map(ItemId::from).map(|i| id_from_item_inner(i, tcx, None, None)); - id_from_item_inner(item.item_id, tcx, extra.as_ref(), item.name) + id_from_item_inner(item.item_id, tcx, item.name, extra.as_ref()) } - _ => id_from_item_inner(item.item_id, tcx, None, item.name), + _ => id_from_item_inner(item.item_id, tcx, item.name, None), } } @@ -551,7 +562,7 @@ impl FromWithTcx for Path { fn from_tcx(path: clean::Path, tcx: TyCtxt<'_>) -> Path { Path { name: path.whole_name(), - id: id_from_item_inner(path.def_id().into(), tcx, None, None), + id: id_from_item_default(path.def_id().into(), tcx), args: path.segments.last().map(|args| Box::new(args.clone().args.into_tcx(tcx))), } } @@ -728,7 +739,7 @@ impl FromWithTcx for Import { Import { source: import.source.path.whole_name(), name, - id: import.source.did.map(ItemId::from).map(|i| id_from_item_inner(i, tcx, None, None)), + id: import.source.did.map(ItemId::from).map(|i| id_from_item_default(i, tcx)), glob, } } diff --git a/src/librustdoc/json/mod.rs b/src/librustdoc/json/mod.rs index a0785f32cf203..08bceb59cfde6 100644 --- a/src/librustdoc/json/mod.rs +++ b/src/librustdoc/json/mod.rs @@ -28,7 +28,7 @@ use crate::docfs::PathError; use crate::error::Error; use crate::formats::cache::Cache; use crate::formats::FormatRenderer; -use crate::json::conversions::{id_from_item, id_from_item_inner, IntoWithTcx}; +use crate::json::conversions::{id_from_item, id_from_item_default, IntoWithTcx}; use crate::{clean, try_err}; #[derive(Clone)] @@ -243,7 +243,7 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> { .chain(&self.cache.external_paths) .map(|(&k, &(ref path, kind))| { ( - id_from_item_inner(k.into(), self.tcx, None, None), + id_from_item_default(k.into(), self.tcx), types::ItemSummary { crate_id: k.krate.as_u32(), path: path.iter().map(|s| s.to_string()).collect(),