4
4
can use them like any other lints by doing this:
5
5
6
6
``` rust
7
- #![allow(missing_docs)] // allows the lint, no diagnostics will be reported
8
- #![warn(missing_docs)] // warn if there are missing docs
9
- #![deny(missing_docs)] // error if there are missing docs
10
- # // ! Crate docs.
7
+ #![allow(rustdoc:: broken_intra_doc_links)] // allows the lint, no diagnostics will be reported
8
+ #![warn(rustdoc:: broken_intra_doc_links)] // warn if there are broken intra-doc links
9
+ #![deny(rustdoc:: broken_intra_doc_links)] // error if there are broken intra-doc links
11
10
```
12
11
12
+ Note that, except for ` missing_docs ` , these lints are only available when running ` rustdoc ` , not ` rustc ` .
13
+
13
14
Here is the list of the lints provided by ` rustdoc ` :
14
15
15
16
## broken_intra_doc_links
@@ -51,7 +52,7 @@ warning: `Foo` is both an enum and a function
51
52
1 | /// [`Foo`]
52
53
| ^^^^^ ambiguous link
53
54
|
54
- = note: `#[warn(broken_intra_doc_links)]` on by default
55
+ = note: `#[warn(rustdoc:: broken_intra_doc_links)]` on by default
55
56
help: to link to the enum, prefix with the item type
56
57
|
57
58
1 | /// [`enum@Foo`]
@@ -83,7 +84,7 @@ warning: public documentation for `public` links to private item `private`
83
84
1 | /// [private]
84
85
| ^^^^^^^ this item is private
85
86
|
86
- = note: `#[warn(private_intra_doc_links)]` on by default
87
+ = note: `#[warn(rustdoc:: private_intra_doc_links)]` on by default
87
88
= note: this link will resolve properly if you pass `--document-private-items`
88
89
```
89
90
@@ -97,7 +98,7 @@ warning: public documentation for `public` links to private item `private`
97
98
1 | /// [private]
98
99
| ^^^^^^^ this item is private
99
100
|
100
- = note: `#[warn(private_intra_doc_links)]` on by default
101
+ = note: `#[warn(rustdoc:: private_intra_doc_links)]` on by default
101
102
= note: this link resolves only because you passed `--document-private-items`, but will break without
102
103
```
103
104
@@ -125,13 +126,15 @@ warning: missing documentation for a function
125
126
| ^^^^^^^^^^^^^^^^^^^^^
126
127
```
127
128
129
+ Note that unlike other rustdoc lints, this lint is also available from ` rustc ` directly.
130
+
128
131
## missing_crate_level_docs
129
132
130
133
This lint is ** allowed by default** . It detects if there is no documentation
131
134
at the crate root. For example:
132
135
133
136
``` rust
134
- #![warn(missing_crate_level_docs)]
137
+ #![warn(rustdoc :: missing_crate_level_docs)]
135
138
```
136
139
137
140
This will generate the following warning:
@@ -155,7 +158,7 @@ This lint is **allowed by default** and is **nightly-only**. It detects when a d
155
158
is missing a code example. For example:
156
159
157
160
``` rust
158
- #![warn(missing_doc_code_examples)]
161
+ #![warn(rustdoc :: missing_doc_code_examples)]
159
162
160
163
/// There is no code example!
161
164
pub fn no_code_example () {}
@@ -191,7 +194,7 @@ This lint is **allowed by default**. It detects documentation tests when they
191
194
are on a private item. For example:
192
195
193
196
``` rust
194
- #![warn(private_doc_tests)]
197
+ #![warn(rustdoc :: private_doc_tests)]
195
198
196
199
mod foo {
197
200
/// private doc test
@@ -245,7 +248,7 @@ warning: unknown attribute `should-panic`. Did you mean `should_panic`?
245
248
5 | | /// ```
246
249
| |_______^
247
250
|
248
- = note: `#[warn(invalid_codeblock_attributes)]` on by default
251
+ = note: `#[warn(rustdoc:: invalid_codeblock_attributes)]` on by default
249
252
= help: the code block will either not be tested if not marked as a rust one or won't fail if it doesn't panic when running
250
253
```
251
254
@@ -258,7 +261,7 @@ This lint is **allowed by default** and is **nightly-only**. It detects unclosed
258
261
or invalid HTML tags. For example:
259
262
260
263
``` rust
261
- #![warn(invalid_html_tags)]
264
+ #![warn(rustdoc :: invalid_html_tags)]
262
265
263
266
/// <h1>
264
267
/// </script>
@@ -275,7 +278,11 @@ warning: unopened HTML tag `script`
275
278
2 | | /// </script>
276
279
| |_____________^
277
280
|
278
- = note: `#[warn(invalid_html_tags)]` on by default
281
+ note: the lint level is defined here
282
+ --> foo.rs:1:9
283
+ |
284
+ 1 | #![warn(rustdoc::invalid_html_tags)]
285
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^
279
286
280
287
warning: unclosed HTML tag `h1`
281
288
--> foo.rs:1:1
@@ -310,7 +317,7 @@ warning: this URL is not a hyperlink
310
317
1 | /// http://example.org
311
318
| ^^^^^^^^^^^^^^^^^^ help: use an automatic link instead: `<http://example.org>`
312
319
|
313
- = note: `#[warn(non_autolinks)]` on by default
320
+ = note: `#[warn(rustdoc:: non_autolinks)]` on by default
314
321
315
322
warning: unneeded long form for URL
316
323
--> foo.rs:2:5
0 commit comments