Skip to content

Commit 4f3180a

Browse files
committed
Auto merge of #12875 - y21:deprecate_cfg_lints, r=flip1995
Deprecate `maybe_misused_cfg` and `mismatched_target_os` All cases that these two lints would catch are now caught by cargo/rustc's own check-cfg feature. This was previously discussed on zulip: https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/Deprecate.20maybe_misused_cfg.20and.20mismatched_target_os For the most part, this PR was automated with `cargo dev deprecate` r? `@flip1995` cc `@Urgau` changelog: deprecate [`maybe_misused_cfg`] and [`mismatched_target_os`]
2 parents 61d3e14 + f950961 commit 4f3180a

19 files changed

+67
-735
lines changed

clippy_lints/src/attrs/maybe_misused_cfg.rs

-51
This file was deleted.

clippy_lints/src/attrs/mismatched_target_os.rs

-90
This file was deleted.

clippy_lints/src/attrs/mod.rs

-71
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ mod deprecated_semver;
77
mod duplicated_attributes;
88
mod empty_line_after;
99
mod inline_always;
10-
mod maybe_misused_cfg;
11-
mod mismatched_target_os;
1210
mod mixed_attributes_style;
1311
mod non_minimal_cfg;
1412
mod should_panic_without_expect;
@@ -270,39 +268,6 @@ declare_clippy_lint! {
270268
"usage of `cfg_attr(rustfmt)` instead of tool attributes"
271269
}
272270

273-
declare_clippy_lint! {
274-
/// ### What it does
275-
/// Checks for cfg attributes having operating systems used in target family position.
276-
///
277-
/// ### Why is this bad?
278-
/// The configuration option will not be recognised and the related item will not be included
279-
/// by the conditional compilation engine.
280-
///
281-
/// ### Example
282-
/// ```no_run
283-
/// #[cfg(linux)]
284-
/// fn conditional() { }
285-
/// ```
286-
///
287-
/// Use instead:
288-
/// ```no_run
289-
/// # mod hidden {
290-
/// #[cfg(target_os = "linux")]
291-
/// fn conditional() { }
292-
/// # }
293-
///
294-
/// // or
295-
///
296-
/// #[cfg(unix)]
297-
/// fn conditional() { }
298-
/// ```
299-
/// Check the [Rust Reference](https://doc.rust-lang.org/reference/conditional-compilation.html#target_os) for more details.
300-
#[clippy::version = "1.45.0"]
301-
pub MISMATCHED_TARGET_OS,
302-
correctness,
303-
"usage of `cfg(operating_system)` instead of `cfg(target_os = \"operating_system\")`"
304-
}
305-
306271
declare_clippy_lint! {
307272
/// ### What it does
308273
/// Checks for attributes that allow lints without a reason.
@@ -391,38 +356,6 @@ declare_clippy_lint! {
391356
"ensure that all `cfg(any())` and `cfg(all())` have more than one condition"
392357
}
393358

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-
426359
declare_clippy_lint! {
427360
/// ### What it does
428361
/// Checks for `#[cfg_attr(feature = "cargo-clippy", ...)]` and for
@@ -612,11 +545,9 @@ pub struct EarlyAttributes {
612545

613546
impl_lint_pass!(EarlyAttributes => [
614547
DEPRECATED_CFG_ATTR,
615-
MISMATCHED_TARGET_OS,
616548
EMPTY_LINE_AFTER_OUTER_ATTR,
617549
EMPTY_LINE_AFTER_DOC_COMMENTS,
618550
NON_MINIMAL_CFG,
619-
MAYBE_MISUSED_CFG,
620551
DEPRECATED_CLIPPY_CFG_ATTR,
621552
UNNECESSARY_CLIPPY_CFG,
622553
]);
@@ -629,9 +560,7 @@ impl EarlyLintPass for EarlyAttributes {
629560
fn check_attribute(&mut self, cx: &EarlyContext<'_>, attr: &Attribute) {
630561
deprecated_cfg_attr::check(cx, attr, &self.msrv);
631562
deprecated_cfg_attr::check_clippy(cx, attr);
632-
mismatched_target_os::check(cx, attr);
633563
non_minimal_cfg::check(cx, attr);
634-
maybe_misused_cfg::check(cx, attr);
635564
}
636565

637566
extract_msrv_attr!(EarlyContext);

clippy_lints/src/declared_lints.rs

-2
Original file line numberDiff line numberDiff line change
@@ -58,8 +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,
62-
crate::attrs::MISMATCHED_TARGET_OS_INFO,
6361
crate::attrs::MIXED_ATTRIBUTES_STYLE_INFO,
6462
crate::attrs::NON_MINIMAL_CFG_INFO,
6563
crate::attrs::SHOULD_PANIC_WITHOUT_EXPECT_INFO,

clippy_lints/src/deprecated_lints.rs

+26
Original file line numberDiff line numberDiff line change
@@ -215,3 +215,29 @@ 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+
}
231+
232+
declare_deprecated_lint! {
233+
/// ### What it does
234+
/// Nothing. This lint has been deprecated.
235+
///
236+
/// ### Deprecation reason
237+
/// This lint has been superseded by rustc's own [`unexpected_cfgs`] lint that is able to detect invalid `#[cfg(linux)]` attributes.
238+
///
239+
/// [`unexpected_cfgs`]: https://doc.rust-lang.org/rustc/lints/listing/warn-by-default.html#unexpected-cfgs
240+
#[clippy::version = "1.80.0"]
241+
pub MISMATCHED_TARGET_OS,
242+
"this lint has been replaced by `unexpected_cfgs`"
243+
}

clippy_lints/src/lib.deprecated.rs

+8
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,12 @@
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+
);
74+
store.register_removed(
75+
"clippy::mismatched_target_os",
76+
"this lint has been replaced by `unexpected_cfgs`",
77+
);
7078
}

tests/ui/cfg_features.fixed

-29
This file was deleted.

tests/ui/cfg_features.rs

-29
This file was deleted.

0 commit comments

Comments
 (0)