about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSerial <69764315+Serial-ATA@users.noreply.github.com>2022-06-24 14:11:24 -0400
committerSerial <69764315+Serial-ATA@users.noreply.github.com>2022-06-24 14:11:24 -0400
commitaec465cabdeb9a126446ccf791a9cf5ae045c185 (patch)
tree0ee7582ec3a75ddd0f44a9c10e50235e36984b56
parentebf77f6d7ecfb2cc60dfb39116d889af76d932cf (diff)
downloadrust-aec465cabdeb9a126446ccf791a9cf5ae045c185.tar.gz
rust-aec465cabdeb9a126446ccf791a9cf5ae045c185.zip
Add test for [`default_deprecation_reason`]
-rw-r--r--clippy_lints/src/deprecated_lints.rs5
-rw-r--r--clippy_lints/src/lib.rs2
-rw-r--r--clippy_lints/src/utils/internal_lints.rs3
-rw-r--r--tests/compile-test.rs3
-rw-r--r--tests/ui-internal/default_deprecation_reason.rs30
-rw-r--r--tests/ui-internal/default_deprecation_reason.stderr22
6 files changed, 59 insertions, 6 deletions
diff --git a/clippy_lints/src/deprecated_lints.rs b/clippy_lints/src/deprecated_lints.rs
index d7a4b6f5c88..9aa5af3190f 100644
--- a/clippy_lints/src/deprecated_lints.rs
+++ b/clippy_lints/src/deprecated_lints.rs
@@ -4,17 +4,16 @@
 /// enables the simple extraction of the metadata without changing the current deprecation
 /// declaration.
 pub struct ClippyDeprecatedLint {
-    #[cfg(feature = "internal")]
     #[allow(dead_code)]
-    desc: &'static str,
+    pub desc: &'static str,
 }
 
+#[macro_export]
 macro_rules! declare_deprecated_lint {
     { $(#[$attr:meta])* pub $name: ident, $reason: literal} => {
         $(#[$attr])*
         #[allow(dead_code)]
         pub static $name: ClippyDeprecatedLint = ClippyDeprecatedLint {
-            #[cfg(feature = "internal")]
             desc: $reason
         };
     }
diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs
index dcee11cc28c..8eb75a0a548 100644
--- a/clippy_lints/src/lib.rs
+++ b/clippy_lints/src/lib.rs
@@ -159,7 +159,7 @@ macro_rules! declare_clippy_lint {
 }
 
 #[cfg(feature = "internal")]
-mod deprecated_lints;
+pub mod deprecated_lints;
 #[cfg_attr(feature = "internal", allow(clippy::missing_clippy_version_attribute))]
 mod utils;
 
diff --git a/clippy_lints/src/utils/internal_lints.rs b/clippy_lints/src/utils/internal_lints.rs
index c5380662566..b8e704b983b 100644
--- a/clippy_lints/src/utils/internal_lints.rs
+++ b/clippy_lints/src/utils/internal_lints.rs
@@ -348,7 +348,6 @@ declare_clippy_lint! {
     /// Indicates that the documentation is incomplete.
     ///
     /// ### Example
-    /// Bad:
     /// ```rust,ignore
     /// declare_deprecated_lint! {
     ///     /// ### What it does
@@ -362,7 +361,7 @@ declare_clippy_lint! {
     /// }
     /// ```
     ///
-    /// Good:
+    /// Use instead:
     /// ```rust,ignore
     /// declare_deprecated_lint! {
     ///     /// ### What it does
diff --git a/tests/compile-test.rs b/tests/compile-test.rs
index 7d219835723..a303d90d953 100644
--- a/tests/compile-test.rs
+++ b/tests/compile-test.rs
@@ -24,6 +24,7 @@ const RUN_INTERNAL_TESTS: bool = cfg!(feature = "internal");
 /// All crates used in UI tests are listed here
 static TEST_DEPENDENCIES: &[&str] = &[
     "clap",
+    "clippy_lints",
     "clippy_utils",
     "derive_new",
     "futures",
@@ -44,6 +45,8 @@ static TEST_DEPENDENCIES: &[&str] = &[
 #[allow(unused_extern_crates)]
 extern crate clap;
 #[allow(unused_extern_crates)]
+extern crate clippy_lints;
+#[allow(unused_extern_crates)]
 extern crate clippy_utils;
 #[allow(unused_extern_crates)]
 extern crate derive_new;
diff --git a/tests/ui-internal/default_deprecation_reason.rs b/tests/ui-internal/default_deprecation_reason.rs
new file mode 100644
index 00000000000..c8961d5e1f0
--- /dev/null
+++ b/tests/ui-internal/default_deprecation_reason.rs
@@ -0,0 +1,30 @@
+#![deny(clippy::internal)]
+#![feature(rustc_private)]
+
+#[macro_use]
+extern crate clippy_lints;
+use clippy_lints::deprecated_lints::ClippyDeprecatedLint;
+
+declare_deprecated_lint! {
+    /// ### What it does
+    /// Nothing. This lint has been deprecated.
+    ///
+    /// ### Deprecation reason
+    /// TODO
+    #[clippy::version = "1.63.0"]
+    pub COOL_LINT_DEFAULT,
+    "default deprecation note"
+}
+
+declare_deprecated_lint! {
+    /// ### What it does
+    /// Nothing. This lint has been deprecated.
+    ///
+    /// ### Deprecation reason
+    /// This lint has been replaced by `cooler_lint`
+    #[clippy::version = "1.63.0"]
+    pub COOL_LINT,
+    "this lint has been replaced by `cooler_lint`"
+}
+
+fn main() {}
diff --git a/tests/ui-internal/default_deprecation_reason.stderr b/tests/ui-internal/default_deprecation_reason.stderr
new file mode 100644
index 00000000000..ca26b649f98
--- /dev/null
+++ b/tests/ui-internal/default_deprecation_reason.stderr
@@ -0,0 +1,22 @@
+error: the lint `COOL_LINT_DEFAULT` has the default deprecation reason
+  --> $DIR/default_deprecation_reason.rs:8:1
+   |
+LL | / declare_deprecated_lint! {
+LL | |     /// ### What it does
+LL | |     /// Nothing. This lint has been deprecated.
+LL | |     ///
+...  |
+LL | |     "default deprecation note"
+LL | | }
+   | |_^
+   |
+note: the lint level is defined here
+  --> $DIR/default_deprecation_reason.rs:1:9
+   |
+LL | #![deny(clippy::internal)]
+   |         ^^^^^^^^^^^^^^^^
+   = note: `#[deny(clippy::default_deprecation_reason)]` implied by `#[deny(clippy::internal)]`
+   = note: this error originates in the macro `declare_deprecated_lint` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: aborting due to previous error
+