Change:
Generated rustdoc JSON for every one of dozens of crates I've looked at seems to contain unexpected inlined items that look like an block and its contents. I expected to see this happen: rustdoc JSON file contains only the items defined or re-exported by the corresponding crate. Instead, this happened: the rustdoc JSON file contains items like this: In this example, is and here are the names of the items contained in that impl (also part of the rustdoc JSON): Similarly, you can find items from : Invocation for generating rustdoc JSON: : You can find a variety of pre-generated rustdoc JSON files with this issue here: Briefly discussed in Zulip: https://rust- I'll have to work around this behavior to shield , which uses the same codebase as the playground link above. I can hold off on updating the playground for, say, another week, but at some point I'll need to upgrade it to include my workaround which means those items will cease being shown. label +T-rustdoc +A-rustdoc-json
Possibly duplicate of
Might be! Definitely at least some overlap, not entirely sure if duplicate. Do you mind if I ship the workaround for this in cargo-semver-checks and the playground, which will hide these items from our lints and from queries in the playground?
Yeah, it's easy enough to reproduce in raw json, I'm not worried about the repro breaking.

Discussion:
// `public_items` map, so we can skip inserting into the // paths map if there was already an entry present and we're // not a public item. <del> if !self.cache.paths.contains_key(&item.item_id.expect_def_id()) </del> <ins> let item_def_id = item.item_id.expect_def_id(); if !self.cache.paths.contains_key(&item_def_id) </ins> || self .cache .effective_visibilities <del> .is_directly_public(self.tcx, item.item_id.expect_def_id()) </del> <ins> .is_directly_public(self.tcx, item_def_id) </ins> { <del> self.cache.paths.insert( item.item_id.expect_def_id(), (self.cache.stack.clone(), item.type_()), ); </del> <ins> self.cache .paths .insert(item_def_id, (self.cache.stack.clone(), item.type_())); </ins> } } }

&& adt.is_fundamental() { for ty in generics { <del> if let Some(did) = ty.def_id(self.cache) { dids.insert(did); } </del> <ins> dids.extend(ty.def_id(self.cache)); </ins> } } }

.primitive_type() .and_then(|t| self.cache.primitive_locations.get(&t).cloned()); <del> if let Some(did) = did { dids.insert(did); } </del> <ins> dids.extend(did); </ins> } } if let Some(generics) = i.trait_.as_ref().and_then(|t| t.generics()) { for bound in generics { <del> if let Some(did) = bound.def_id(self.cache) { dids.insert(did); } </del> <ins> dids.extend(bound.def_id(self.cache)); </ins> } } let impl_item = Impl { impl_item: item }; <del> if impl_item.trait_did().map_or(true, |d| self.cache.traits.contains_key(&d)) { </del> <ins> 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)) { </ins> for did in dids { <del> if self.impl_ids.entry(did).or_default().insert(impl_item.def_id()) { self.cache .impls .entry(did) .or_insert_with(Vec::new) .push(impl_item.clone()); </del> <ins> if self.impl_ids.entry(did).or_default().insert(impl_did) { self.cache.impls.entry(did).or_default().push(impl_item.clone()); </ins> } } } else { <del> let trait_did = impl_item.trait_did().expect("no trait did"); </del> <ins> let trait_did = trait_did.expect("no trait did"); </ins> self.cache.orphan_trait_impls.push((trait_did, dids, impl_item)); } None

fn after_krate(&mut self) -> Result<(), Error> { debug!("Done with crate"); <del> debug!("Adding Primitive impls"); for primitive in Rc::clone(&self.cache).primitive_locations.values() { self.get_impls(*primitive); } </del> let e = ExternalCrate { crate_num: LOCAL_CRATE }; let index = (*self.index).clone().into_inner(); debug!("Constructing Output");

<ins> // 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() {} </ins>