Skip to content

Commit afea84f

Browse files
authored
Rollup merge of #110348 - GuillaumeGomez:disambiguators-suffixes-rustdoc-book, r=Manishearth
Add list of supported disambiguators and suffixes for intra-doc links in the rustdoc book This information is otherwise only provided in case an error occurs, which isn't great. r? ```@notriddle```
2 parents 06d403d + 1531c95 commit afea84f

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/doc/rustdoc/src/write-documentation/linking-to-items-by-name.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,16 @@ fn Foo() {}
8888
```
8989

9090
These prefixes will be stripped when displayed in the documentation, so `[struct@Foo]` will be
91-
rendered as `Foo`.
91+
rendered as `Foo`. The following prefixes are available: `struct`, `enum`, `trait`, `union`,
92+
`mod`, `module`, `const`, `constant`, `fn`, `function`, `method`, `derive`, `type`, `value`,
93+
`macro`, `prim` or `primitive`.
9294

9395
You can also disambiguate for functions by adding `()` after the function name,
94-
or for macros by adding `!` after the macro name:
96+
or for macros by adding `!` after the macro name. The macro `!` can be followed by `()`, `{}`,
97+
or `[]`. Example:
9598

9699
```rust
97-
/// This is different from [`foo!`]
100+
/// This is different from [`foo!()`].
98101
fn foo() {}
99102

100103
/// This is different from [`foo()`]

src/librustdoc/passes/collect_intra_doc_links.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1419,6 +1419,7 @@ impl Disambiguator {
14191419
if let Some(idx) = link.find('@') {
14201420
let (prefix, rest) = link.split_at(idx);
14211421
let d = match prefix {
1422+
// If you update this list, please also update the relevant rustdoc book section!
14221423
"struct" => Kind(DefKind::Struct),
14231424
"enum" => Kind(DefKind::Enum),
14241425
"trait" => Kind(DefKind::Trait),
@@ -1437,6 +1438,7 @@ impl Disambiguator {
14371438
Ok(Some((d, &rest[1..], &rest[1..])))
14381439
} else {
14391440
let suffixes = [
1441+
// If you update this list, please also update the relevant rustdoc book section!
14401442
("!()", DefKind::Macro(MacroKind::Bang)),
14411443
("!{}", DefKind::Macro(MacroKind::Bang)),
14421444
("![]", DefKind::Macro(MacroKind::Bang)),

0 commit comments

Comments
 (0)