Skip to content

Commit 67a7001

Browse files
Improve maybe_misused_cfg lint output
1 parent 6eb935a commit 67a7001

File tree

4 files changed

+18
-18
lines changed

4 files changed

+18
-18
lines changed

clippy_lints/src/attrs.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -936,8 +936,8 @@ fn check_nested_misused_cfg(cx: &EarlyContext<'_>, items: &[NestedMetaItem]) {
936936
cx,
937937
MAYBE_MISUSED_CFG,
938938
meta.span,
939-
"feature may misspelled as features",
940-
"use",
939+
"'feature' may be misspelled as 'features'",
940+
"do you mean",
941941
format!("feature = \"{val}\""),
942942
Applicability::MaybeIncorrect,
943943
);

tests/ui/cfg_features.fixed

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22

33
fn main() {
44
#[cfg(feature = "not-really-a-feature")]
5-
//~^ ERROR: feature may misspelled as features
5+
//~^ ERROR: 'feature' may be misspelled as 'features'
66
//~| NOTE: `-D clippy::maybe-misused-cfg` implied by `-D warnings`
77
let _ = 1 + 2;
88

99
#[cfg(all(feature = "right", feature = "wrong"))]
10-
//~^ ERROR: feature may misspelled as features
10+
//~^ ERROR: 'feature' may be misspelled as 'features'
1111
let _ = 1 + 2;
1212

1313
#[cfg(all(feature = "wrong1", any(feature = "right", feature = "wrong2", feature, features)))]
14-
//~^ ERROR: feature may misspelled as features
15-
//~| ERROR: feature may misspelled as features
14+
//~^ ERROR: 'feature' may be misspelled as 'features'
15+
//~| ERROR: 'feature' may be misspelled as 'features'
1616
let _ = 1 + 2;
1717

1818
#[cfg(test)]

tests/ui/cfg_features.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22

33
fn main() {
44
#[cfg(features = "not-really-a-feature")]
5-
//~^ ERROR: feature may misspelled as features
5+
//~^ ERROR: 'feature' may be misspelled as 'features'
66
//~| NOTE: `-D clippy::maybe-misused-cfg` implied by `-D warnings`
77
let _ = 1 + 2;
88

99
#[cfg(all(feature = "right", features = "wrong"))]
10-
//~^ ERROR: feature may misspelled as features
10+
//~^ ERROR: 'feature' may be misspelled as 'features'
1111
let _ = 1 + 2;
1212

1313
#[cfg(all(features = "wrong1", any(feature = "right", features = "wrong2", feature, features)))]
14-
//~^ ERROR: feature may misspelled as features
15-
//~| ERROR: feature may misspelled as features
14+
//~^ ERROR: 'feature' may be misspelled as 'features'
15+
//~| ERROR: 'feature' may be misspelled as 'features'
1616
let _ = 1 + 2;
1717

1818
#[cfg(tests)]

tests/ui/cfg_features.stderr

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
1-
error: feature may misspelled as features
1+
error: 'feature' may be misspelled as 'features'
22
--> $DIR/cfg_features.rs:4:11
33
|
44
LL | #[cfg(features = "not-really-a-feature")]
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `feature = "not-really-a-feature"`
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: do you mean: `feature = "not-really-a-feature"`
66
|
77
= note: `-D clippy::maybe-misused-cfg` implied by `-D warnings`
88
= help: to override `-D warnings` add `#[allow(clippy::maybe_misused_cfg)]`
99

10-
error: feature may misspelled as features
10+
error: 'feature' may be misspelled as 'features'
1111
--> $DIR/cfg_features.rs:9:34
1212
|
1313
LL | #[cfg(all(feature = "right", features = "wrong"))]
14-
| ^^^^^^^^^^^^^^^^^^ help: use: `feature = "wrong"`
14+
| ^^^^^^^^^^^^^^^^^^ help: do you mean: `feature = "wrong"`
1515

16-
error: feature may misspelled as features
16+
error: 'feature' may be misspelled as 'features'
1717
--> $DIR/cfg_features.rs:13:15
1818
|
1919
LL | #[cfg(all(features = "wrong1", any(feature = "right", features = "wrong2", feature, features)))]
20-
| ^^^^^^^^^^^^^^^^^^^ help: use: `feature = "wrong1"`
20+
| ^^^^^^^^^^^^^^^^^^^ help: do you mean: `feature = "wrong1"`
2121

22-
error: feature may misspelled as features
22+
error: 'feature' may be misspelled as 'features'
2323
--> $DIR/cfg_features.rs:13:59
2424
|
2525
LL | #[cfg(all(features = "wrong1", any(feature = "right", features = "wrong2", feature, features)))]
26-
| ^^^^^^^^^^^^^^^^^^^ help: use: `feature = "wrong2"`
26+
| ^^^^^^^^^^^^^^^^^^^ help: do you mean: `feature = "wrong2"`
2727

2828
error: 'test' may be misspelled as 'tests'
2929
--> $DIR/cfg_features.rs:18:11

0 commit comments

Comments
 (0)