1
Fork 0

Auto merge of #106316 - camelid:rustdoc-all-only-stable, r=GuillaumeGomez

Only include stable lints in `rustdoc::all` group

Fixes #106289.

Including unstable lints in the lint group produces unintuitive behavior
on stable (see #106289). Meanwhile, if we only included unstable lints
on nightly and not on stable, we could end up with confusing bugs that
were hard to compare across versions of Rust that lacked code changes.

I think that only including stable lints in `rustdoc::all`, no matter
the release channel, is the most intuitive option. Users can then
control unstable lints individually, which is reasonable since they have
to enable the feature gates individually anyway.

r? `@GuillaumeGomez`
This commit is contained in:
bors 2023-02-20 06:37:58 +00:00
commit 7e253a7fb2
8 changed files with 45 additions and 20 deletions

View file

@ -194,7 +194,11 @@ pub(crate) fn register_lints(_sess: &Session, lint_store: &mut LintStore) {
true, true,
"rustdoc::all", "rustdoc::all",
Some("rustdoc"), Some("rustdoc"),
RUSTDOC_LINTS.iter().map(|&lint| LintId::of(lint)).collect(), RUSTDOC_LINTS
.iter()
.filter(|lint| lint.feature_gate.is_none()) // only include stable lints
.map(|&lint| LintId::of(lint))
.collect(),
); );
for lint in &*RUSTDOC_LINTS { for lint in &*RUSTDOC_LINTS {
let name = lint.name_lower(); let name = lint.name_lower();

View file

@ -2,6 +2,7 @@
#![feature(rustdoc_missing_doc_code_examples)] #![feature(rustdoc_missing_doc_code_examples)]
#![deny(missing_docs)] #![deny(missing_docs)]
#![deny(rustdoc::missing_doc_code_examples)]
#![deny(rustdoc::all)] #![deny(rustdoc::all)]
//! ```rust,testharness //! ```rust,testharness

View file

@ -1,5 +1,5 @@
error: missing documentation for a function error: missing documentation for a function
--> $DIR/check-fail.rs:12:1 --> $DIR/check-fail.rs:13:1
| |
LL | pub fn foo() {} LL | pub fn foo() {}
| ^^^^^^^^^^^^ | ^^^^^^^^^^^^
@ -11,7 +11,7 @@ LL | #![deny(missing_docs)]
| ^^^^^^^^^^^^ | ^^^^^^^^^^^^
error: missing code example in this documentation error: missing code example in this documentation
--> $DIR/check-fail.rs:12:1 --> $DIR/check-fail.rs:13:1
| |
LL | pub fn foo() {} LL | pub fn foo() {}
| ^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^
@ -19,12 +19,11 @@ LL | pub fn foo() {}
note: the lint level is defined here note: the lint level is defined here
--> $DIR/check-fail.rs:5:9 --> $DIR/check-fail.rs:5:9
| |
LL | #![deny(rustdoc::all)] LL | #![deny(rustdoc::missing_doc_code_examples)]
| ^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: `#[deny(rustdoc::missing_doc_code_examples)]` implied by `#[deny(rustdoc::all)]`
error: unknown attribute `testharness`. Did you mean `test_harness`? error: unknown attribute `testharness`. Did you mean `test_harness`?
--> $DIR/check-fail.rs:7:1 --> $DIR/check-fail.rs:8:1
| |
LL | / //! ```rust,testharness LL | / //! ```rust,testharness
LL | | LL | |
@ -33,10 +32,15 @@ LL | | //! ```
| |_______^ | |_______^
| |
= help: the code block will either not be tested if not marked as a rust one or the code will be wrapped inside a main function = help: the code block will either not be tested if not marked as a rust one or the code will be wrapped inside a main function
note: the lint level is defined here
--> $DIR/check-fail.rs:6:9
|
LL | #![deny(rustdoc::all)]
| ^^^^^^^^^^^^
= note: `#[deny(rustdoc::invalid_codeblock_attributes)]` implied by `#[deny(rustdoc::all)]` = note: `#[deny(rustdoc::invalid_codeblock_attributes)]` implied by `#[deny(rustdoc::all)]`
error: unknown attribute `testharness`. Did you mean `test_harness`? error: unknown attribute `testharness`. Did you mean `test_harness`?
--> $DIR/check-fail.rs:16:1 --> $DIR/check-fail.rs:17:1
| |
LL | / /// hello LL | / /// hello
LL | | LL | |

View file

@ -7,6 +7,7 @@
//~^^ WARN //~^^ WARN
#![warn(missing_docs)] #![warn(missing_docs)]
#![warn(rustdoc::missing_doc_code_examples)]
#![warn(rustdoc::all)] #![warn(rustdoc::all)]
pub fn foo() {} pub fn foo() {}

View file

@ -17,7 +17,7 @@ LL | #![warn(missing_docs)]
| ^^^^^^^^^^^^ | ^^^^^^^^^^^^
warning: missing documentation for a function warning: missing documentation for a function
--> $DIR/check.rs:12:1 --> $DIR/check.rs:13:1
| |
LL | pub fn foo() {} LL | pub fn foo() {}
| ^^^^^^^^^^^^ | ^^^^^^^^^^^^
@ -27,7 +27,7 @@ warning: no documentation found for this crate's top-level module
= help: The following guide may be of use: = help: The following guide may be of use:
https://doc.rust-lang.org/$CHANNEL/rustdoc/how-to-write-documentation.html https://doc.rust-lang.org/$CHANNEL/rustdoc/how-to-write-documentation.html
note: the lint level is defined here note: the lint level is defined here
--> $DIR/check.rs:10:9 --> $DIR/check.rs:11:9
| |
LL | #![warn(rustdoc::all)] LL | #![warn(rustdoc::all)]
| ^^^^^^^^^^^^ | ^^^^^^^^^^^^
@ -45,10 +45,14 @@ LL | |
LL | | pub fn foo() {} LL | | pub fn foo() {}
| |_______________^ | |_______________^
| |
= note: `#[warn(rustdoc::missing_doc_code_examples)]` implied by `#[warn(rustdoc::all)]` note: the lint level is defined here
--> $DIR/check.rs:10:9
|
LL | #![warn(rustdoc::missing_doc_code_examples)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: missing code example in this documentation warning: missing code example in this documentation
--> $DIR/check.rs:12:1 --> $DIR/check.rs:13:1
| |
LL | pub fn foo() {} LL | pub fn foo() {}
| ^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^

View file

@ -6,6 +6,7 @@
//! println!("sup"); //! println!("sup");
//! ``` //! ```
#![deny(rustdoc::missing_doc_code_examples)]
#![deny(rustdoc::all)] #![deny(rustdoc::all)]
/// what up, let's make an [error] /// what up, let's make an [error]

View file

@ -1,5 +1,5 @@
error: missing code example in this documentation error: missing code example in this documentation
--> $DIR/lint-group.rs:18:1 --> $DIR/lint-group.rs:19:1
| |
LL | /// wait, this doesn't have a doctest? LL | /// wait, this doesn't have a doctest?
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -7,12 +7,11 @@ LL | /// wait, this doesn't have a doctest?
note: the lint level is defined here note: the lint level is defined here
--> $DIR/lint-group.rs:9:9 --> $DIR/lint-group.rs:9:9
| |
LL | #![deny(rustdoc::all)] LL | #![deny(rustdoc::missing_doc_code_examples)]
| ^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: `#[deny(rustdoc::missing_doc_code_examples)]` implied by `#[deny(rustdoc::all)]`
error: documentation test in private item error: documentation test in private item
--> $DIR/lint-group.rs:21:1 --> $DIR/lint-group.rs:22:1
| |
LL | / /// wait, this *does* have a doctest? LL | / /// wait, this *does* have a doctest?
LL | | /// LL | | ///
@ -21,16 +20,21 @@ LL | | /// println!("sup");
LL | | /// ``` LL | | /// ```
| |_______^ | |_______^
| |
note: the lint level is defined here
--> $DIR/lint-group.rs:10:9
|
LL | #![deny(rustdoc::all)]
| ^^^^^^^^^^^^
= note: `#[deny(rustdoc::private_doc_tests)]` implied by `#[deny(rustdoc::all)]` = note: `#[deny(rustdoc::private_doc_tests)]` implied by `#[deny(rustdoc::all)]`
error: missing code example in this documentation error: missing code example in this documentation
--> $DIR/lint-group.rs:28:1 --> $DIR/lint-group.rs:29:1
| |
LL | /// <unknown> LL | /// <unknown>
| ^^^^^^^^^^^^^ | ^^^^^^^^^^^^^
error: unresolved link to `error` error: unresolved link to `error`
--> $DIR/lint-group.rs:11:29 --> $DIR/lint-group.rs:12:29
| |
LL | /// what up, let's make an [error] LL | /// what up, let's make an [error]
| ^^^^^ no item named `error` in scope | ^^^^^ no item named `error` in scope
@ -39,7 +43,7 @@ LL | /// what up, let's make an [error]
= note: `#[deny(rustdoc::broken_intra_doc_links)]` implied by `#[deny(rustdoc::all)]` = note: `#[deny(rustdoc::broken_intra_doc_links)]` implied by `#[deny(rustdoc::all)]`
error: unclosed HTML tag `unknown` error: unclosed HTML tag `unknown`
--> $DIR/lint-group.rs:28:5 --> $DIR/lint-group.rs:29:5
| |
LL | /// <unknown> LL | /// <unknown>
| ^^^^^^^^^ | ^^^^^^^^^

View file

@ -0,0 +1,6 @@
// check-pass
// Ensure `rustdoc::all` only affects stable lints. See #106289.
#![deny(unknown_lints)]
#![allow(rustdoc::all)]