44can use them like any other lints by doing this:
55
66``` 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
1110```
1211
12+ Note that, except for ` missing_docs ` , these lints are only available when running ` rustdoc ` , not ` rustc ` .
13+
1314Here is the list of the lints provided by ` rustdoc ` :
1415
1516## broken_intra_doc_links
@@ -51,7 +52,7 @@ warning: `Foo` is both an enum and a function
51521 | /// [`Foo`]
5253 | ^^^^^ ambiguous link
5354 |
54- = note: `#[warn(broken_intra_doc_links)]` on by default
55+ = note: `#[warn(rustdoc:: broken_intra_doc_links)]` on by default
5556help: to link to the enum, prefix with the item type
5657 |
57581 | /// [`enum@Foo`]
@@ -83,7 +84,7 @@ warning: public documentation for `public` links to private item `private`
83841 | /// [private]
8485 | ^^^^^^^ this item is private
8586 |
86- = note: `#[warn(private_intra_doc_links)]` on by default
87+ = note: `#[warn(rustdoc:: private_intra_doc_links)]` on by default
8788 = note: this link will resolve properly if you pass `--document-private-items`
8889```
8990
@@ -97,7 +98,7 @@ warning: public documentation for `public` links to private item `private`
97981 | /// [private]
9899 | ^^^^^^^ this item is private
99100 |
100- = note: `#[warn(private_intra_doc_links)]` on by default
101+ = note: `#[warn(rustdoc:: private_intra_doc_links)]` on by default
101102 = note: this link resolves only because you passed `--document-private-items`, but will break without
102103```
103104
@@ -125,13 +126,15 @@ warning: missing documentation for a function
125126 | ^^^^^^^^^^^^^^^^^^^^^
126127```
127128
129+ Note that unlike other rustdoc lints, this lint is also available from ` rustc ` directly.
130+
128131## missing_crate_level_docs
129132
130133This lint is ** allowed by default** . It detects if there is no documentation
131134at the crate root. For example:
132135
133136``` rust
134- #![warn(missing_crate_level_docs)]
137+ #![warn(rustdoc :: missing_crate_level_docs)]
135138```
136139
137140This will generate the following warning:
@@ -155,7 +158,7 @@ This lint is **allowed by default** and is **nightly-only**. It detects when a d
155158is missing a code example. For example:
156159
157160``` rust
158- #![warn(missing_doc_code_examples)]
161+ #![warn(rustdoc :: missing_doc_code_examples)]
159162
160163/// There is no code example!
161164pub fn no_code_example () {}
@@ -191,7 +194,7 @@ This lint is **allowed by default**. It detects documentation tests when they
191194are on a private item. For example:
192195
193196``` rust
194- #![warn(private_doc_tests)]
197+ #![warn(rustdoc :: private_doc_tests)]
195198
196199mod foo {
197200 /// private doc test
@@ -245,7 +248,7 @@ warning: unknown attribute `should-panic`. Did you mean `should_panic`?
2452485 | | /// ```
246249 | |_______^
247250 |
248- = note: `#[warn(invalid_codeblock_attributes)]` on by default
251+ = note: `#[warn(rustdoc:: invalid_codeblock_attributes)]` on by default
249252 = 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
250253```
251254
@@ -258,7 +261,7 @@ This lint is **allowed by default** and is **nightly-only**. It detects unclosed
258261or invalid HTML tags. For example:
259262
260263``` rust
261- #![warn(invalid_html_tags)]
264+ #![warn(rustdoc :: invalid_html_tags)]
262265
263266/// <h1>
264267/// </script>
@@ -275,7 +278,11 @@ warning: unopened HTML tag `script`
2752782 | | /// </script>
276279 | |_____________^
277280 |
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+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^
279286
280287warning: unclosed HTML tag `h1`
281288 --> foo.rs:1:1
@@ -310,7 +317,7 @@ warning: this URL is not a hyperlink
3103171 | /// http://example.org
311318 | ^^^^^^^^^^^^^^^^^^ help: use an automatic link instead: `<http://example.org>`
312319 |
313- = note: `#[warn(non_autolinks)]` on by default
320+ = note: `#[warn(rustdoc:: non_autolinks)]` on by default
314321
315322warning: unneeded long form for URL
316323 --> foo.rs:2:5
0 commit comments