Skip to content

Commit 4aa20d2

Browse files
committed
deprecate maybe_misused_cfg
1 parent 28e887f commit 4aa20d2

12 files changed

+43
-217
lines changed

clippy_lints/src/attrs/maybe_misused_cfg.rs

Lines changed: 0 additions & 51 deletions
This file was deleted.

clippy_lints/src/attrs/mod.rs

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ mod deprecated_semver;
77
mod duplicated_attributes;
88
mod empty_line_after;
99
mod inline_always;
10-
mod maybe_misused_cfg;
1110
mod mismatched_target_os;
1211
mod mixed_attributes_style;
1312
mod non_minimal_cfg;
@@ -391,38 +390,6 @@ declare_clippy_lint! {
391390
"ensure that all `cfg(any())` and `cfg(all())` have more than one condition"
392391
}
393392

394-
declare_clippy_lint! {
395-
/// ### What it does
396-
/// Checks for `#[cfg(features = "...")]` and suggests to replace it with
397-
/// `#[cfg(feature = "...")]`.
398-
///
399-
/// It also checks if `cfg(test)` was misspelled.
400-
///
401-
/// ### Why is this bad?
402-
/// Misspelling `feature` as `features` or `test` as `tests` can be sometimes hard to spot. It
403-
/// may cause conditional compilation not work quietly.
404-
///
405-
/// ### Example
406-
/// ```no_run
407-
/// #[cfg(features = "some-feature")]
408-
/// fn conditional() { }
409-
/// #[cfg(tests)]
410-
/// mod tests { }
411-
/// ```
412-
///
413-
/// Use instead:
414-
/// ```no_run
415-
/// #[cfg(feature = "some-feature")]
416-
/// fn conditional() { }
417-
/// #[cfg(test)]
418-
/// mod tests { }
419-
/// ```
420-
#[clippy::version = "1.69.0"]
421-
pub MAYBE_MISUSED_CFG,
422-
suspicious,
423-
"prevent from misusing the wrong attr name"
424-
}
425-
426393
declare_clippy_lint! {
427394
/// ### What it does
428395
/// Checks for `#[cfg_attr(feature = "cargo-clippy", ...)]` and for
@@ -616,7 +583,6 @@ impl_lint_pass!(EarlyAttributes => [
616583
EMPTY_LINE_AFTER_OUTER_ATTR,
617584
EMPTY_LINE_AFTER_DOC_COMMENTS,
618585
NON_MINIMAL_CFG,
619-
MAYBE_MISUSED_CFG,
620586
DEPRECATED_CLIPPY_CFG_ATTR,
621587
UNNECESSARY_CLIPPY_CFG,
622588
]);
@@ -631,7 +597,6 @@ impl EarlyLintPass for EarlyAttributes {
631597
deprecated_cfg_attr::check_clippy(cx, attr);
632598
mismatched_target_os::check(cx, attr);
633599
non_minimal_cfg::check(cx, attr);
634-
maybe_misused_cfg::check(cx, attr);
635600
}
636601

637602
extract_msrv_attr!(EarlyContext);

clippy_lints/src/declared_lints.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[
5858
crate::attrs::EMPTY_LINE_AFTER_DOC_COMMENTS_INFO,
5959
crate::attrs::EMPTY_LINE_AFTER_OUTER_ATTR_INFO,
6060
crate::attrs::INLINE_ALWAYS_INFO,
61-
crate::attrs::MAYBE_MISUSED_CFG_INFO,
6261
crate::attrs::MISMATCHED_TARGET_OS_INFO,
6362
crate::attrs::MIXED_ATTRIBUTES_STYLE_INFO,
6463
crate::attrs::NON_MINIMAL_CFG_INFO,

clippy_lints/src/deprecated_lints.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,3 +215,16 @@ declare_deprecated_lint! {
215215
pub WRONG_PUB_SELF_CONVENTION,
216216
"set the `avoid-breaking-exported-api` config option to `false` to enable the `wrong_self_convention` lint for public items"
217217
}
218+
219+
declare_deprecated_lint! {
220+
/// ### What it does
221+
/// Nothing. This lint has been deprecated.
222+
///
223+
/// ### Deprecation reason
224+
/// This lint has been superseded by rustc's own [`unexpected_cfgs`] lint that is able to detect the `#[cfg(features)]` and `#[cfg(tests)]` typos.
225+
///
226+
/// [`unexpected_cfgs`]: https://doc.rust-lang.org/rustc/lints/listing/warn-by-default.html#unexpected-cfgs
227+
#[clippy::version = "1.80.0"]
228+
pub MAYBE_MISUSED_CFG,
229+
"this lint has been replaced by `unexpected_cfgs`"
230+
}

clippy_lints/src/lib.deprecated.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,8 @@
6767
"clippy::wrong_pub_self_convention",
6868
"set the `avoid-breaking-exported-api` config option to `false` to enable the `wrong_self_convention` lint for public items",
6969
);
70+
store.register_removed(
71+
"clippy::maybe_misused_cfg",
72+
"this lint has been replaced by `unexpected_cfgs`",
73+
);
7074
}

tests/ui/cfg_features.fixed

Lines changed: 0 additions & 29 deletions
This file was deleted.

tests/ui/cfg_features.rs

Lines changed: 0 additions & 29 deletions
This file was deleted.

tests/ui/cfg_features.stderr

Lines changed: 0 additions & 53 deletions
This file was deleted.

tests/ui/deprecated.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,6 @@
1818
#![warn(clippy::filter_map)]
1919
#![warn(clippy::pub_enum_variant_names)]
2020
#![warn(clippy::wrong_pub_self_convention)]
21+
#![warn(clippy::maybe_misused_cfg)]
2122

2223
fn main() {}

tests/ui/deprecated.stderr

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,5 +97,11 @@ error: lint `clippy::wrong_pub_self_convention` has been removed: set the `avoid
9797
LL | #![warn(clippy::wrong_pub_self_convention)]
9898
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
9999

100-
error: aborting due to 16 previous errors
100+
error: lint `clippy::maybe_misused_cfg` has been removed: this lint has been replaced by `unexpected_cfgs`
101+
--> tests/ui/deprecated.rs:21:9
102+
|
103+
LL | #![warn(clippy::maybe_misused_cfg)]
104+
| ^^^^^^^^^^^^^^^^^^^^^^^^^
105+
106+
error: aborting due to 17 previous errors
101107

tests/ui/unnecessary_clippy_cfg.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@
55
//~^ ERROR: no need to put clippy lints behind a `clippy` cfg
66
#![cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg))]
77
//~^ ERROR: no need to put clippy lints behind a `clippy` cfg
8-
#![cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg, clippy::maybe_misused_cfg))]
8+
#![cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg))]
99
//~^ ERROR: no need to put clippy lints behind a `clippy` cfg
10-
#![cfg_attr(clippy, deny(clippy::non_minimal_cfg, clippy::maybe_misused_cfg))]
10+
#![cfg_attr(clippy, deny(clippy::non_minimal_cfg))]
1111
//~^ ERROR: no need to put clippy lints behind a `clippy` cfg
1212

1313
#[cfg_attr(clippy, deny(clippy::non_minimal_cfg))]
1414
//~^ ERROR: no need to put clippy lints behind a `clippy` cfg
1515
#[cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg))]
1616
//~^ ERROR: no need to put clippy lints behind a `clippy` cfg
17-
#[cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg, clippy::maybe_misused_cfg))]
17+
#[cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg))]
1818
//~^ ERROR: no need to put clippy lints behind a `clippy` cfg
19-
#[cfg_attr(clippy, deny(clippy::non_minimal_cfg, clippy::maybe_misused_cfg))]
19+
#[cfg_attr(clippy, deny(clippy::non_minimal_cfg))]
2020
//~^ ERROR: no need to put clippy lints behind a `clippy` cfg
2121
pub struct Bar;
2222

tests/ui/unnecessary_clippy_cfg.stderr

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@ LL | #[cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg))]
1818
error: no need to put clippy lints behind a `clippy` cfg
1919
--> tests/ui/unnecessary_clippy_cfg.rs:17:36
2020
|
21-
LL | #[cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg, clippy::maybe_misused_cfg))]
22-
| ^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^
21+
LL | #[cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg))]
22+
| ^^^^^^^^^^^^^^^^^^^^^^^
2323
|
24-
= note: write instead: `#[deny(clippy::non_minimal_cfg,clippy::maybe_misused_cfg)]`
24+
= note: write instead: `#[deny(clippy::non_minimal_cfg)]`
2525

2626
error: no need to put clippy lints behind a `clippy` cfg
2727
--> tests/ui/unnecessary_clippy_cfg.rs:19:1
2828
|
29-
LL | #[cfg_attr(clippy, deny(clippy::non_minimal_cfg, clippy::maybe_misused_cfg))]
30-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `#[deny(clippy::non_minimal_cfg, clippy::maybe_misused_cfg)]`
29+
LL | #[cfg_attr(clippy, deny(clippy::non_minimal_cfg))]
30+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `#[deny(clippy::non_minimal_cfg)]`
3131

3232
error: no need to put clippy lints behind a `clippy` cfg
3333
--> tests/ui/unnecessary_clippy_cfg.rs:4:1
@@ -46,21 +46,21 @@ LL | #![cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg))]
4646
error: no need to put clippy lints behind a `clippy` cfg
4747
--> tests/ui/unnecessary_clippy_cfg.rs:8:37
4848
|
49-
LL | #![cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg, clippy::maybe_misused_cfg))]
50-
| ^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^
49+
LL | #![cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg))]
50+
| ^^^^^^^^^^^^^^^^^^^^^^^
5151
|
52-
= note: write instead: `#![deny(clippy::non_minimal_cfg,clippy::maybe_misused_cfg)]`
52+
= note: write instead: `#![deny(clippy::non_minimal_cfg)]`
5353

5454
error: no need to put clippy lints behind a `clippy` cfg
5555
--> tests/ui/unnecessary_clippy_cfg.rs:10:1
5656
|
57-
LL | #![cfg_attr(clippy, deny(clippy::non_minimal_cfg, clippy::maybe_misused_cfg))]
58-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `#![deny(clippy::non_minimal_cfg, clippy::maybe_misused_cfg)]`
57+
LL | #![cfg_attr(clippy, deny(clippy::non_minimal_cfg))]
58+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `#![deny(clippy::non_minimal_cfg)]`
5959

6060
error: duplicated attribute
6161
--> tests/ui/unnecessary_clippy_cfg.rs:8:26
6262
|
63-
LL | #![cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg, clippy::maybe_misused_cfg))]
63+
LL | #![cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg))]
6464
| ^^^^^^^^^
6565
|
6666
note: first defined here
@@ -71,15 +71,15 @@ LL | #![cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg))]
7171
help: remove this attribute
7272
--> tests/ui/unnecessary_clippy_cfg.rs:8:26
7373
|
74-
LL | #![cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg, clippy::maybe_misused_cfg))]
74+
LL | #![cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg))]
7575
| ^^^^^^^^^
7676
= note: `-D clippy::duplicated-attributes` implied by `-D warnings`
7777
= help: to override `-D warnings` add `#[allow(clippy::duplicated_attributes)]`
7878

7979
error: duplicated attribute
8080
--> tests/ui/unnecessary_clippy_cfg.rs:17:25
8181
|
82-
LL | #[cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg, clippy::maybe_misused_cfg))]
82+
LL | #[cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg))]
8383
| ^^^^^^^^^
8484
|
8585
note: first defined here
@@ -90,7 +90,7 @@ LL | #[cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg))]
9090
help: remove this attribute
9191
--> tests/ui/unnecessary_clippy_cfg.rs:17:25
9292
|
93-
LL | #[cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg, clippy::maybe_misused_cfg))]
93+
LL | #[cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg))]
9494
| ^^^^^^^^^
9595

9696
error: aborting due to 10 previous errors

0 commit comments

Comments
 (0)