rustdoc: Collect traits in scope for lang items
This commit is contained in:
parent
f838a425e3
commit
0da7adc828
5 changed files with 55 additions and 8 deletions
|
|
@ -118,6 +118,7 @@ impl IntraLinkCrateLoader<'_, '_> {
|
|||
Vec::from_iter(self.resolver.cstore().trait_impls_in_crate_untracked(cnum));
|
||||
let all_inherent_impls =
|
||||
Vec::from_iter(self.resolver.cstore().inherent_impls_in_crate_untracked(cnum));
|
||||
let all_lang_items = Vec::from_iter(self.resolver.cstore().lang_items_untracked(cnum));
|
||||
|
||||
// Querying traits in scope is expensive so we try to prune the impl and traits lists
|
||||
// using privacy, private traits and impls from other crates are never documented in
|
||||
|
|
@ -141,6 +142,9 @@ impl IntraLinkCrateLoader<'_, '_> {
|
|||
self.add_traits_in_parent_scope(impl_def_id);
|
||||
}
|
||||
}
|
||||
for def_id in all_lang_items {
|
||||
self.add_traits_in_parent_scope(def_id);
|
||||
}
|
||||
|
||||
self.all_traits.extend(all_traits);
|
||||
self.all_trait_impls.extend(all_trait_impls.into_iter().map(|(_, def_id, _)| def_id));
|
||||
|
|
|
|||
|
|
@ -0,0 +1,29 @@
|
|||
// no-prefer-dynamic
|
||||
|
||||
#![feature(lang_items)]
|
||||
|
||||
#![crate_type = "rlib"]
|
||||
#![no_std]
|
||||
|
||||
pub struct DerefsToF64(f64);
|
||||
|
||||
impl core::ops::Deref for DerefsToF64 {
|
||||
type Target = f64;
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
mod inner {
|
||||
#[lang = "f64_runtime"]
|
||||
impl f64 {
|
||||
/// [f64::clone]
|
||||
pub fn method() {}
|
||||
}
|
||||
}
|
||||
|
||||
#[lang = "eh_personality"]
|
||||
fn foo() {}
|
||||
|
||||
#[panic_handler]
|
||||
fn bar(_: &core::panic::PanicInfo) -> ! { loop {} }
|
||||
11
src/test/rustdoc/intra-doc/extern-lang-item-impl.rs
Normal file
11
src/test/rustdoc/intra-doc/extern-lang-item-impl.rs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
// Reexport of a structure that derefs to a type with lang item impls having doc links in their
|
||||
// comments. The doc link points to an associated item, so we check that traits in scope for that
|
||||
// link are populated.
|
||||
|
||||
// aux-build:extern-lang-item-impl-dep.rs
|
||||
|
||||
#![no_std]
|
||||
|
||||
extern crate extern_lang_item_impl_dep;
|
||||
|
||||
pub use extern_lang_item_impl_dep::DerefsToF64;
|
||||
Loading…
Add table
Add a link
Reference in a new issue