mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
Rustdoc-Json: Don't loose subitems of foreign traits.
This commit is contained in:
parent
2e44c17c12
commit
e80ccd3d3a
@ -49,6 +49,8 @@ def check_generic_param(param):
|
|||||||
ty = param["kind"]["type"]
|
ty = param["kind"]["type"]
|
||||||
if ty["default"]:
|
if ty["default"]:
|
||||||
check_type(ty["default"])
|
check_type(ty["default"])
|
||||||
|
for bound in ty["bounds"]:
|
||||||
|
check_generic_bound(bound)
|
||||||
elif "const" in param["kind"]:
|
elif "const" in param["kind"]:
|
||||||
check_type(param["kind"]["const"])
|
check_type(param["kind"]["const"])
|
||||||
|
|
||||||
@ -88,8 +90,11 @@ def check_path(path):
|
|||||||
check_type(input_ty)
|
check_type(input_ty)
|
||||||
if args["parenthesized"]["output"]:
|
if args["parenthesized"]["output"]:
|
||||||
check_type(args["parenthesized"]["output"])
|
check_type(args["parenthesized"]["output"])
|
||||||
if not valid_id(path["id"]):
|
|
||||||
print("Type contained an invalid ID:", path["id"])
|
if path["id"] in crate["index"]:
|
||||||
|
work_list.add(path["id"])
|
||||||
|
elif path["id"] not in crate["paths"]:
|
||||||
|
print("Id not in index or paths:", path["id"])
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
def check_type(ty):
|
def check_type(ty):
|
||||||
|
@ -101,6 +101,7 @@ impl<'tcx> JsonRenderer<'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn get_trait_items(&mut self) -> Vec<(types::Id, types::Item)> {
|
fn get_trait_items(&mut self) -> Vec<(types::Id, types::Item)> {
|
||||||
|
debug!("Adding foreign trait items");
|
||||||
Rc::clone(&self.cache)
|
Rc::clone(&self.cache)
|
||||||
.traits
|
.traits
|
||||||
.iter()
|
.iter()
|
||||||
@ -109,6 +110,7 @@ impl<'tcx> JsonRenderer<'tcx> {
|
|||||||
if !id.is_local() {
|
if !id.is_local() {
|
||||||
let trait_item = &trait_item.trait_;
|
let trait_item = &trait_item.trait_;
|
||||||
for item in &trait_item.items {
|
for item in &trait_item.items {
|
||||||
|
trace!("Adding subitem to {id:?}: {:?}", item.item_id);
|
||||||
self.item(item.clone()).unwrap();
|
self.item(item.clone()).unwrap();
|
||||||
}
|
}
|
||||||
let item_id = from_item_id(id.into(), self.tcx);
|
let item_id = from_item_id(id.into(), self.tcx);
|
||||||
@ -184,7 +186,9 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> {
|
|||||||
/// the hashmap because certain items (traits and types) need to have their mappings for trait
|
/// the hashmap because certain items (traits and types) need to have their mappings for trait
|
||||||
/// implementations filled out before they're inserted.
|
/// implementations filled out before they're inserted.
|
||||||
fn item(&mut self, item: clean::Item) -> Result<(), Error> {
|
fn item(&mut self, item: clean::Item) -> Result<(), Error> {
|
||||||
trace!("rendering {} {:?}", item.type_(), item.name);
|
let item_type = item.type_();
|
||||||
|
let item_name = item.name;
|
||||||
|
trace!("rendering {} {:?}", item_type, item_name);
|
||||||
|
|
||||||
// Flatten items that recursively store other items. We include orphaned items from
|
// Flatten items that recursively store other items. We include orphaned items from
|
||||||
// stripped modules and etc that are otherwise reachable.
|
// stripped modules and etc that are otherwise reachable.
|
||||||
@ -253,6 +257,7 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
trace!("done rendering {} {:?}", item_type, item_name);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -263,14 +268,20 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> {
|
|||||||
fn after_krate(&mut self) -> Result<(), Error> {
|
fn after_krate(&mut self) -> Result<(), Error> {
|
||||||
debug!("Done with crate");
|
debug!("Done with crate");
|
||||||
|
|
||||||
|
debug!("Adding Primitve impls");
|
||||||
for primitive in Rc::clone(&self.cache).primitive_locations.values() {
|
for primitive in Rc::clone(&self.cache).primitive_locations.values() {
|
||||||
self.get_impls(*primitive);
|
self.get_impls(*primitive);
|
||||||
}
|
}
|
||||||
|
|
||||||
let e = ExternalCrate { crate_num: LOCAL_CRATE };
|
let e = ExternalCrate { crate_num: LOCAL_CRATE };
|
||||||
|
|
||||||
|
// FIXME(adotinthevoid): Remove this, as it's not consistant with not
|
||||||
|
// inlining foreign items.
|
||||||
|
let foreign_trait_items = self.get_trait_items();
|
||||||
let mut index = (*self.index).clone().into_inner();
|
let mut index = (*self.index).clone().into_inner();
|
||||||
index.extend(self.get_trait_items());
|
index.extend(foreign_trait_items);
|
||||||
|
|
||||||
|
debug!("Constructing Output");
|
||||||
// This needs to be the default HashMap for compatibility with the public interface for
|
// This needs to be the default HashMap for compatibility with the public interface for
|
||||||
// rustdoc-json-types
|
// rustdoc-json-types
|
||||||
#[allow(rustc::default_hash_types)]
|
#[allow(rustc::default_hash_types)]
|
||||||
|
7
src/test/rustdoc-json/traits/uses_extern_trait.rs
Normal file
7
src/test/rustdoc-json/traits/uses_extern_trait.rs
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#![no_std]
|
||||||
|
pub fn drop_default<T: core::default::Default>(_x: T) {}
|
||||||
|
|
||||||
|
// FIXME(adotinthevoid): Theses shouldn't be here
|
||||||
|
// @has "$.index[*][?(@.name=='Debug')]"
|
||||||
|
// @set Debug_fmt = "$.index[*][?(@.name=='Debug')].inner.items[*]"
|
||||||
|
// @has "$.index[*][?(@.name=='fmt')].id" $Debug_fmt
|
Loading…
Reference in New Issue
Block a user