@@ -24,7 +24,7 @@ pub struct Foo4;
2424pub struct Bar ;
2525```
2626
27- Unlike normal markdown , ` [bar][Bar] ` syntax is also supported without needing a
27+ Unlike normal Markdown , ` [bar][Bar] ` syntax is also supported without needing a
2828` [Bar]: ... ` reference link, and links are case-sensitive.
2929
3030Backticks around the link will be stripped, so `` [`Option`] `` will correctly
@@ -37,14 +37,14 @@ You can refer to anything in scope, and use paths, including `Self`, `self`, `su
3737trait implementations] [ #79682 ] . Rustdoc also supports linking to the following primitives, which
3838have no path and cannot be imported:
3939
40- - [ ` slice ` ] ( https://doc.rust-lang.org /std/primitive.slice.html)
41- - [ ` array ` ] ( https://doc.rust-lang.org /std/primitive.array.html)
42- - [ ` tuple ` ] ( https://doc.rust-lang.org /std/primitive.tuple.html)
43- - [ ` unit ` ] ( https://doc.rust-lang.org /std/primitive.unit.html)
44- - [ ` fn ` ] ( https://doc.rust-lang.org /std/primitive.fn.html)
45- - [ ` pointer ` ] ( https://doc.rust-lang.org /std/primitive.pointer.html) , ` * ` , ` *const ` , or ` *mut `
46- - [ ` reference ` ] ( https://doc.rust-lang.org /std/primitive.reference.html) , ` & ` , or ` &mut `
47- - [ ` never ` ] ( https://doc.rust-lang.org /std/primitive.never.html) or ` ! `
40+ - [ ` slice ` ] ( ../.. /std/primitive.slice.html)
41+ - [ ` array ` ] ( ../.. /std/primitive.array.html)
42+ - [ ` tuple ` ] ( ../.. /std/primitive.tuple.html)
43+ - [ ` unit ` ] ( ../.. /std/primitive.unit.html)
44+ - [ ` fn ` ] ( ../.. /std/primitive.fn.html)
45+ - [ ` pointer ` ] ( ../.. /std/primitive.pointer.html) , ` * ` , ` *const ` , or ` *mut `
46+ - [ ` reference ` ] ( ../.. /std/primitive.reference.html) , ` & ` , or ` &mut `
47+ - [ ` never ` ] ( ../.. /std/primitive.never.html) or ` ! `
4848
4949[ #79682 ] : https://github.com/rust-lang/rust/pull/79682
5050
@@ -83,10 +83,8 @@ struct MySpecialFormatter;
8383## Namespaces and Disambiguators
8484
8585Paths in Rust have three namespaces: type, value, and macro. Item names must be unique within
86- their namespace, but can overlap with items outside of their namespace. In case of ambiguity,
87- rustdoc will warn about the ambiguity and ask you to disambiguate, which can be done by using a
88- prefix like ` struct@ ` , ` enum@ ` , ` type@ ` , ` trait@ ` , ` union@ ` , ` const@ ` , ` static@ ` , ` value@ ` ,
89- ` fn@ ` , ` function@ ` , ` mod@ ` , ` module@ ` , ` method@ ` , ` prim@ ` , ` primitive@ ` , ` macro@ ` , or ` derive@ ` :
86+ their namespace, but can overlap with items in other namespaces. In case of ambiguity,
87+ rustdoc will warn about the ambiguity and ask you to disambiguate.
9088
9189``` rust
9290/// See also: [`Foo`](struct@Foo)
@@ -98,30 +96,48 @@ struct Foo {}
9896fn Foo () {}
9997```
10098
99+ The following prefixes can be used:
100+
101+ - ` struct@ `
102+ - ` enum@ `
103+ - ` type@ `
104+ - ` trait@ `
105+ - ` union@ `
106+ - ` const@ `
107+ - ` static@ `
108+ - ` value@ `
109+ - ` fn@ ` / ` function@ ` / ` method@ `
110+ - ` mod@ ` / ` module@ `
111+ - ` prim@ ` / ` primitive@ `
112+ - ` macro@ `
113+ - ` derive@ `
114+
101115These prefixes will be stripped when displayed in the documentation, so ` [struct@Foo] `
102116will be rendered as ` Foo ` .
103117
104118You can also disambiguate for functions by adding ` () ` after the function name,
105119or for macros by adding ` ! ` after the macro name:
106120
107121``` rust
108- /// See also: [`Foo`](struct@Foo)
109- struct Bar ;
122+ /// This is different from [`foo!`]
123+ fn foo () {}
110124
111- /// This is different from [`Foo ()`]
112- struct Foo {}
113-
114- fn Foo () { }
125+ /// This is different from [`foo ()`]
126+ macro_rules! foo {
127+ () => {}
128+ }
115129```
116130
117131## Warnings, re-exports, and scoping
118132
119- Links are resolved in the current module scope, even when re-exported. If a link from another
120- crate fails to resolve, no warning is given.
133+ Links are resolved in the scope of the module where the item is defined, even
134+ when the item is re-exported. If a link from another crate fails to resolve, no
135+ warning is given.
121136
122- When re-exporting an item, rustdoc allows additional documentation to it. That documentation will
123- be resolved in the new scope, not the original, allowing you to link to items in the current
124- crate. The new links will still give a warning if they fail to resolve.
137+ When re-exporting an item, rustdoc allows adding additional documentation to it.
138+ That additional documentation will be resolved in scope of the re-export, not
139+ the original, allowing you to link to items in the new crate. The new links
140+ will still give a warning if they fail to resolve.
125141
126142``` rust
127143/// See also [foo()]
@@ -130,7 +146,7 @@ pub use std::process::Command;
130146pub fn foo () {}
131147```
132148
133- This is especially useful for proc-macros, which must always be in their own dedicated crate.
149+ This is especially useful for proc-macros, which must always be defined in their own dedicated crate.
134150
135151Note: Because of how ` macro_rules! ` macros are scoped in Rust, the intra-doc links of a
136152` macro_rules! ` macro will be resolved [ relative to the crate root] [ #72243 ] , as opposed to the
0 commit comments