Skip to content

Commit 74451cd

Browse files
Extend maybe_misused_cfg lint over cfg(test)
1 parent 902c79c commit 74451cd

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

clippy_lints/src/attrs.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -946,6 +946,19 @@ fn check_nested_misused_cfg(cx: &EarlyContext<'_>, items: &[NestedMetaItem]) {
946946
}
947947
if let MetaItemKind::List(list) = &meta.kind {
948948
check_nested_misused_cfg(cx, list);
949+
// If this is not a list, then we check for `cfg(test)`.
950+
} else if let Some(ident) = meta.ident()
951+
&& matches!(ident.name.as_str(), "tests" | "Test")
952+
{
953+
span_lint_and_sugg(
954+
cx,
955+
MAYBE_MISUSED_CFG,
956+
meta.span,
957+
&format!("'test' may be misspelled as '{}'", ident.name.as_str()),
958+
"do you mean",
959+
"test".to_string(),
960+
Applicability::MaybeIncorrect,
961+
);
949962
}
950963
}
951964
}

0 commit comments

Comments
 (0)