about summary refs log tree commit diff
path: root/clippy_lints
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-11-19 22:31:11 +0000
committerbors <bors@rust-lang.org>2023-11-19 22:31:11 +0000
commit41140e3cb8642abb12404520ac95c4ac82ead73f (patch)
treec65856fa1d9426a1c0b86bec87155af65ec2acf8 /clippy_lints
parent9c3a365fd2e2486d2b8efce99b0159821e2eca4f (diff)
parentdfbca7ffa8e0f7d69374f5f6dd351cc34ed0e811 (diff)
Auto merge of #11840 - GuillaumeGomez:improve-maybe_misused_cfg, r=blyxyas
Improve maybe misused cfg

Follow-up of the improvements that were suggested to me in https://github.com/rust-lang/rust-clippy/pull/11821:

 * I unified the output to use the same terms.
 * I updated the code to prevent creating a new symbol.

r? `@blyxyas`

changelog: [`maybe_misued_cfg`]: Output and code improvements
Diffstat (limited to 'clippy_lints')
-rw-r--r--clippy_lints/src/attrs.rs9
1 files changed, 5 insertions, 4 deletions
diff --git a/clippy_lints/src/attrs.rs b/clippy_lints/src/attrs.rs
index 9fe1ef2ed14..0a4a0ab9f07 100644
--- a/clippy_lints/src/attrs.rs
+++ b/clippy_lints/src/attrs.rs
@@ -929,15 +929,16 @@ fn check_nested_cfg(cx: &EarlyContext<'_>, items: &[NestedMetaItem]) {
 fn check_nested_misused_cfg(cx: &EarlyContext<'_>, items: &[NestedMetaItem]) {
     for item in items {
         if let NestedMetaItem::MetaItem(meta) = item {
-            if meta.has_name(sym!(features))
+            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 misspelled as features",
-                    "use",
+                    "'feature' may be misspelled as 'features'",
+                    "did you mean",
                     format!("feature = \"{val}\""),
                     Applicability::MaybeIncorrect,
                 );
@@ -953,7 +954,7 @@ fn check_nested_misused_cfg(cx: &EarlyContext<'_>, items: &[NestedMetaItem]) {
                     MAYBE_MISUSED_CFG,
                     meta.span,
                     &format!("'test' may be misspelled as '{}'", ident.name.as_str()),
-                    "do you mean",
+                    "did you mean",
                     "test".to_string(),
                     Applicability::MaybeIncorrect,
                 );