mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-28 02:57:37 +00:00
rustdoc: Do not expect doc(primitive)
modules to always exist
This commit is contained in:
parent
8be3ce9056
commit
c65f3db2d9
@ -80,10 +80,10 @@ impl Res {
|
||||
}
|
||||
}
|
||||
|
||||
fn def_id(self, tcx: TyCtxt<'_>) -> DefId {
|
||||
fn def_id(self, tcx: TyCtxt<'_>) -> Option<DefId> {
|
||||
match self {
|
||||
Res::Def(_, id) => id,
|
||||
Res::Primitive(prim) => *PrimitiveType::primitive_locations(tcx).get(&prim).unwrap(),
|
||||
Res::Def(_, id) => Some(id),
|
||||
Res::Primitive(prim) => PrimitiveType::primitive_locations(tcx).get(&prim).copied(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -1127,10 +1127,10 @@ impl LinkCollector<'_, '_> {
|
||||
}
|
||||
}
|
||||
|
||||
Some(ItemLink {
|
||||
res.def_id(self.cx.tcx).map(|page_id| ItemLink {
|
||||
link: ori_link.link.clone(),
|
||||
link_text: link_text.clone(),
|
||||
page_id: res.def_id(self.cx.tcx),
|
||||
page_id,
|
||||
fragment,
|
||||
})
|
||||
}
|
||||
|
15
src/test/rustdoc/intra-doc/no-doc-primitive.rs
Normal file
15
src/test/rustdoc/intra-doc/no-doc-primitive.rs
Normal file
@ -0,0 +1,15 @@
|
||||
// Crate tree without a `doc(primitive)` module for primitive type linked to by a doc link.
|
||||
|
||||
#![deny(rustdoc::broken_intra_doc_links)]
|
||||
#![feature(no_core, lang_items, rustc_attrs)]
|
||||
#![no_core]
|
||||
#![rustc_coherence_is_core]
|
||||
#![crate_type = "rlib"]
|
||||
|
||||
// @has no_doc_primitive/index.html
|
||||
//! A [`char`] and its [`char::len_utf8`].
|
||||
impl char {
|
||||
pub fn len_utf8(self) -> usize {
|
||||
42
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user