Skip to content

Commit 968740a

Browse files
authored
Rollup merge of #75318 - jyn514:primitive, r=manishearth
Resolve `char` as a primitive even if there is a module in scope Closes #58699. r? @Manishearth
2 parents df2da46 + b11e2f2 commit 968740a

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/librustdoc/passes/collect_intra_doc_links.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,11 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
217217
return Ok((res, Some(path_str.to_owned())));
218218
}
219219
Res::Def(DefKind::Mod, _) => {
220-
// This resolved to a module, but if we were passed `type@`,
221-
// we want primitive types to take precedence instead.
222-
if disambiguator == Some(Disambiguator::Namespace(Namespace::TypeNS)) {
220+
// This resolved to a module, but we want primitive types to take precedence instead.
221+
if matches!(
222+
disambiguator,
223+
None | Some(Disambiguator::Namespace(Namespace::TypeNS))
224+
) {
223225
if let Some(prim) = is_primitive(path_str, ns) {
224226
if extra_fragment.is_some() {
225227
return Err(ErrorKind::AnchorFailure(AnchorFailure::Primitive));

src/test/rustdoc/intra-link-prim-precedence.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,10 @@ pub mod char {}
88
pub struct MyString;
99

1010
/// See also [char]
11-
// @has intra_link_prim_precedence/struct.MyString2.html '//a/@href' 'intra_link_prim_precedence/char/index.html'
11+
// @has intra_link_prim_precedence/struct.MyString2.html '//a/@href' 'https://doc.rust-lang.org/nightly/std/primitive.char.html'
1212
pub struct MyString2;
13+
14+
/// See also [crate::char] and [mod@char]
15+
// @has intra_link_prim_precedence/struct.MyString3.html '//*[@href="../intra_link_prim_precedence/char/index.html"]' 'crate::char'
16+
// @has - '//*[@href="../intra_link_prim_precedence/char/index.html"]' 'mod@char'
17+
pub struct MyString3;

0 commit comments

Comments
 (0)