Skip to content

Commit aec465c

Browse files
committed
Add test for [default_deprecation_reason]
1 parent ebf77f6 commit aec465c

File tree

6 files changed

+59
-6
lines changed

6 files changed

+59
-6
lines changed

clippy_lints/src/deprecated_lints.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,16 @@
44
/// enables the simple extraction of the metadata without changing the current deprecation
55
/// declaration.
66
pub struct ClippyDeprecatedLint {
7-
#[cfg(feature = "internal")]
87
#[allow(dead_code)]
9-
desc: &'static str,
8+
pub desc: &'static str,
109
}
1110

11+
#[macro_export]
1212
macro_rules! declare_deprecated_lint {
1313
{ $(#[$attr:meta])* pub $name: ident, $reason: literal} => {
1414
$(#[$attr])*
1515
#[allow(dead_code)]
1616
pub static $name: ClippyDeprecatedLint = ClippyDeprecatedLint {
17-
#[cfg(feature = "internal")]
1817
desc: $reason
1918
};
2019
}

clippy_lints/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ macro_rules! declare_clippy_lint {
159159
}
160160

161161
#[cfg(feature = "internal")]
162-
mod deprecated_lints;
162+
pub mod deprecated_lints;
163163
#[cfg_attr(feature = "internal", allow(clippy::missing_clippy_version_attribute))]
164164
mod utils;
165165

clippy_lints/src/utils/internal_lints.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,6 @@ declare_clippy_lint! {
348348
/// Indicates that the documentation is incomplete.
349349
///
350350
/// ### Example
351-
/// Bad:
352351
/// ```rust,ignore
353352
/// declare_deprecated_lint! {
354353
/// /// ### What it does
@@ -362,7 +361,7 @@ declare_clippy_lint! {
362361
/// }
363362
/// ```
364363
///
365-
/// Good:
364+
/// Use instead:
366365
/// ```rust,ignore
367366
/// declare_deprecated_lint! {
368367
/// /// ### What it does

tests/compile-test.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const RUN_INTERNAL_TESTS: bool = cfg!(feature = "internal");
2424
/// All crates used in UI tests are listed here
2525
static TEST_DEPENDENCIES: &[&str] = &[
2626
"clap",
27+
"clippy_lints",
2728
"clippy_utils",
2829
"derive_new",
2930
"futures",
@@ -44,6 +45,8 @@ static TEST_DEPENDENCIES: &[&str] = &[
4445
#[allow(unused_extern_crates)]
4546
extern crate clap;
4647
#[allow(unused_extern_crates)]
48+
extern crate clippy_lints;
49+
#[allow(unused_extern_crates)]
4750
extern crate clippy_utils;
4851
#[allow(unused_extern_crates)]
4952
extern crate derive_new;
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#![deny(clippy::internal)]
2+
#![feature(rustc_private)]
3+
4+
#[macro_use]
5+
extern crate clippy_lints;
6+
use clippy_lints::deprecated_lints::ClippyDeprecatedLint;
7+
8+
declare_deprecated_lint! {
9+
/// ### What it does
10+
/// Nothing. This lint has been deprecated.
11+
///
12+
/// ### Deprecation reason
13+
/// TODO
14+
#[clippy::version = "1.63.0"]
15+
pub COOL_LINT_DEFAULT,
16+
"default deprecation note"
17+
}
18+
19+
declare_deprecated_lint! {
20+
/// ### What it does
21+
/// Nothing. This lint has been deprecated.
22+
///
23+
/// ### Deprecation reason
24+
/// This lint has been replaced by `cooler_lint`
25+
#[clippy::version = "1.63.0"]
26+
pub COOL_LINT,
27+
"this lint has been replaced by `cooler_lint`"
28+
}
29+
30+
fn main() {}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
error: the lint `COOL_LINT_DEFAULT` has the default deprecation reason
2+
--> $DIR/default_deprecation_reason.rs:8:1
3+
|
4+
LL | / declare_deprecated_lint! {
5+
LL | | /// ### What it does
6+
LL | | /// Nothing. This lint has been deprecated.
7+
LL | | ///
8+
... |
9+
LL | | "default deprecation note"
10+
LL | | }
11+
| |_^
12+
|
13+
note: the lint level is defined here
14+
--> $DIR/default_deprecation_reason.rs:1:9
15+
|
16+
LL | #![deny(clippy::internal)]
17+
| ^^^^^^^^^^^^^^^^
18+
= note: `#[deny(clippy::default_deprecation_reason)]` implied by `#[deny(clippy::internal)]`
19+
= note: this error originates in the macro `declare_deprecated_lint` (in Nightly builds, run with -Z macro-backtrace for more info)
20+
21+
error: aborting due to previous error
22+

0 commit comments

Comments
 (0)