Skip to content

Commit 881bd86

Browse files
committed
Rustdoc-Json: Don't include foreign traits
1 parent c1b8eff commit 881bd86

File tree

2 files changed

+3
-61
lines changed

2 files changed

+3
-61
lines changed

src/librustdoc/json/mod.rs

+1-52
Original file line numberDiff line numberDiff line change
@@ -99,53 +99,6 @@ impl<'tcx> JsonRenderer<'tcx> {
9999
})
100100
.unwrap_or_default()
101101
}
102-
103-
fn get_trait_items(&mut self) -> Vec<(types::Id, types::Item)> {
104-
debug!("Adding foreign trait items");
105-
Rc::clone(&self.cache)
106-
.traits
107-
.iter()
108-
.filter_map(|(&id, trait_item)| {
109-
// only need to synthesize items for external traits
110-
if !id.is_local() {
111-
for item in &trait_item.items {
112-
trace!("Adding subitem to {id:?}: {:?}", item.item_id);
113-
self.item(item.clone()).unwrap();
114-
}
115-
let item_id = from_item_id(id.into(), self.tcx);
116-
Some((
117-
item_id.clone(),
118-
types::Item {
119-
id: item_id,
120-
crate_id: id.krate.as_u32(),
121-
name: self
122-
.cache
123-
.paths
124-
.get(&id)
125-
.unwrap_or_else(|| {
126-
self.cache
127-
.external_paths
128-
.get(&id)
129-
.expect("Trait should either be in local or external paths")
130-
})
131-
.0
132-
.last()
133-
.map(|s| s.to_string()),
134-
visibility: types::Visibility::Public,
135-
inner: types::ItemEnum::Trait(trait_item.clone().into_tcx(self.tcx)),
136-
span: None,
137-
docs: Default::default(),
138-
links: Default::default(),
139-
attrs: Default::default(),
140-
deprecation: Default::default(),
141-
},
142-
))
143-
} else {
144-
None
145-
}
146-
})
147-
.collect()
148-
}
149102
}
150103

151104
impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> {
@@ -276,11 +229,7 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> {
276229

277230
let e = ExternalCrate { crate_num: LOCAL_CRATE };
278231

279-
// FIXME(adotinthevoid): Remove this, as it's not consistent with not
280-
// inlining foreign items.
281-
let foreign_trait_items = self.get_trait_items();
282-
let mut index = (*self.index).clone().into_inner();
283-
index.extend(foreign_trait_items);
232+
let index = (*self.index).clone().into_inner();
284233

285234
debug!("Constructing Output");
286235
// This needs to be the default HashMap for compatibility with the public interface for
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
#![no_std]
22
pub fn drop_default<T: core::default::Default>(_x: T) {}
33

4-
// FIXME(adotinthevoid): Theses shouldn't be here
5-
// @has "$.index[*][?(@.name=='Debug')]"
6-
7-
// Debug may have several items. All we depend on here the that `fmt` is first. See
8-
// https://github.com/rust-lang/rust/pull/104525#issuecomment-1331087852 for why we
9-
// can't use [*].
10-
11-
// @set Debug_fmt = "$.index[*][?(@.name=='Debug')].inner.items[0]"
12-
// @has "$.index[*][?(@.name=='fmt')].id" $Debug_fmt
4+
// @!has "$.index[*][?(@.name=='Debug')]"
5+
// @!has "$.index[*][?(@.name=='Default')]"

0 commit comments

Comments
 (0)