Rollup merge of #128385 - its-the-shrimp:fix_114039, r=aDotInTheVoid
rustdoc-json: discard non-local inherent impls for primitives Fixes #114039 at least it should r? `@aDotInTheVoid`
This commit is contained in:
commit
376a6f9f43
@ -310,16 +310,16 @@ fn is_from_private_dep(tcx: TyCtxt<'_>, cache: &Cache, def_id: DefId) -> bool {
|
|||||||
// `public_items` map, so we can skip inserting into the
|
// `public_items` map, so we can skip inserting into the
|
||||||
// paths map if there was already an entry present and we're
|
// paths map if there was already an entry present and we're
|
||||||
// not a public item.
|
// not a public item.
|
||||||
if !self.cache.paths.contains_key(&item.item_id.expect_def_id())
|
let item_def_id = item.item_id.expect_def_id();
|
||||||
|
if !self.cache.paths.contains_key(&item_def_id)
|
||||||
|| self
|
|| self
|
||||||
.cache
|
.cache
|
||||||
.effective_visibilities
|
.effective_visibilities
|
||||||
.is_directly_public(self.tcx, item.item_id.expect_def_id())
|
.is_directly_public(self.tcx, item_def_id)
|
||||||
{
|
{
|
||||||
self.cache.paths.insert(
|
self.cache
|
||||||
item.item_id.expect_def_id(),
|
.paths
|
||||||
(self.cache.stack.clone(), item.type_()),
|
.insert(item_def_id, (self.cache.stack.clone(), item.type_()));
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -381,9 +381,7 @@ fn is_from_private_dep(tcx: TyCtxt<'_>, cache: &Cache, def_id: DefId) -> bool {
|
|||||||
&& adt.is_fundamental()
|
&& adt.is_fundamental()
|
||||||
{
|
{
|
||||||
for ty in generics {
|
for ty in generics {
|
||||||
if let Some(did) = ty.def_id(self.cache) {
|
dids.extend(ty.def_id(self.cache));
|
||||||
dids.insert(did);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -396,32 +394,26 @@ fn is_from_private_dep(tcx: TyCtxt<'_>, cache: &Cache, def_id: DefId) -> bool {
|
|||||||
.primitive_type()
|
.primitive_type()
|
||||||
.and_then(|t| self.cache.primitive_locations.get(&t).cloned());
|
.and_then(|t| self.cache.primitive_locations.get(&t).cloned());
|
||||||
|
|
||||||
if let Some(did) = did {
|
dids.extend(did);
|
||||||
dids.insert(did);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(generics) = i.trait_.as_ref().and_then(|t| t.generics()) {
|
if let Some(generics) = i.trait_.as_ref().and_then(|t| t.generics()) {
|
||||||
for bound in generics {
|
for bound in generics {
|
||||||
if let Some(did) = bound.def_id(self.cache) {
|
dids.extend(bound.def_id(self.cache));
|
||||||
dids.insert(did);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let impl_item = Impl { impl_item: item };
|
let impl_item = Impl { impl_item: item };
|
||||||
if impl_item.trait_did().map_or(true, |d| self.cache.traits.contains_key(&d)) {
|
let impl_did = impl_item.def_id();
|
||||||
|
let trait_did = impl_item.trait_did();
|
||||||
|
if trait_did.map_or(true, |d| self.cache.traits.contains_key(&d)) {
|
||||||
for did in dids {
|
for did in dids {
|
||||||
if self.impl_ids.entry(did).or_default().insert(impl_item.def_id()) {
|
if self.impl_ids.entry(did).or_default().insert(impl_did) {
|
||||||
self.cache
|
self.cache.impls.entry(did).or_default().push(impl_item.clone());
|
||||||
.impls
|
|
||||||
.entry(did)
|
|
||||||
.or_insert_with(Vec::new)
|
|
||||||
.push(impl_item.clone());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let trait_did = impl_item.trait_did().expect("no trait did");
|
let trait_did = trait_did.expect("no trait did");
|
||||||
self.cache.orphan_trait_impls.push((trait_did, dids, impl_item));
|
self.cache.orphan_trait_impls.push((trait_did, dids, impl_item));
|
||||||
}
|
}
|
||||||
None
|
None
|
||||||
|
@ -216,13 +216,7 @@ fn mod_item_in(&mut self, _item: &clean::Item) -> Result<(), Error> {
|
|||||||
fn after_krate(&mut self) -> Result<(), Error> {
|
fn after_krate(&mut self) -> Result<(), Error> {
|
||||||
debug!("Done with crate");
|
debug!("Done with crate");
|
||||||
|
|
||||||
debug!("Adding Primitive impls");
|
|
||||||
for primitive in Rc::clone(&self.cache).primitive_locations.values() {
|
|
||||||
self.get_impls(*primitive);
|
|
||||||
}
|
|
||||||
|
|
||||||
let e = ExternalCrate { crate_num: LOCAL_CRATE };
|
let e = ExternalCrate { crate_num: LOCAL_CRATE };
|
||||||
|
|
||||||
let index = (*self.index).clone().into_inner();
|
let index = (*self.index).clone().into_inner();
|
||||||
|
|
||||||
debug!("Constructing Output");
|
debug!("Constructing Output");
|
||||||
|
5
tests/rustdoc-json/the_smallest.rs
Normal file
5
tests/rustdoc-json/the_smallest.rs
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
// This test asserts that `index` is not polluted with unrelated items.
|
||||||
|
// See https://github.com/rust-lang/rust/issues/114039
|
||||||
|
|
||||||
|
//@ count "$.index[*]" 1
|
||||||
|
fn main() {}
|
Loading…
Reference in New Issue
Block a user