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`]
This commit is contained in:
commit
4f3180adac
@ -1,51 +0,0 @@
|
||||
use super::{Attribute, MAYBE_MISUSED_CFG};
|
||||
use clippy_utils::diagnostics::span_lint_and_sugg;
|
||||
use rustc_ast::{MetaItemKind, NestedMetaItem};
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_lint::EarlyContext;
|
||||
use rustc_span::sym;
|
||||
|
||||
pub(super) fn check(cx: &EarlyContext<'_>, attr: &Attribute) {
|
||||
if attr.has_name(sym::cfg)
|
||||
&& let Some(items) = attr.meta_item_list()
|
||||
{
|
||||
check_nested_misused_cfg(cx, &items);
|
||||
}
|
||||
}
|
||||
|
||||
fn check_nested_misused_cfg(cx: &EarlyContext<'_>, items: &[NestedMetaItem]) {
|
||||
for item in items {
|
||||
if let NestedMetaItem::MetaItem(meta) = item {
|
||||
if let Some(ident) = meta.ident()
|
||||
&& ident.name.as_str() == "features"
|
||||
&& let Some(val) = meta.value_str()
|
||||
{
|
||||
span_lint_and_sugg(
|
||||
cx,
|
||||
MAYBE_MISUSED_CFG,
|
||||
meta.span,
|
||||
"'feature' may be misspelled as 'features'",
|
||||
"did you mean",
|
||||
format!("feature = \"{val}\""),
|
||||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
}
|
||||
if let MetaItemKind::List(list) = &meta.kind {
|
||||
check_nested_misused_cfg(cx, list);
|
||||
// If this is not a list, then we check for `cfg(test)`.
|
||||
} else if let Some(ident) = meta.ident()
|
||||
&& matches!(ident.name.as_str(), "tests" | "Test")
|
||||
{
|
||||
span_lint_and_sugg(
|
||||
cx,
|
||||
MAYBE_MISUSED_CFG,
|
||||
meta.span,
|
||||
format!("'test' may be misspelled as '{}'", ident.name.as_str()),
|
||||
"did you mean",
|
||||
"test".to_string(),
|
||||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,90 +0,0 @@
|
||||
use super::{Attribute, MISMATCHED_TARGET_OS};
|
||||
use clippy_utils::diagnostics::span_lint_and_then;
|
||||
use rustc_ast::{MetaItemKind, NestedMetaItem};
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_lint::EarlyContext;
|
||||
use rustc_span::{sym, Span};
|
||||
|
||||
static UNIX_SYSTEMS: &[&str] = &[
|
||||
"android",
|
||||
"dragonfly",
|
||||
"emscripten",
|
||||
"freebsd",
|
||||
"fuchsia",
|
||||
"haiku",
|
||||
"illumos",
|
||||
"ios",
|
||||
"l4re",
|
||||
"linux",
|
||||
"macos",
|
||||
"netbsd",
|
||||
"openbsd",
|
||||
"redox",
|
||||
"solaris",
|
||||
"vxworks",
|
||||
];
|
||||
|
||||
// NOTE: windows is excluded from the list because it's also a valid target family.
|
||||
static NON_UNIX_SYSTEMS: &[&str] = &["hermit", "none", "wasi"];
|
||||
|
||||
pub(super) fn check(cx: &EarlyContext<'_>, attr: &Attribute) {
|
||||
fn find_os(name: &str) -> Option<&'static str> {
|
||||
UNIX_SYSTEMS
|
||||
.iter()
|
||||
.chain(NON_UNIX_SYSTEMS.iter())
|
||||
.find(|&&os| os == name)
|
||||
.copied()
|
||||
}
|
||||
|
||||
fn is_unix(name: &str) -> bool {
|
||||
UNIX_SYSTEMS.iter().any(|&os| os == name)
|
||||
}
|
||||
|
||||
fn find_mismatched_target_os(items: &[NestedMetaItem]) -> Vec<(&str, Span)> {
|
||||
let mut mismatched = Vec::new();
|
||||
|
||||
for item in items {
|
||||
if let NestedMetaItem::MetaItem(meta) = item {
|
||||
match &meta.kind {
|
||||
MetaItemKind::List(list) => {
|
||||
mismatched.extend(find_mismatched_target_os(list));
|
||||
},
|
||||
MetaItemKind::Word => {
|
||||
if let Some(ident) = meta.ident()
|
||||
&& let Some(os) = find_os(ident.name.as_str())
|
||||
{
|
||||
mismatched.push((os, ident.span));
|
||||
}
|
||||
},
|
||||
MetaItemKind::NameValue(..) => {},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mismatched
|
||||
}
|
||||
|
||||
if attr.has_name(sym::cfg)
|
||||
&& let Some(list) = attr.meta_item_list()
|
||||
&& let mismatched = find_mismatched_target_os(&list)
|
||||
&& !mismatched.is_empty()
|
||||
{
|
||||
let mess = "operating system used in target family position";
|
||||
|
||||
span_lint_and_then(cx, MISMATCHED_TARGET_OS, attr.span, mess, |diag| {
|
||||
// Avoid showing the unix suggestion multiple times in case
|
||||
// we have more than one mismatch for unix-like systems
|
||||
let mut unix_suggested = false;
|
||||
|
||||
for (os, span) in mismatched {
|
||||
let sugg = format!("target_os = \"{os}\"");
|
||||
diag.span_suggestion(span, "try", sugg, Applicability::MaybeIncorrect);
|
||||
|
||||
if !unix_suggested && is_unix(os) {
|
||||
diag.help("did you mean `unix`?");
|
||||
unix_suggested = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -7,8 +7,6 @@
|
||||
mod duplicated_attributes;
|
||||
mod empty_line_after;
|
||||
mod inline_always;
|
||||
mod maybe_misused_cfg;
|
||||
mod mismatched_target_os;
|
||||
mod mixed_attributes_style;
|
||||
mod non_minimal_cfg;
|
||||
mod should_panic_without_expect;
|
||||
@ -270,39 +268,6 @@
|
||||
"usage of `cfg_attr(rustfmt)` instead of tool attributes"
|
||||
}
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// ### What it does
|
||||
/// Checks for cfg attributes having operating systems used in target family position.
|
||||
///
|
||||
/// ### Why is this bad?
|
||||
/// The configuration option will not be recognised and the related item will not be included
|
||||
/// by the conditional compilation engine.
|
||||
///
|
||||
/// ### Example
|
||||
/// ```no_run
|
||||
/// #[cfg(linux)]
|
||||
/// fn conditional() { }
|
||||
/// ```
|
||||
///
|
||||
/// Use instead:
|
||||
/// ```no_run
|
||||
/// # mod hidden {
|
||||
/// #[cfg(target_os = "linux")]
|
||||
/// fn conditional() { }
|
||||
/// # }
|
||||
///
|
||||
/// // or
|
||||
///
|
||||
/// #[cfg(unix)]
|
||||
/// fn conditional() { }
|
||||
/// ```
|
||||
/// Check the [Rust Reference](https://doc.rust-lang.org/reference/conditional-compilation.html#target_os) for more details.
|
||||
#[clippy::version = "1.45.0"]
|
||||
pub MISMATCHED_TARGET_OS,
|
||||
correctness,
|
||||
"usage of `cfg(operating_system)` instead of `cfg(target_os = \"operating_system\")`"
|
||||
}
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// ### What it does
|
||||
/// Checks for attributes that allow lints without a reason.
|
||||
@ -391,38 +356,6 @@
|
||||
"ensure that all `cfg(any())` and `cfg(all())` have more than one condition"
|
||||
}
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// ### What it does
|
||||
/// Checks for `#[cfg(features = "...")]` and suggests to replace it with
|
||||
/// `#[cfg(feature = "...")]`.
|
||||
///
|
||||
/// It also checks if `cfg(test)` was misspelled.
|
||||
///
|
||||
/// ### Why is this bad?
|
||||
/// Misspelling `feature` as `features` or `test` as `tests` can be sometimes hard to spot. It
|
||||
/// may cause conditional compilation not work quietly.
|
||||
///
|
||||
/// ### Example
|
||||
/// ```no_run
|
||||
/// #[cfg(features = "some-feature")]
|
||||
/// fn conditional() { }
|
||||
/// #[cfg(tests)]
|
||||
/// mod tests { }
|
||||
/// ```
|
||||
///
|
||||
/// Use instead:
|
||||
/// ```no_run
|
||||
/// #[cfg(feature = "some-feature")]
|
||||
/// fn conditional() { }
|
||||
/// #[cfg(test)]
|
||||
/// mod tests { }
|
||||
/// ```
|
||||
#[clippy::version = "1.69.0"]
|
||||
pub MAYBE_MISUSED_CFG,
|
||||
suspicious,
|
||||
"prevent from misusing the wrong attr name"
|
||||
}
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// ### What it does
|
||||
/// Checks for `#[cfg_attr(feature = "cargo-clippy", ...)]` and for
|
||||
@ -612,11 +545,9 @@ pub struct EarlyAttributes {
|
||||
|
||||
impl_lint_pass!(EarlyAttributes => [
|
||||
DEPRECATED_CFG_ATTR,
|
||||
MISMATCHED_TARGET_OS,
|
||||
EMPTY_LINE_AFTER_OUTER_ATTR,
|
||||
EMPTY_LINE_AFTER_DOC_COMMENTS,
|
||||
NON_MINIMAL_CFG,
|
||||
MAYBE_MISUSED_CFG,
|
||||
DEPRECATED_CLIPPY_CFG_ATTR,
|
||||
UNNECESSARY_CLIPPY_CFG,
|
||||
]);
|
||||
@ -629,9 +560,7 @@ fn check_item(&mut self, cx: &EarlyContext<'_>, item: &rustc_ast::Item) {
|
||||
fn check_attribute(&mut self, cx: &EarlyContext<'_>, attr: &Attribute) {
|
||||
deprecated_cfg_attr::check(cx, attr, &self.msrv);
|
||||
deprecated_cfg_attr::check_clippy(cx, attr);
|
||||
mismatched_target_os::check(cx, attr);
|
||||
non_minimal_cfg::check(cx, attr);
|
||||
maybe_misused_cfg::check(cx, attr);
|
||||
}
|
||||
|
||||
extract_msrv_attr!(EarlyContext);
|
||||
|
@ -58,8 +58,6 @@
|
||||
crate::attrs::EMPTY_LINE_AFTER_DOC_COMMENTS_INFO,
|
||||
crate::attrs::EMPTY_LINE_AFTER_OUTER_ATTR_INFO,
|
||||
crate::attrs::INLINE_ALWAYS_INFO,
|
||||
crate::attrs::MAYBE_MISUSED_CFG_INFO,
|
||||
crate::attrs::MISMATCHED_TARGET_OS_INFO,
|
||||
crate::attrs::MIXED_ATTRIBUTES_STYLE_INFO,
|
||||
crate::attrs::NON_MINIMAL_CFG_INFO,
|
||||
crate::attrs::SHOULD_PANIC_WITHOUT_EXPECT_INFO,
|
||||
|
@ -215,3 +215,29 @@ macro_rules! declare_deprecated_lint {
|
||||
pub WRONG_PUB_SELF_CONVENTION,
|
||||
"set the `avoid-breaking-exported-api` config option to `false` to enable the `wrong_self_convention` lint for public items"
|
||||
}
|
||||
|
||||
declare_deprecated_lint! {
|
||||
/// ### What it does
|
||||
/// Nothing. This lint has been deprecated.
|
||||
///
|
||||
/// ### Deprecation reason
|
||||
/// This lint has been superseded by rustc's own [`unexpected_cfgs`] lint that is able to detect the `#[cfg(features)]` and `#[cfg(tests)]` typos.
|
||||
///
|
||||
/// [`unexpected_cfgs`]: https://doc.rust-lang.org/rustc/lints/listing/warn-by-default.html#unexpected-cfgs
|
||||
#[clippy::version = "1.80.0"]
|
||||
pub MAYBE_MISUSED_CFG,
|
||||
"this lint has been replaced by `unexpected_cfgs`"
|
||||
}
|
||||
|
||||
declare_deprecated_lint! {
|
||||
/// ### What it does
|
||||
/// Nothing. This lint has been deprecated.
|
||||
///
|
||||
/// ### Deprecation reason
|
||||
/// This lint has been superseded by rustc's own [`unexpected_cfgs`] lint that is able to detect invalid `#[cfg(linux)]` attributes.
|
||||
///
|
||||
/// [`unexpected_cfgs`]: https://doc.rust-lang.org/rustc/lints/listing/warn-by-default.html#unexpected-cfgs
|
||||
#[clippy::version = "1.80.0"]
|
||||
pub MISMATCHED_TARGET_OS,
|
||||
"this lint has been replaced by `unexpected_cfgs`"
|
||||
}
|
||||
|
@ -67,4 +67,12 @@
|
||||
"clippy::wrong_pub_self_convention",
|
||||
"set the `avoid-breaking-exported-api` config option to `false` to enable the `wrong_self_convention` lint for public items",
|
||||
);
|
||||
store.register_removed(
|
||||
"clippy::maybe_misused_cfg",
|
||||
"this lint has been replaced by `unexpected_cfgs`",
|
||||
);
|
||||
store.register_removed(
|
||||
"clippy::mismatched_target_os",
|
||||
"this lint has been replaced by `unexpected_cfgs`",
|
||||
);
|
||||
}
|
||||
|
@ -1,29 +0,0 @@
|
||||
#![warn(clippy::maybe_misused_cfg)]
|
||||
|
||||
fn main() {
|
||||
#[cfg(feature = "not-really-a-feature")]
|
||||
//~^ ERROR: 'feature' may be misspelled as 'features'
|
||||
//~| NOTE: `-D clippy::maybe-misused-cfg` implied by `-D warnings`
|
||||
let _ = 1 + 2;
|
||||
|
||||
#[cfg(all(feature = "right", feature = "wrong"))]
|
||||
//~^ ERROR: 'feature' may be misspelled as 'features'
|
||||
let _ = 1 + 2;
|
||||
|
||||
#[cfg(all(feature = "wrong1", any(feature = "right", feature = "wrong2", feature, features)))]
|
||||
//~^ ERROR: 'feature' may be misspelled as 'features'
|
||||
//~| ERROR: 'feature' may be misspelled as 'features'
|
||||
let _ = 1 + 2;
|
||||
|
||||
#[cfg(test)]
|
||||
//~^ ERROR: 'test' may be misspelled as 'tests'
|
||||
let _ = 2;
|
||||
#[cfg(test)]
|
||||
//~^ ERROR: 'test' may be misspelled as 'Test'
|
||||
let _ = 2;
|
||||
|
||||
#[cfg(all(test, test))]
|
||||
//~^ ERROR: 'test' may be misspelled as 'tests'
|
||||
//~| ERROR: 'test' may be misspelled as 'Test'
|
||||
let _ = 2;
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
#![warn(clippy::maybe_misused_cfg)]
|
||||
|
||||
fn main() {
|
||||
#[cfg(features = "not-really-a-feature")]
|
||||
//~^ ERROR: 'feature' may be misspelled as 'features'
|
||||
//~| NOTE: `-D clippy::maybe-misused-cfg` implied by `-D warnings`
|
||||
let _ = 1 + 2;
|
||||
|
||||
#[cfg(all(feature = "right", features = "wrong"))]
|
||||
//~^ ERROR: 'feature' may be misspelled as 'features'
|
||||
let _ = 1 + 2;
|
||||
|
||||
#[cfg(all(features = "wrong1", any(feature = "right", features = "wrong2", feature, features)))]
|
||||
//~^ ERROR: 'feature' may be misspelled as 'features'
|
||||
//~| ERROR: 'feature' may be misspelled as 'features'
|
||||
let _ = 1 + 2;
|
||||
|
||||
#[cfg(tests)]
|
||||
//~^ ERROR: 'test' may be misspelled as 'tests'
|
||||
let _ = 2;
|
||||
#[cfg(Test)]
|
||||
//~^ ERROR: 'test' may be misspelled as 'Test'
|
||||
let _ = 2;
|
||||
|
||||
#[cfg(all(tests, Test))]
|
||||
//~^ ERROR: 'test' may be misspelled as 'tests'
|
||||
//~| ERROR: 'test' may be misspelled as 'Test'
|
||||
let _ = 2;
|
||||
}
|
@ -1,53 +0,0 @@
|
||||
error: 'feature' may be misspelled as 'features'
|
||||
--> tests/ui/cfg_features.rs:4:11
|
||||
|
|
||||
LL | #[cfg(features = "not-really-a-feature")]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: did you mean: `feature = "not-really-a-feature"`
|
||||
|
|
||||
= note: `-D clippy::maybe-misused-cfg` implied by `-D warnings`
|
||||
= help: to override `-D warnings` add `#[allow(clippy::maybe_misused_cfg)]`
|
||||
|
||||
error: 'feature' may be misspelled as 'features'
|
||||
--> tests/ui/cfg_features.rs:9:34
|
||||
|
|
||||
LL | #[cfg(all(feature = "right", features = "wrong"))]
|
||||
| ^^^^^^^^^^^^^^^^^^ help: did you mean: `feature = "wrong"`
|
||||
|
||||
error: 'feature' may be misspelled as 'features'
|
||||
--> tests/ui/cfg_features.rs:13:15
|
||||
|
|
||||
LL | #[cfg(all(features = "wrong1", any(feature = "right", features = "wrong2", feature, features)))]
|
||||
| ^^^^^^^^^^^^^^^^^^^ help: did you mean: `feature = "wrong1"`
|
||||
|
||||
error: 'feature' may be misspelled as 'features'
|
||||
--> tests/ui/cfg_features.rs:13:59
|
||||
|
|
||||
LL | #[cfg(all(features = "wrong1", any(feature = "right", features = "wrong2", feature, features)))]
|
||||
| ^^^^^^^^^^^^^^^^^^^ help: did you mean: `feature = "wrong2"`
|
||||
|
||||
error: 'test' may be misspelled as 'tests'
|
||||
--> tests/ui/cfg_features.rs:18:11
|
||||
|
|
||||
LL | #[cfg(tests)]
|
||||
| ^^^^^ help: did you mean: `test`
|
||||
|
||||
error: 'test' may be misspelled as 'Test'
|
||||
--> tests/ui/cfg_features.rs:21:11
|
||||
|
|
||||
LL | #[cfg(Test)]
|
||||
| ^^^^ help: did you mean: `test`
|
||||
|
||||
error: 'test' may be misspelled as 'tests'
|
||||
--> tests/ui/cfg_features.rs:25:15
|
||||
|
|
||||
LL | #[cfg(all(tests, Test))]
|
||||
| ^^^^^ help: did you mean: `test`
|
||||
|
||||
error: 'test' may be misspelled as 'Test'
|
||||
--> tests/ui/cfg_features.rs:25:22
|
||||
|
|
||||
LL | #[cfg(all(tests, Test))]
|
||||
| ^^^^ help: did you mean: `test`
|
||||
|
||||
error: aborting due to 8 previous errors
|
||||
|
@ -18,5 +18,7 @@
|
||||
#![warn(clippy::filter_map)]
|
||||
#![warn(clippy::pub_enum_variant_names)]
|
||||
#![warn(clippy::wrong_pub_self_convention)]
|
||||
#![warn(clippy::maybe_misused_cfg)]
|
||||
#![warn(clippy::mismatched_target_os)]
|
||||
|
||||
fn main() {}
|
||||
|
@ -97,5 +97,17 @@ error: lint `clippy::wrong_pub_self_convention` has been removed: set the `avoid
|
||||
LL | #![warn(clippy::wrong_pub_self_convention)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 16 previous errors
|
||||
error: lint `clippy::maybe_misused_cfg` has been removed: this lint has been replaced by `unexpected_cfgs`
|
||||
--> tests/ui/deprecated.rs:21:9
|
||||
|
|
||||
LL | #![warn(clippy::maybe_misused_cfg)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: lint `clippy::mismatched_target_os` has been removed: this lint has been replaced by `unexpected_cfgs`
|
||||
--> tests/ui/deprecated.rs:22:9
|
||||
|
|
||||
LL | #![warn(clippy::mismatched_target_os)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 18 previous errors
|
||||
|
||||
|
@ -1,25 +0,0 @@
|
||||
#![warn(clippy::mismatched_target_os)]
|
||||
#![allow(unused)]
|
||||
|
||||
#[cfg(target_os = "hermit")]
|
||||
fn hermit() {}
|
||||
|
||||
#[cfg(target_os = "wasi")]
|
||||
fn wasi() {}
|
||||
|
||||
#[cfg(target_os = "none")]
|
||||
fn none() {}
|
||||
|
||||
// list with conditions
|
||||
#[cfg(all(not(windows), target_os = "wasi"))]
|
||||
fn list() {}
|
||||
|
||||
// windows is a valid target family, should be ignored
|
||||
#[cfg(windows)]
|
||||
fn windows() {}
|
||||
|
||||
// correct use, should be ignored
|
||||
#[cfg(target_os = "hermit")]
|
||||
fn correct() {}
|
||||
|
||||
fn main() {}
|
@ -1,25 +0,0 @@
|
||||
#![warn(clippy::mismatched_target_os)]
|
||||
#![allow(unused)]
|
||||
|
||||
#[cfg(hermit)]
|
||||
fn hermit() {}
|
||||
|
||||
#[cfg(wasi)]
|
||||
fn wasi() {}
|
||||
|
||||
#[cfg(none)]
|
||||
fn none() {}
|
||||
|
||||
// list with conditions
|
||||
#[cfg(all(not(windows), wasi))]
|
||||
fn list() {}
|
||||
|
||||
// windows is a valid target family, should be ignored
|
||||
#[cfg(windows)]
|
||||
fn windows() {}
|
||||
|
||||
// correct use, should be ignored
|
||||
#[cfg(target_os = "hermit")]
|
||||
fn correct() {}
|
||||
|
||||
fn main() {}
|
@ -1,37 +0,0 @@
|
||||
error: operating system used in target family position
|
||||
--> tests/ui/mismatched_target_os_non_unix.rs:4:1
|
||||
|
|
||||
LL | #[cfg(hermit)]
|
||||
| ^^^^^^------^^
|
||||
| |
|
||||
| help: try: `target_os = "hermit"`
|
||||
|
|
||||
= note: `-D clippy::mismatched-target-os` implied by `-D warnings`
|
||||
= help: to override `-D warnings` add `#[allow(clippy::mismatched_target_os)]`
|
||||
|
||||
error: operating system used in target family position
|
||||
--> tests/ui/mismatched_target_os_non_unix.rs:7:1
|
||||
|
|
||||
LL | #[cfg(wasi)]
|
||||
| ^^^^^^----^^
|
||||
| |
|
||||
| help: try: `target_os = "wasi"`
|
||||
|
||||
error: operating system used in target family position
|
||||
--> tests/ui/mismatched_target_os_non_unix.rs:10:1
|
||||
|
|
||||
LL | #[cfg(none)]
|
||||
| ^^^^^^----^^
|
||||
| |
|
||||
| help: try: `target_os = "none"`
|
||||
|
||||
error: operating system used in target family position
|
||||
--> tests/ui/mismatched_target_os_non_unix.rs:14:1
|
||||
|
|
||||
LL | #[cfg(all(not(windows), wasi))]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^----^^^
|
||||
| |
|
||||
| help: try: `target_os = "wasi"`
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
@ -1,60 +0,0 @@
|
||||
#![warn(clippy::mismatched_target_os)]
|
||||
#![allow(unused)]
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
fn linux() {}
|
||||
|
||||
#[cfg(target_os = "freebsd")]
|
||||
fn freebsd() {}
|
||||
|
||||
#[cfg(target_os = "dragonfly")]
|
||||
fn dragonfly() {}
|
||||
|
||||
#[cfg(target_os = "openbsd")]
|
||||
fn openbsd() {}
|
||||
|
||||
#[cfg(target_os = "netbsd")]
|
||||
fn netbsd() {}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
fn macos() {}
|
||||
|
||||
#[cfg(target_os = "ios")]
|
||||
fn ios() {}
|
||||
|
||||
#[cfg(target_os = "android")]
|
||||
fn android() {}
|
||||
|
||||
#[cfg(target_os = "emscripten")]
|
||||
fn emscripten() {}
|
||||
|
||||
#[cfg(target_os = "fuchsia")]
|
||||
fn fuchsia() {}
|
||||
|
||||
#[cfg(target_os = "haiku")]
|
||||
fn haiku() {}
|
||||
|
||||
#[cfg(target_os = "illumos")]
|
||||
fn illumos() {}
|
||||
|
||||
#[cfg(target_os = "l4re")]
|
||||
fn l4re() {}
|
||||
|
||||
#[cfg(target_os = "redox")]
|
||||
fn redox() {}
|
||||
|
||||
#[cfg(target_os = "solaris")]
|
||||
fn solaris() {}
|
||||
|
||||
#[cfg(target_os = "vxworks")]
|
||||
fn vxworks() {}
|
||||
|
||||
// list with conditions
|
||||
#[cfg(all(not(any(target_os = "solaris", target_os = "linux")), target_os = "freebsd"))]
|
||||
fn list() {}
|
||||
|
||||
// correct use, should be ignored
|
||||
#[cfg(target_os = "freebsd")]
|
||||
fn correct() {}
|
||||
|
||||
fn main() {}
|
@ -1,60 +0,0 @@
|
||||
#![warn(clippy::mismatched_target_os)]
|
||||
#![allow(unused)]
|
||||
|
||||
#[cfg(linux)]
|
||||
fn linux() {}
|
||||
|
||||
#[cfg(freebsd)]
|
||||
fn freebsd() {}
|
||||
|
||||
#[cfg(dragonfly)]
|
||||
fn dragonfly() {}
|
||||
|
||||
#[cfg(openbsd)]
|
||||
fn openbsd() {}
|
||||
|
||||
#[cfg(netbsd)]
|
||||
fn netbsd() {}
|
||||
|
||||
#[cfg(macos)]
|
||||
fn macos() {}
|
||||
|
||||
#[cfg(ios)]
|
||||
fn ios() {}
|
||||
|
||||
#[cfg(android)]
|
||||
fn android() {}
|
||||
|
||||
#[cfg(emscripten)]
|
||||
fn emscripten() {}
|
||||
|
||||
#[cfg(fuchsia)]
|
||||
fn fuchsia() {}
|
||||
|
||||
#[cfg(haiku)]
|
||||
fn haiku() {}
|
||||
|
||||
#[cfg(illumos)]
|
||||
fn illumos() {}
|
||||
|
||||
#[cfg(l4re)]
|
||||
fn l4re() {}
|
||||
|
||||
#[cfg(redox)]
|
||||
fn redox() {}
|
||||
|
||||
#[cfg(solaris)]
|
||||
fn solaris() {}
|
||||
|
||||
#[cfg(vxworks)]
|
||||
fn vxworks() {}
|
||||
|
||||
// list with conditions
|
||||
#[cfg(all(not(any(solaris, linux)), freebsd))]
|
||||
fn list() {}
|
||||
|
||||
// correct use, should be ignored
|
||||
#[cfg(target_os = "freebsd")]
|
||||
fn correct() {}
|
||||
|
||||
fn main() {}
|
@ -1,184 +0,0 @@
|
||||
error: operating system used in target family position
|
||||
--> tests/ui/mismatched_target_os_unix.rs:4:1
|
||||
|
|
||||
LL | #[cfg(linux)]
|
||||
| ^^^^^^-----^^
|
||||
| |
|
||||
| help: try: `target_os = "linux"`
|
||||
|
|
||||
= help: did you mean `unix`?
|
||||
= note: `-D clippy::mismatched-target-os` implied by `-D warnings`
|
||||
= help: to override `-D warnings` add `#[allow(clippy::mismatched_target_os)]`
|
||||
|
||||
error: operating system used in target family position
|
||||
--> tests/ui/mismatched_target_os_unix.rs:7:1
|
||||
|
|
||||
LL | #[cfg(freebsd)]
|
||||
| ^^^^^^-------^^
|
||||
| |
|
||||
| help: try: `target_os = "freebsd"`
|
||||
|
|
||||
= help: did you mean `unix`?
|
||||
|
||||
error: operating system used in target family position
|
||||
--> tests/ui/mismatched_target_os_unix.rs:10:1
|
||||
|
|
||||
LL | #[cfg(dragonfly)]
|
||||
| ^^^^^^---------^^
|
||||
| |
|
||||
| help: try: `target_os = "dragonfly"`
|
||||
|
|
||||
= help: did you mean `unix`?
|
||||
|
||||
error: operating system used in target family position
|
||||
--> tests/ui/mismatched_target_os_unix.rs:13:1
|
||||
|
|
||||
LL | #[cfg(openbsd)]
|
||||
| ^^^^^^-------^^
|
||||
| |
|
||||
| help: try: `target_os = "openbsd"`
|
||||
|
|
||||
= help: did you mean `unix`?
|
||||
|
||||
error: operating system used in target family position
|
||||
--> tests/ui/mismatched_target_os_unix.rs:16:1
|
||||
|
|
||||
LL | #[cfg(netbsd)]
|
||||
| ^^^^^^------^^
|
||||
| |
|
||||
| help: try: `target_os = "netbsd"`
|
||||
|
|
||||
= help: did you mean `unix`?
|
||||
|
||||
error: operating system used in target family position
|
||||
--> tests/ui/mismatched_target_os_unix.rs:19:1
|
||||
|
|
||||
LL | #[cfg(macos)]
|
||||
| ^^^^^^-----^^
|
||||
| |
|
||||
| help: try: `target_os = "macos"`
|
||||
|
|
||||
= help: did you mean `unix`?
|
||||
|
||||
error: operating system used in target family position
|
||||
--> tests/ui/mismatched_target_os_unix.rs:22:1
|
||||
|
|
||||
LL | #[cfg(ios)]
|
||||
| ^^^^^^---^^
|
||||
| |
|
||||
| help: try: `target_os = "ios"`
|
||||
|
|
||||
= help: did you mean `unix`?
|
||||
|
||||
error: operating system used in target family position
|
||||
--> tests/ui/mismatched_target_os_unix.rs:25:1
|
||||
|
|
||||
LL | #[cfg(android)]
|
||||
| ^^^^^^-------^^
|
||||
| |
|
||||
| help: try: `target_os = "android"`
|
||||
|
|
||||
= help: did you mean `unix`?
|
||||
|
||||
error: operating system used in target family position
|
||||
--> tests/ui/mismatched_target_os_unix.rs:28:1
|
||||
|
|
||||
LL | #[cfg(emscripten)]
|
||||
| ^^^^^^----------^^
|
||||
| |
|
||||
| help: try: `target_os = "emscripten"`
|
||||
|
|
||||
= help: did you mean `unix`?
|
||||
|
||||
error: operating system used in target family position
|
||||
--> tests/ui/mismatched_target_os_unix.rs:31:1
|
||||
|
|
||||
LL | #[cfg(fuchsia)]
|
||||
| ^^^^^^-------^^
|
||||
| |
|
||||
| help: try: `target_os = "fuchsia"`
|
||||
|
|
||||
= help: did you mean `unix`?
|
||||
|
||||
error: operating system used in target family position
|
||||
--> tests/ui/mismatched_target_os_unix.rs:34:1
|
||||
|
|
||||
LL | #[cfg(haiku)]
|
||||
| ^^^^^^-----^^
|
||||
| |
|
||||
| help: try: `target_os = "haiku"`
|
||||
|
|
||||
= help: did you mean `unix`?
|
||||
|
||||
error: operating system used in target family position
|
||||
--> tests/ui/mismatched_target_os_unix.rs:37:1
|
||||
|
|
||||
LL | #[cfg(illumos)]
|
||||
| ^^^^^^-------^^
|
||||
| |
|
||||
| help: try: `target_os = "illumos"`
|
||||
|
|
||||
= help: did you mean `unix`?
|
||||
|
||||
error: operating system used in target family position
|
||||
--> tests/ui/mismatched_target_os_unix.rs:40:1
|
||||
|
|
||||
LL | #[cfg(l4re)]
|
||||
| ^^^^^^----^^
|
||||
| |
|
||||
| help: try: `target_os = "l4re"`
|
||||
|
|
||||
= help: did you mean `unix`?
|
||||
|
||||
error: operating system used in target family position
|
||||
--> tests/ui/mismatched_target_os_unix.rs:43:1
|
||||
|
|
||||
LL | #[cfg(redox)]
|
||||
| ^^^^^^-----^^
|
||||
| |
|
||||
| help: try: `target_os = "redox"`
|
||||
|
|
||||
= help: did you mean `unix`?
|
||||
|
||||
error: operating system used in target family position
|
||||
--> tests/ui/mismatched_target_os_unix.rs:46:1
|
||||
|
|
||||
LL | #[cfg(solaris)]
|
||||
| ^^^^^^-------^^
|
||||
| |
|
||||
| help: try: `target_os = "solaris"`
|
||||
|
|
||||
= help: did you mean `unix`?
|
||||
|
||||
error: operating system used in target family position
|
||||
--> tests/ui/mismatched_target_os_unix.rs:49:1
|
||||
|
|
||||
LL | #[cfg(vxworks)]
|
||||
| ^^^^^^-------^^
|
||||
| |
|
||||
| help: try: `target_os = "vxworks"`
|
||||
|
|
||||
= help: did you mean `unix`?
|
||||
|
||||
error: operating system used in target family position
|
||||
--> tests/ui/mismatched_target_os_unix.rs:53:1
|
||||
|
|
||||
LL | #[cfg(all(not(any(solaris, linux)), freebsd))]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: did you mean `unix`?
|
||||
help: try
|
||||
|
|
||||
LL | #[cfg(all(not(any(target_os = "solaris", linux)), freebsd))]
|
||||
| ~~~~~~~~~~~~~~~~~~~~~
|
||||
help: try
|
||||
|
|
||||
LL | #[cfg(all(not(any(solaris, target_os = "linux")), freebsd))]
|
||||
| ~~~~~~~~~~~~~~~~~~~
|
||||
help: try
|
||||
|
|
||||
LL | #[cfg(all(not(any(solaris, linux)), target_os = "freebsd"))]
|
||||
| ~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
error: aborting due to 17 previous errors
|
||||
|
@ -5,18 +5,18 @@
|
||||
//~^ ERROR: no need to put clippy lints behind a `clippy` cfg
|
||||
#![cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg))]
|
||||
//~^ ERROR: no need to put clippy lints behind a `clippy` cfg
|
||||
#![cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg, clippy::maybe_misused_cfg))]
|
||||
#![cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg))]
|
||||
//~^ ERROR: no need to put clippy lints behind a `clippy` cfg
|
||||
#![cfg_attr(clippy, deny(clippy::non_minimal_cfg, clippy::maybe_misused_cfg))]
|
||||
#![cfg_attr(clippy, deny(clippy::non_minimal_cfg))]
|
||||
//~^ ERROR: no need to put clippy lints behind a `clippy` cfg
|
||||
|
||||
#[cfg_attr(clippy, deny(clippy::non_minimal_cfg))]
|
||||
//~^ ERROR: no need to put clippy lints behind a `clippy` cfg
|
||||
#[cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg))]
|
||||
//~^ ERROR: no need to put clippy lints behind a `clippy` cfg
|
||||
#[cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg, clippy::maybe_misused_cfg))]
|
||||
#[cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg))]
|
||||
//~^ ERROR: no need to put clippy lints behind a `clippy` cfg
|
||||
#[cfg_attr(clippy, deny(clippy::non_minimal_cfg, clippy::maybe_misused_cfg))]
|
||||
#[cfg_attr(clippy, deny(clippy::non_minimal_cfg))]
|
||||
//~^ ERROR: no need to put clippy lints behind a `clippy` cfg
|
||||
pub struct Bar;
|
||||
|
||||
|
@ -18,16 +18,16 @@ LL | #[cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg))]
|
||||
error: no need to put clippy lints behind a `clippy` cfg
|
||||
--> tests/ui/unnecessary_clippy_cfg.rs:17:36
|
||||
|
|
||||
LL | #[cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg, clippy::maybe_misused_cfg))]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
LL | #[cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg))]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: write instead: `#[deny(clippy::non_minimal_cfg,clippy::maybe_misused_cfg)]`
|
||||
= note: write instead: `#[deny(clippy::non_minimal_cfg)]`
|
||||
|
||||
error: no need to put clippy lints behind a `clippy` cfg
|
||||
--> tests/ui/unnecessary_clippy_cfg.rs:19:1
|
||||
|
|
||||
LL | #[cfg_attr(clippy, deny(clippy::non_minimal_cfg, clippy::maybe_misused_cfg))]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `#[deny(clippy::non_minimal_cfg, clippy::maybe_misused_cfg)]`
|
||||
LL | #[cfg_attr(clippy, deny(clippy::non_minimal_cfg))]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `#[deny(clippy::non_minimal_cfg)]`
|
||||
|
||||
error: no need to put clippy lints behind a `clippy` cfg
|
||||
--> tests/ui/unnecessary_clippy_cfg.rs:4:1
|
||||
@ -46,21 +46,21 @@ LL | #![cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg))]
|
||||
error: no need to put clippy lints behind a `clippy` cfg
|
||||
--> tests/ui/unnecessary_clippy_cfg.rs:8:37
|
||||
|
|
||||
LL | #![cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg, clippy::maybe_misused_cfg))]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
LL | #![cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg))]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: write instead: `#![deny(clippy::non_minimal_cfg,clippy::maybe_misused_cfg)]`
|
||||
= note: write instead: `#![deny(clippy::non_minimal_cfg)]`
|
||||
|
||||
error: no need to put clippy lints behind a `clippy` cfg
|
||||
--> tests/ui/unnecessary_clippy_cfg.rs:10:1
|
||||
|
|
||||
LL | #![cfg_attr(clippy, deny(clippy::non_minimal_cfg, clippy::maybe_misused_cfg))]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `#![deny(clippy::non_minimal_cfg, clippy::maybe_misused_cfg)]`
|
||||
LL | #![cfg_attr(clippy, deny(clippy::non_minimal_cfg))]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `#![deny(clippy::non_minimal_cfg)]`
|
||||
|
||||
error: duplicated attribute
|
||||
--> tests/ui/unnecessary_clippy_cfg.rs:8:26
|
||||
|
|
||||
LL | #![cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg, clippy::maybe_misused_cfg))]
|
||||
LL | #![cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg))]
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
note: first defined here
|
||||
@ -71,7 +71,7 @@ LL | #![cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg))]
|
||||
help: remove this attribute
|
||||
--> tests/ui/unnecessary_clippy_cfg.rs:8:26
|
||||
|
|
||||
LL | #![cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg, clippy::maybe_misused_cfg))]
|
||||
LL | #![cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg))]
|
||||
| ^^^^^^^^^
|
||||
= note: `-D clippy::duplicated-attributes` implied by `-D warnings`
|
||||
= help: to override `-D warnings` add `#[allow(clippy::duplicated_attributes)]`
|
||||
@ -79,7 +79,7 @@ LL | #![cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg, clippy::maybe_
|
||||
error: duplicated attribute
|
||||
--> tests/ui/unnecessary_clippy_cfg.rs:17:25
|
||||
|
|
||||
LL | #[cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg, clippy::maybe_misused_cfg))]
|
||||
LL | #[cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg))]
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
note: first defined here
|
||||
@ -90,7 +90,7 @@ LL | #[cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg))]
|
||||
help: remove this attribute
|
||||
--> tests/ui/unnecessary_clippy_cfg.rs:17:25
|
||||
|
|
||||
LL | #[cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg, clippy::maybe_misused_cfg))]
|
||||
LL | #[cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg))]
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: aborting due to 10 previous errors
|
||||
|
Loading…
Reference in New Issue
Block a user