From 261f64358c216941e6543e43f9ea33efa7a35ab3 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Wed, 19 May 2021 23:13:26 -0400 Subject: [PATCH] Fix `deny(invalid_doc_attributes)` --- compiler/rustc_lint_defs/src/builtin.rs | 1 + src/librustdoc/core.rs | 3 ++- src/test/rustdoc-ui/doc-spotlight.fixed | 5 ++--- src/test/rustdoc-ui/doc-spotlight.rs | 5 ++--- src/test/rustdoc-ui/doc-spotlight.stderr | 13 +++++++++---- src/test/ui/rustdoc/deny-invalid-doc-attrs.rs | 7 +++++++ .../ui/rustdoc/deny-invalid-doc-attrs.stderr | 16 ++++++++++++++++ 7 files changed, 39 insertions(+), 11 deletions(-) create mode 100644 src/test/ui/rustdoc/deny-invalid-doc-attrs.rs create mode 100644 src/test/ui/rustdoc/deny-invalid-doc-attrs.stderr diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index 15246971bae..352146d6463 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -2994,6 +2994,7 @@ USELESS_DEPRECATED, UNSUPPORTED_NAKED_FUNCTIONS, MISSING_ABI, + INVALID_DOC_ATTRIBUTES, SEMICOLON_IN_EXPRESSIONS_FROM_MACROS, DISJOINT_CAPTURE_MIGRATION, LEGACY_DERIVE_HELPERS, diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index 3dd13a8f170..5c4c74c57bd 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -217,8 +217,9 @@ impl<'tcx> DocContext<'tcx> { // By default, rustdoc ignores all lints. // Specifically unblock lints relevant to documentation or the lint machinery itself. let mut lints_to_show = vec![ - // it's unclear whether this should be part of rustdoc directly (#77364) + // it's unclear whether these should be part of rustdoc directly (#77364) rustc_lint::builtin::MISSING_DOCS.name.to_string(), + rustc_lint::builtin::INVALID_DOC_ATTRIBUTES.name.to_string(), // these are definitely not part of rustdoc, but we want to warn on them anyway. rustc_lint::builtin::RENAMED_AND_REMOVED_LINTS.name.to_string(), rustc_lint::builtin::UNKNOWN_LINTS.name.to_string(), diff --git a/src/test/rustdoc-ui/doc-spotlight.fixed b/src/test/rustdoc-ui/doc-spotlight.fixed index 94b69a99879..4b58778eacd 100644 --- a/src/test/rustdoc-ui/doc-spotlight.fixed +++ b/src/test/rustdoc-ui/doc-spotlight.fixed @@ -1,9 +1,8 @@ -// check-pass // run-rustfix - +#![deny(warnings)] #![feature(doc_notable_trait)] #[doc(notable_trait)] -//~^ WARN unknown `doc` attribute `spotlight` +//~^ ERROR unknown `doc` attribute `spotlight` //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! trait MyTrait {} diff --git a/src/test/rustdoc-ui/doc-spotlight.rs b/src/test/rustdoc-ui/doc-spotlight.rs index cc5f159a809..16e38724580 100644 --- a/src/test/rustdoc-ui/doc-spotlight.rs +++ b/src/test/rustdoc-ui/doc-spotlight.rs @@ -1,9 +1,8 @@ -// check-pass // run-rustfix - +#![deny(warnings)] #![feature(doc_notable_trait)] #[doc(spotlight)] -//~^ WARN unknown `doc` attribute `spotlight` +//~^ ERROR unknown `doc` attribute `spotlight` //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! trait MyTrait {} diff --git a/src/test/rustdoc-ui/doc-spotlight.stderr b/src/test/rustdoc-ui/doc-spotlight.stderr index e5fa6293f3d..8e7831139a8 100644 --- a/src/test/rustdoc-ui/doc-spotlight.stderr +++ b/src/test/rustdoc-ui/doc-spotlight.stderr @@ -1,14 +1,19 @@ -warning: unknown `doc` attribute `spotlight` - --> $DIR/doc-spotlight.rs:6:7 +error: unknown `doc` attribute `spotlight` + --> $DIR/doc-spotlight.rs:5:7 | LL | #[doc(spotlight)] | ^^^^^^^^^ help: use `notable_trait` instead | - = note: `#[warn(invalid_doc_attributes)]` on by default +note: the lint level is defined here + --> $DIR/doc-spotlight.rs:2:9 + | +LL | #![deny(warnings)] + | ^^^^^^^^ + = note: `#[deny(invalid_doc_attributes)]` implied by `#[deny(warnings)]` = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #82730 = note: `doc(spotlight)` was renamed to `doc(notable_trait)` = note: `doc(spotlight)` is now a no-op -warning: 1 warning emitted +error: aborting due to previous error diff --git a/src/test/ui/rustdoc/deny-invalid-doc-attrs.rs b/src/test/ui/rustdoc/deny-invalid-doc-attrs.rs new file mode 100644 index 00000000000..02e9c67915f --- /dev/null +++ b/src/test/ui/rustdoc/deny-invalid-doc-attrs.rs @@ -0,0 +1,7 @@ +#![deny(invalid_doc_attributes)] +//~^ NOTE defined here +#![doc(x)] +//~^ ERROR unknown `doc` attribute `x` +//~| WARNING will become a hard error +//~| NOTE see issue #82730 +fn main() {} diff --git a/src/test/ui/rustdoc/deny-invalid-doc-attrs.stderr b/src/test/ui/rustdoc/deny-invalid-doc-attrs.stderr new file mode 100644 index 00000000000..a14ab8fe4bc --- /dev/null +++ b/src/test/ui/rustdoc/deny-invalid-doc-attrs.stderr @@ -0,0 +1,16 @@ +error: unknown `doc` attribute `x` + --> $DIR/deny-invalid-doc-attrs.rs:3:8 + | +LL | #![doc(x)] + | ^ + | +note: the lint level is defined here + --> $DIR/deny-invalid-doc-attrs.rs:1:9 + | +LL | #![deny(invalid_doc_attributes)] + | ^^^^^^^^^^^^^^^^^^^^^^ + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #82730 + +error: aborting due to previous error + -- 2.44.0