mirror of https://github.com/rust-lang/rust.git
fix rustdoc wrt builtin impls switch
This commit is contained in:
parent
a6153e8218
commit
ee62514b16
|
@ -1033,11 +1033,13 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
|
|||
}
|
||||
|
||||
/// Iterates over the language items in the given crate.
|
||||
fn get_lang_items(self) -> impl Iterator<Item = (DefId, usize)> + 'a {
|
||||
self.root
|
||||
.lang_items
|
||||
.decode(self)
|
||||
.map(move |(def_index, index)| (self.local_def_id(def_index), index))
|
||||
fn get_lang_items(self, tcx: TyCtxt<'tcx>) -> &'tcx [(DefId, usize)] {
|
||||
tcx.arena.alloc_from_iter(
|
||||
self.root
|
||||
.lang_items
|
||||
.decode(self)
|
||||
.map(move |(def_index, index)| (self.local_def_id(def_index), index)),
|
||||
)
|
||||
}
|
||||
|
||||
/// Iterates over the diagnostic items in the given crate.
|
||||
|
@ -1343,6 +1345,13 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
|
|||
})
|
||||
}
|
||||
|
||||
fn get_all_incoherent_impls(self) -> impl Iterator<Item = DefId> + 'a {
|
||||
self.cdata
|
||||
.incoherent_impls
|
||||
.values()
|
||||
.flat_map(move |impls| impls.decode(self).map(move |idx| self.local_def_id(idx)))
|
||||
}
|
||||
|
||||
fn get_incoherent_impls(self, tcx: TyCtxt<'tcx>, simp: SimplifiedType) -> &'tcx [DefId] {
|
||||
if let Some(impls) = self.cdata.incoherent_impls.get(&simp) {
|
||||
tcx.arena.alloc_from_iter(impls.decode(self).map(|idx| self.local_def_id(idx)))
|
||||
|
|
|
@ -223,7 +223,7 @@ provide! { <'tcx> tcx, def_id, other, cdata,
|
|||
tcx.arena.alloc_slice(&result)
|
||||
}
|
||||
defined_lib_features => { cdata.get_lib_features(tcx) }
|
||||
defined_lang_items => { tcx.arena.alloc_from_iter(cdata.get_lang_items()) }
|
||||
defined_lang_items => { cdata.get_lang_items(tcx) }
|
||||
diagnostic_items => { cdata.get_diagnostic_items() }
|
||||
missing_lang_items => { cdata.get_missing_lang_items(tcx) }
|
||||
|
||||
|
@ -523,9 +523,12 @@ impl CStore {
|
|||
self.get_crate_data(cnum).get_inherent_impls()
|
||||
}
|
||||
|
||||
/// Decodes all lang items in the crate (for rustdoc).
|
||||
pub fn lang_items_untracked(&self, cnum: CrateNum) -> impl Iterator<Item = DefId> + '_ {
|
||||
self.get_crate_data(cnum).get_lang_items().map(|(def_id, _)| def_id)
|
||||
/// Decodes all incoherent inherent impls in the crate (for rustdoc).
|
||||
pub fn incoherent_impls_in_crate_untracked(
|
||||
&self,
|
||||
cnum: CrateNum,
|
||||
) -> impl Iterator<Item = DefId> + '_ {
|
||||
self.get_crate_data(cnum).get_all_incoherent_impls()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -113,7 +113,8 @@ 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));
|
||||
let all_incoherent_impls =
|
||||
Vec::from_iter(self.resolver.cstore().incoherent_impls_in_crate_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
|
||||
|
@ -137,7 +138,7 @@ impl IntraLinkCrateLoader<'_, '_> {
|
|||
self.add_traits_in_parent_scope(impl_def_id);
|
||||
}
|
||||
}
|
||||
for def_id in all_lang_items {
|
||||
for def_id in all_incoherent_impls {
|
||||
self.add_traits_in_parent_scope(def_id);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// no-prefer-dynamic
|
||||
|
||||
#![feature(lang_items)]
|
||||
|
||||
#![feature(lang_items, rustc_attrs)]
|
||||
#![crate_type = "rlib"]
|
||||
#![no_std]
|
||||
|
||||
|
@ -15,9 +14,9 @@ impl core::ops::Deref for DerefsToF64 {
|
|||
}
|
||||
|
||||
mod inner {
|
||||
#[lang = "f64_runtime"]
|
||||
impl f64 {
|
||||
/// [f64::clone]
|
||||
#[rustc_allow_incoherent_impl]
|
||||
pub fn method() {}
|
||||
}
|
||||
}
|
|
@ -1,12 +1,12 @@
|
|||
#![feature(no_core, lang_items, rustdoc_internals)]
|
||||
#![feature(no_core, lang_items, rustdoc_internals, rustc_attrs)]
|
||||
#![no_core]
|
||||
#![rustc_coherence_is_core]
|
||||
#![crate_type="rlib"]
|
||||
|
||||
#[doc(primitive = "char")]
|
||||
/// Some char docs
|
||||
mod char {}
|
||||
|
||||
#[lang = "char"]
|
||||
impl char {
|
||||
pub fn len_utf8(self) -> usize {
|
||||
42
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
// 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
|
||||
// aux-build:extern-builtin-type-impl-dep.rs
|
||||
|
||||
#![no_std]
|
||||
|
||||
extern crate extern_lang_item_impl_dep;
|
||||
extern crate extern_builtin_type_impl_dep;
|
||||
|
||||
pub use extern_lang_item_impl_dep::DerefsToF64;
|
||||
pub use extern_builtin_type_impl_dep::DerefsToF64;
|
|
@ -1,6 +1,7 @@
|
|||
#![deny(rustdoc::broken_intra_doc_links)]
|
||||
#![feature(no_core, lang_items, rustdoc_internals)]
|
||||
#![feature(no_core, lang_items, rustc_attrs, rustdoc_internals)]
|
||||
#![no_core]
|
||||
#![rustc_coherence_is_core]
|
||||
#![crate_type = "rlib"]
|
||||
|
||||
// @has prim_methods_local/index.html
|
||||
|
@ -12,7 +13,6 @@
|
|||
#[doc(primitive = "char")]
|
||||
mod char {}
|
||||
|
||||
#[lang = "char"]
|
||||
impl char {
|
||||
pub fn len_utf8(self) -> usize {
|
||||
42
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
#![feature(lang_items)]
|
||||
#![feature(rustc_attrs)]
|
||||
#![feature(rustdoc_internals)]
|
||||
#![no_std]
|
||||
|
||||
pub mod str {
|
||||
#![doc(primitive = "str")]
|
||||
|
||||
#[lang = "str_alloc"]
|
||||
impl str {
|
||||
// @has search-index.js foo
|
||||
#[rustc_allow_incoherent_impl]
|
||||
pub fn foo(&self) {}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue