Skip to content

Commit e80ccd3

Browse files
committed
Rustdoc-Json: Don't loose subitems of foreign traits.
1 parent 2e44c17 commit e80ccd3

File tree

3 files changed

+27
-4
lines changed

3 files changed

+27
-4
lines changed

src/etc/check_missing_items.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ def check_generic_param(param):
4949
ty = param["kind"]["type"]
5050
if ty["default"]:
5151
check_type(ty["default"])
52+
for bound in ty["bounds"]:
53+
check_generic_bound(bound)
5254
elif "const" in param["kind"]:
5355
check_type(param["kind"]["const"])
5456

@@ -88,8 +90,11 @@ def check_path(path):
8890
check_type(input_ty)
8991
if args["parenthesized"]["output"]:
9092
check_type(args["parenthesized"]["output"])
91-
if not valid_id(path["id"]):
92-
print("Type contained an invalid ID:", path["id"])
93+
94+
if path["id"] in crate["index"]:
95+
work_list.add(path["id"])
96+
elif path["id"] not in crate["paths"]:
97+
print("Id not in index or paths:", path["id"])
9398
sys.exit(1)
9499

95100
def check_type(ty):

src/librustdoc/json/mod.rs

+13-2
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ impl<'tcx> JsonRenderer<'tcx> {
101101
}
102102

103103
fn get_trait_items(&mut self) -> Vec<(types::Id, types::Item)> {
104+
debug!("Adding foreign trait items");
104105
Rc::clone(&self.cache)
105106
.traits
106107
.iter()
@@ -109,6 +110,7 @@ impl<'tcx> JsonRenderer<'tcx> {
109110
if !id.is_local() {
110111
let trait_item = &trait_item.trait_;
111112
for item in &trait_item.items {
113+
trace!("Adding subitem to {id:?}: {:?}", item.item_id);
112114
self.item(item.clone()).unwrap();
113115
}
114116
let item_id = from_item_id(id.into(), self.tcx);
@@ -184,7 +186,9 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> {
184186
/// the hashmap because certain items (traits and types) need to have their mappings for trait
185187
/// implementations filled out before they're inserted.
186188
fn item(&mut self, item: clean::Item) -> Result<(), Error> {
187-
trace!("rendering {} {:?}", item.type_(), item.name);
189+
let item_type = item.type_();
190+
let item_name = item.name;
191+
trace!("rendering {} {:?}", item_type, item_name);
188192

189193
// Flatten items that recursively store other items. We include orphaned items from
190194
// stripped modules and etc that are otherwise reachable.
@@ -253,6 +257,7 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> {
253257
}
254258
}
255259

260+
trace!("done rendering {} {:?}", item_type, item_name);
256261
Ok(())
257262
}
258263

@@ -263,14 +268,20 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> {
263268
fn after_krate(&mut self) -> Result<(), Error> {
264269
debug!("Done with crate");
265270

271+
debug!("Adding Primitve impls");
266272
for primitive in Rc::clone(&self.cache).primitive_locations.values() {
267273
self.get_impls(*primitive);
268274
}
269275

270276
let e = ExternalCrate { crate_num: LOCAL_CRATE };
271277

278+
// FIXME(adotinthevoid): Remove this, as it's not consistant with not
279+
// inlining foreign items.
280+
let foreign_trait_items = self.get_trait_items();
272281
let mut index = (*self.index).clone().into_inner();
273-
index.extend(self.get_trait_items());
282+
index.extend(foreign_trait_items);
283+
284+
debug!("Constructing Output");
274285
// This needs to be the default HashMap for compatibility with the public interface for
275286
// rustdoc-json-types
276287
#[allow(rustc::default_hash_types)]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#![no_std]
2+
pub fn drop_default<T: core::default::Default>(_x: T) {}
3+
4+
// FIXME(adotinthevoid): Theses shouldn't be here
5+
// @has "$.index[*][?(@.name=='Debug')]"
6+
// @set Debug_fmt = "$.index[*][?(@.name=='Debug')].inner.items[*]"
7+
// @has "$.index[*][?(@.name=='fmt')].id" $Debug_fmt

0 commit comments

Comments
 (0)