@@ -25,7 +25,7 @@ pub struct Bar;
2525```
2626
2727Unlike normal Markdown, ` [bar][Bar] ` syntax is also supported without needing a
28- ` [Bar]: ... ` reference link, and links are case-sensitive .
28+ ` [Bar]: ... ` reference link.
2929
3030Backticks around the link will be stripped, so `` [`Option`] `` will correctly
3131link to ` Option ` .
@@ -34,17 +34,8 @@ link to `Option`.
3434
3535You can refer to anything in scope, and use paths, including ` Self ` , ` self ` , ` super ` , and
3636` crate ` . Associated items (functions, types, and constants) are supported, but [ not for blanket
37- trait implementations] [ #79682 ] . Rustdoc also supports linking to the following primitives, which
38- have no path and cannot be imported:
39-
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 ` ! `
37+ trait implementations] [ #79682 ] . Rustdoc also supports linking to all primitives listed in
38+ [ the standard library documentation] ( ../std/index.html#primitives ) .
4839
4940[ #79682 ] : https://github.com/rust-lang/rust/pull/79682
5041
@@ -84,7 +75,7 @@ struct MySpecialFormatter;
8475
8576Paths in Rust have three namespaces: type, value, and macro. Item names must be unique within
8677their 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 .
78+ rustdoc will warn about the ambiguity and suggest a disambiguator .
8879
8980``` rust
9081/// See also: [`Foo`](struct@Foo)
@@ -96,24 +87,8 @@ struct Foo {}
9687fn Foo () {}
9788```
9889
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-
115- These prefixes will be stripped when displayed in the documentation, so ` [struct@Foo] `
116- will be rendered as ` Foo ` .
90+ These prefixes will be stripped when displayed in the documentation, so ` [struct@Foo] ` will be
91+ rendered as ` Foo ` .
11792
11893You can also disambiguate for functions by adding ` () ` after the function name,
11994or for macros by adding ` ! ` after the macro name:
@@ -134,6 +109,15 @@ Links are resolved in the scope of the module where the item is defined, even
134109when the item is re-exported. If a link from another crate fails to resolve, no
135110warning is given.
136111
112+ ``` rust
113+ mod inner {
114+ /// Link to [f()]
115+ pub struct S ;
116+ pub fn f () {}
117+ }
118+ pub use inner :: S ; // the link to `f` will still resolve correctly
119+ ```
120+
137121When re-exporting an item, rustdoc allows adding additional documentation to it.
138122That additional documentation will be resolved in the scope of the re-export, not
139123the original, allowing you to link to items in the new crate. The new links
@@ -154,8 +138,6 @@ module it is defined in.
154138
155139If links do not look 'sufficiently like' an intra-doc link, they will be ignored and no warning
156140will be given, even if the link fails to resolve. For example, any link containing ` / ` or ` [] `
157- characters will be ignored. You can see the full criteria for 'sufficiently like' in [ the source
158- code] .
141+ characters will be ignored.
159142
160143[ #72243 ] : https://github.com/rust-lang/rust/issues/72243
161- [ the source code ] : https://github.com/rust-lang/rust/blob/34628e5b533d35840b61c5db0665cf7633ed3c5a/src/librustdoc/passes/collect_intra_doc_links.rs#L982
0 commit comments