Skip to content

Commit 7e16025

Browse files
authored
Rollup merge of #80885 - camelid:intra-doc-str-ref, r=jyn514
rustdoc: Resolve `&str` as `str` People almost always are referring to `&str`, not `str`, so this will save a manual link resolve in many cases. Note that we already accept `&` (resolves to `reference`) in intra-doc links, so this shouldn't cause breakage. r? `@jyn514`
2 parents fd02c83 + 2750e36 commit 7e16025

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/librustdoc/passes/collect_intra_doc_links.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2085,7 +2085,7 @@ fn resolve_primitive(path_str: &str, ns: Namespace) -> Option<Res> {
20852085
"f64" => F64,
20862086
"char" => Char,
20872087
"bool" | "true" | "false" => Bool,
2088-
"str" => Str,
2088+
"str" | "&str" => Str,
20892089
// See #80181 for why these don't have symbols associated.
20902090
"slice" => Slice,
20912091
"array" => Array,

src/test/rustdoc/intra-doc/non-path-primitives.rs

+9
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@
88
// @has - '//a[@href="https://doc.rust-lang.org/nightly/std/primitive.array.html#method.map"]' 'array::map'
99
//! [array::map]
1010
11+
// @has - '//a[@href="https://doc.rust-lang.org/nightly/std/primitive.str.html"]' 'owned str'
12+
// @has - '//a[@href="https://doc.rust-lang.org/nightly/std/primitive.str.html"]' 'str ref'
13+
// @has - '//a[@href="https://doc.rust-lang.org/nightly/std/primitive.str.html#method.is_empty"]' 'str::is_empty'
14+
// @has - '//a[@href="https://doc.rust-lang.org/nightly/std/primitive.str.html#method.len"]' '&str::len'
15+
//! [owned str][str]
16+
//! [str ref][&str]
17+
//! [str::is_empty]
18+
//! [&str::len]
19+
1120
// @has - '//a[@href="https://doc.rust-lang.org/nightly/std/primitive.pointer.html#method.is_null"]' 'pointer::is_null'
1221
// @has - '//a[@href="https://doc.rust-lang.org/nightly/std/primitive.pointer.html#method.is_null"]' '*const::is_null'
1322
// @has - '//a[@href="https://doc.rust-lang.org/nightly/std/primitive.pointer.html#method.is_null"]' '*mut::is_null'

0 commit comments

Comments
 (0)