intra-doc links: Resolve modules in type namespace

This commit is contained in:
Manish Goregaokar 2020-07-17 11:04:31 -07:00
parent 3014f23ddd
commit fe98de2a8e

View file

@ -584,25 +584,18 @@ impl<'a, 'tcx> DocFolder for LinkCollector<'a, 'tcx> {
let (res, fragment) = { let (res, fragment) = {
let mut kind = None; let mut kind = None;
let mut disambiguator = None; let mut disambiguator = None;
path_str = if let Some(prefix) = ["struct@", "enum@", "type@", "trait@", "union@"] path_str = if let Some(prefix) =
.iter() ["struct@", "enum@", "type@", "trait@", "union@", "module@", "mod@"]
.find(|p| link.starts_with(**p)) .iter()
.find(|p| link.starts_with(**p))
{ {
kind = Some(TypeNS); kind = Some(TypeNS);
disambiguator = Some(&prefix[..prefix.len() - 1]); disambiguator = Some(&prefix[..prefix.len() - 1]);
link.trim_start_matches(prefix) link.trim_start_matches(prefix)
} else if let Some(prefix) = [ } else if let Some(prefix) =
"const@", ["const@", "static@", "value@", "function@", "fn@", "method@"]
"static@", .iter()
"value@", .find(|p| link.starts_with(**p))
"function@",
"mod@",
"fn@",
"module@",
"method@",
]
.iter()
.find(|p| link.starts_with(**p))
{ {
kind = Some(ValueNS); kind = Some(ValueNS);
disambiguator = Some(&prefix[..prefix.len() - 1]); disambiguator = Some(&prefix[..prefix.len() - 1]);