Add test for [default_deprecation_reason
]
This commit is contained in:
parent
ebf77f6d7e
commit
aec465cabd
@ -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
|
||||
};
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
30
tests/ui-internal/default_deprecation_reason.rs
Normal file
30
tests/ui-internal/default_deprecation_reason.rs
Normal file
@ -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() {}
|
22
tests/ui-internal/default_deprecation_reason.stderr
Normal file
22
tests/ui-internal/default_deprecation_reason.stderr
Normal file
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user