Skip to content

Commit c587386

Browse files
authored
Rollup merge of #74452 - Manishearth:module-type-ns, r=jyn514
intra-doc links: resolve modules in the type namespace Fixes #62830 Modules actually live in the type namespace, not all three, and it's not possible to clash a type with a module.
2 parents ff1c53f + 69dab50 commit c587386

File tree

2 files changed

+26
-15
lines changed

2 files changed

+26
-15
lines changed

src/librustdoc/passes/collect_intra_doc_links.rs

+8-15
Original file line numberDiff line numberDiff line change
@@ -584,25 +584,18 @@ impl<'a, 'tcx> DocFolder for LinkCollector<'a, 'tcx> {
584584
let (res, fragment) = {
585585
let mut kind = None;
586586
let mut disambiguator = None;
587-
path_str = if let Some(prefix) = ["struct@", "enum@", "type@", "trait@", "union@"]
588-
.iter()
589-
.find(|p| link.starts_with(**p))
587+
path_str = if let Some(prefix) =
588+
["struct@", "enum@", "type@", "trait@", "union@", "module@", "mod@"]
589+
.iter()
590+
.find(|p| link.starts_with(**p))
590591
{
591592
kind = Some(TypeNS);
592593
disambiguator = Some(&prefix[..prefix.len() - 1]);
593594
link.trim_start_matches(prefix)
594-
} else if let Some(prefix) = [
595-
"const@",
596-
"static@",
597-
"value@",
598-
"function@",
599-
"mod@",
600-
"fn@",
601-
"module@",
602-
"method@",
603-
]
604-
.iter()
605-
.find(|p| link.starts_with(**p))
595+
} else if let Some(prefix) =
596+
["const@", "static@", "value@", "function@", "fn@", "method@"]
597+
.iter()
598+
.find(|p| link.starts_with(**p))
606599
{
607600
kind = Some(ValueNS);
608601
disambiguator = Some(&prefix[..prefix.len() - 1]);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// ignore-tidy-linelength
2+
3+
#![deny(intra_doc_link_resolution_failure)]
4+
5+
6+
pub fn foo() {
7+
8+
}
9+
10+
pub mod foo {}
11+
// @has intra_doc_link_mod_ambiguity/struct.A.html '//a/@href' '../intra_doc_link_mod_ambiguity/foo/index.html'
12+
/// Module is [`module@foo`]
13+
pub struct A;
14+
15+
16+
// @has intra_doc_link_mod_ambiguity/struct.B.html '//a/@href' '../intra_doc_link_mod_ambiguity/fn.foo.html'
17+
/// Function is [`fn@foo`]
18+
pub struct B;

0 commit comments

Comments
 (0)