Skip to content

Commit 0a8d815

Browse files
committed
Auto merge of #118507 - flip1995:clippy-subtree-sync, r=matthiaskrgr
Clippy subtree sync r? `@Manishearth`
2 parents 8c2b577 + 6ae8003 commit 0a8d815

File tree

417 files changed

+3660
-1174
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

417 files changed

+3660
-1174
lines changed

src/tools/clippy/.github/workflows/deploy.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ jobs:
5252
run: cargo generate-lockfile
5353

5454
- name: Cache
55-
uses: Swatinem/[email protected]
55+
uses: Swatinem/[email protected]
56+
with:
57+
save-if: ${{ github.ref == 'refs/heads/master' }}
5658

5759
- name: cargo collect-metadata
5860
run: cargo collect-metadata

src/tools/clippy/CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -5128,6 +5128,7 @@ Released 2018-09-13
51285128
[`if_then_some_else_none`]: https://rust-lang.github.io/rust-clippy/master/index.html#if_then_some_else_none
51295129
[`ifs_same_cond`]: https://rust-lang.github.io/rust-clippy/master/index.html#ifs_same_cond
51305130
[`ignored_unit_patterns`]: https://rust-lang.github.io/rust-clippy/master/index.html#ignored_unit_patterns
5131+
[`impl_hash_borrow_with_str_and_bytes`]: https://rust-lang.github.io/rust-clippy/master/index.html#impl_hash_borrow_with_str_and_bytes
51315132
[`impl_trait_in_params`]: https://rust-lang.github.io/rust-clippy/master/index.html#impl_trait_in_params
51325133
[`implicit_clone`]: https://rust-lang.github.io/rust-clippy/master/index.html#implicit_clone
51335134
[`implicit_hasher`]: https://rust-lang.github.io/rust-clippy/master/index.html#implicit_hasher
@@ -5189,6 +5190,7 @@ Released 2018-09-13
51895190
[`iter_with_drain`]: https://rust-lang.github.io/rust-clippy/master/index.html#iter_with_drain
51905191
[`iter_without_into_iter`]: https://rust-lang.github.io/rust-clippy/master/index.html#iter_without_into_iter
51915192
[`iterator_step_by_zero`]: https://rust-lang.github.io/rust-clippy/master/index.html#iterator_step_by_zero
5193+
[`join_absolute_paths`]: https://rust-lang.github.io/rust-clippy/master/index.html#join_absolute_paths
51925194
[`just_underscores_and_digits`]: https://rust-lang.github.io/rust-clippy/master/index.html#just_underscores_and_digits
51935195
[`large_const_arrays`]: https://rust-lang.github.io/rust-clippy/master/index.html#large_const_arrays
51945196
[`large_digit_groups`]: https://rust-lang.github.io/rust-clippy/master/index.html#large_digit_groups
@@ -5380,6 +5382,7 @@ Released 2018-09-13
53805382
[`option_expect_used`]: https://rust-lang.github.io/rust-clippy/master/index.html#option_expect_used
53815383
[`option_filter_map`]: https://rust-lang.github.io/rust-clippy/master/index.html#option_filter_map
53825384
[`option_if_let_else`]: https://rust-lang.github.io/rust-clippy/master/index.html#option_if_let_else
5385+
[`option_map_or_err_ok`]: https://rust-lang.github.io/rust-clippy/master/index.html#option_map_or_err_ok
53835386
[`option_map_or_none`]: https://rust-lang.github.io/rust-clippy/master/index.html#option_map_or_none
53845387
[`option_map_unit_fn`]: https://rust-lang.github.io/rust-clippy/master/index.html#option_map_unit_fn
53855388
[`option_map_unwrap_or`]: https://rust-lang.github.io/rust-clippy/master/index.html#option_map_unwrap_or
@@ -5542,6 +5545,7 @@ Released 2018-09-13
55425545
[`tabs_in_doc_comments`]: https://rust-lang.github.io/rust-clippy/master/index.html#tabs_in_doc_comments
55435546
[`temporary_assignment`]: https://rust-lang.github.io/rust-clippy/master/index.html#temporary_assignment
55445547
[`temporary_cstring_as_ptr`]: https://rust-lang.github.io/rust-clippy/master/index.html#temporary_cstring_as_ptr
5548+
[`test_attr_in_doctest`]: https://rust-lang.github.io/rust-clippy/master/index.html#test_attr_in_doctest
55455549
[`tests_outside_test_module`]: https://rust-lang.github.io/rust-clippy/master/index.html#tests_outside_test_module
55465550
[`to_digit_is_some`]: https://rust-lang.github.io/rust-clippy/master/index.html#to_digit_is_some
55475551
[`to_string_in_display`]: https://rust-lang.github.io/rust-clippy/master/index.html#to_string_in_display
@@ -5738,4 +5742,5 @@ Released 2018-09-13
57385742
[`absolute-paths-allowed-crates`]: https://doc.rust-lang.org/clippy/lint_configuration.html#absolute-paths-allowed-crates
57395743
[`allowed-dotfiles`]: https://doc.rust-lang.org/clippy/lint_configuration.html#allowed-dotfiles
57405744
[`enforce-iter-loop-reborrow`]: https://doc.rust-lang.org/clippy/lint_configuration.html#enforce-iter-loop-reborrow
5745+
[`check-private-items`]: https://doc.rust-lang.org/clippy/lint_configuration.html#check-private-items
57415746
<!-- end autogenerated links to configuration documentation -->

src/tools/clippy/book/src/development/adding_lints.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ is. This file has already imported some initial things we will need:
202202

203203
```rust
204204
use rustc_lint::{EarlyLintPass, EarlyContext};
205-
use rustc_session::{declare_lint_pass, declare_tool_lint};
205+
use rustc_session::declare_lint_pass;
206206
use rustc_ast::ast::*;
207207
```
208208

@@ -518,6 +518,8 @@ define_Conf! {
518518

519519
[`clippy_config::msrvs`]: https://doc.rust-lang.org/nightly/nightly-rustc/clippy_config/msrvs/index.html
520520

521+
Afterwards update the documentation for the book as described in [Adding configuration to a lint](#adding-configuration-to-a-lint).
522+
521523
## Author lint
522524

523525
If you have trouble implementing your lint, there is also the internal `author`

src/tools/clippy/book/src/development/type_checking.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ an `u32`. As far as `hir::Ty` is concerned those might be different types. But a
119119
understands that they're the same type, in-depth lifetimes, etc...
120120

121121
To get from a `hir::Ty` to a `ty::Ty`, you can use the [`hir_ty_to_ty`][hir_ty_to_ty] function outside of bodies or
122-
outside of bodies the [`TypeckResults::node_type()`][node_type] method.
122+
the [`TypeckResults::node_type()`][node_type] method inside of bodies.
123123

124124
> **Warning**: Don't use `hir_ty_to_ty` inside of bodies, because this can cause ICEs.
125125

src/tools/clippy/book/src/lint_configuration.md

+14
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ The minimum rust version that the project supports. Defaults to the `rust-versio
150150
* [`tuple_array_conversions`](https://rust-lang.github.io/rust-clippy/master/index.html#tuple_array_conversions)
151151
* [`manual_try_fold`](https://rust-lang.github.io/rust-clippy/master/index.html#manual_try_fold)
152152
* [`manual_hash_one`](https://rust-lang.github.io/rust-clippy/master/index.html#manual_hash_one)
153+
* [`iter_kv_map`](https://rust-lang.github.io/rust-clippy/master/index.html#iter_kv_map)
153154

154155

155156
## `cognitive-complexity-threshold`
@@ -791,3 +792,16 @@ for _ in &mut *rmvec {}
791792
* [`explicit_iter_loop`](https://rust-lang.github.io/rust-clippy/master/index.html#explicit_iter_loop)
792793

793794

795+
## `check-private-items`
796+
797+
798+
**Default Value:** `false`
799+
800+
---
801+
**Affected lints:**
802+
* [`missing_safety_doc`](https://rust-lang.github.io/rust-clippy/master/index.html#missing_safety_doc)
803+
* [`unnecessary_safety_doc`](https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_safety_doc)
804+
* [`missing_panics_doc`](https://rust-lang.github.io/rust-clippy/master/index.html#missing_panics_doc)
805+
* [`missing_errors_doc`](https://rust-lang.github.io/rust-clippy/master/index.html#missing_errors_doc)
806+
807+

src/tools/clippy/clippy_config/src/conf.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ define_Conf! {
249249
///
250250
/// Suppress lints whenever the suggested change would cause breakage for other crates.
251251
(avoid_breaking_exported_api: bool = true),
252-
/// Lint: MANUAL_SPLIT_ONCE, MANUAL_STR_REPEAT, CLONED_INSTEAD_OF_COPIED, REDUNDANT_FIELD_NAMES, OPTION_MAP_UNWRAP_OR, REDUNDANT_STATIC_LIFETIMES, FILTER_MAP_NEXT, CHECKED_CONVERSIONS, MANUAL_RANGE_CONTAINS, USE_SELF, MEM_REPLACE_WITH_DEFAULT, MANUAL_NON_EXHAUSTIVE, OPTION_AS_REF_DEREF, MAP_UNWRAP_OR, MATCH_LIKE_MATCHES_MACRO, MANUAL_STRIP, MISSING_CONST_FOR_FN, UNNESTED_OR_PATTERNS, FROM_OVER_INTO, PTR_AS_PTR, IF_THEN_SOME_ELSE_NONE, APPROX_CONSTANT, DEPRECATED_CFG_ATTR, INDEX_REFUTABLE_SLICE, MAP_CLONE, BORROW_AS_PTR, MANUAL_BITS, ERR_EXPECT, CAST_ABS_TO_UNSIGNED, UNINLINED_FORMAT_ARGS, MANUAL_CLAMP, MANUAL_LET_ELSE, UNCHECKED_DURATION_SUBTRACTION, COLLAPSIBLE_STR_REPLACE, SEEK_FROM_CURRENT, SEEK_REWIND, UNNECESSARY_LAZY_EVALUATIONS, TRANSMUTE_PTR_TO_REF, ALMOST_COMPLETE_RANGE, NEEDLESS_BORROW, DERIVABLE_IMPLS, MANUAL_IS_ASCII_CHECK, MANUAL_REM_EUCLID, MANUAL_RETAIN, TYPE_REPETITION_IN_BOUNDS, TUPLE_ARRAY_CONVERSIONS, MANUAL_TRY_FOLD, MANUAL_HASH_ONE.
252+
/// Lint: MANUAL_SPLIT_ONCE, MANUAL_STR_REPEAT, CLONED_INSTEAD_OF_COPIED, REDUNDANT_FIELD_NAMES, OPTION_MAP_UNWRAP_OR, REDUNDANT_STATIC_LIFETIMES, FILTER_MAP_NEXT, CHECKED_CONVERSIONS, MANUAL_RANGE_CONTAINS, USE_SELF, MEM_REPLACE_WITH_DEFAULT, MANUAL_NON_EXHAUSTIVE, OPTION_AS_REF_DEREF, MAP_UNWRAP_OR, MATCH_LIKE_MATCHES_MACRO, MANUAL_STRIP, MISSING_CONST_FOR_FN, UNNESTED_OR_PATTERNS, FROM_OVER_INTO, PTR_AS_PTR, IF_THEN_SOME_ELSE_NONE, APPROX_CONSTANT, DEPRECATED_CFG_ATTR, INDEX_REFUTABLE_SLICE, MAP_CLONE, BORROW_AS_PTR, MANUAL_BITS, ERR_EXPECT, CAST_ABS_TO_UNSIGNED, UNINLINED_FORMAT_ARGS, MANUAL_CLAMP, MANUAL_LET_ELSE, UNCHECKED_DURATION_SUBTRACTION, COLLAPSIBLE_STR_REPLACE, SEEK_FROM_CURRENT, SEEK_REWIND, UNNECESSARY_LAZY_EVALUATIONS, TRANSMUTE_PTR_TO_REF, ALMOST_COMPLETE_RANGE, NEEDLESS_BORROW, DERIVABLE_IMPLS, MANUAL_IS_ASCII_CHECK, MANUAL_REM_EUCLID, MANUAL_RETAIN, TYPE_REPETITION_IN_BOUNDS, TUPLE_ARRAY_CONVERSIONS, MANUAL_TRY_FOLD, MANUAL_HASH_ONE, ITER_KV_MAP.
253253
///
254254
/// The minimum rust version that the project supports. Defaults to the `rust-version` field in `Cargo.toml`
255255
#[default_text = ""]
@@ -543,6 +543,10 @@ define_Conf! {
543543
/// for _ in &mut *rmvec {}
544544
/// ```
545545
(enforce_iter_loop_reborrow: bool = false),
546+
/// Lint: MISSING_SAFETY_DOC, UNNECESSARY_SAFETY_DOC, MISSING_PANICS_DOC, MISSING_ERRORS_DOC
547+
///
548+
/// Whether to also run the listed lints on private items.
549+
(check_private_items: bool = false),
546550
}
547551

548552
/// Search for the configuration file.

src/tools/clippy/clippy_config/src/msrvs.rs

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ msrv_aliases! {
2323
1,62,0 { BOOL_THEN_SOME, DEFAULT_ENUM_ATTRIBUTE }
2424
1,58,0 { FORMAT_ARGS_CAPTURE, PATTERN_TRAIT_CHAR_ARRAY }
2525
1,55,0 { SEEK_REWIND }
26+
1,54,0 { INTO_KEYS }
2627
1,53,0 { OR_PATTERNS, MANUAL_BITS, BTREE_MAP_RETAIN, BTREE_SET_RETAIN, ARRAY_INTO_ITERATOR }
2728
1,52,0 { STR_SPLIT_ONCE, REM_EUCLID_CONST }
2829
1,51,0 { BORROW_AS_PTR, SEEK_FROM_CURRENT, UNSIGNED_ABS }

src/tools/clippy/clippy_dev/src/new_lint.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ fn get_lint_file_contents(lint: &LintData<'_>, enable_msrv: bool) -> String {
283283
use clippy_utils::msrvs::{{self, Msrv}};
284284
{pass_import}
285285
use rustc_lint::{{{context_import}, {pass_type}, LintContext}};
286-
use rustc_session::{{declare_tool_lint, impl_lint_pass}};
286+
use rustc_session::impl_lint_pass;
287287
288288
"#
289289
)
@@ -292,7 +292,7 @@ fn get_lint_file_contents(lint: &LintData<'_>, enable_msrv: bool) -> String {
292292
r#"
293293
{pass_import}
294294
use rustc_lint::{{{context_import}, {pass_type}}};
295-
use rustc_session::{{declare_lint_pass, declare_tool_lint}};
295+
use rustc_session::declare_lint_pass;
296296
297297
"#
298298
)

src/tools/clippy/clippy_lints/src/absolute_paths.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use rustc_hir::def::{DefKind, Res};
55
use rustc_hir::def_id::{DefId, CRATE_DEF_INDEX};
66
use rustc_hir::{HirId, ItemKind, Node, Path};
77
use rustc_lint::{LateContext, LateLintPass};
8-
use rustc_session::{declare_tool_lint, impl_lint_pass};
8+
use rustc_session::impl_lint_pass;
99
use rustc_span::symbol::kw;
1010

1111
declare_clippy_lint! {

src/tools/clippy/clippy_lints/src/allow_attributes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use rustc_ast as ast;
55
use rustc_errors::Applicability;
66
use rustc_lint::{LateContext, LateLintPass, LintContext};
77
use rustc_middle::lint::in_external_macro;
8-
use rustc_session::{declare_lint_pass, declare_tool_lint};
8+
use rustc_session::declare_lint_pass;
99

1010
declare_clippy_lint! {
1111
/// ### What it does

src/tools/clippy/clippy_lints/src/almost_complete_range.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use rustc_ast::ast::{Expr, ExprKind, LitKind, Pat, PatKind, RangeEnd, RangeLimit
55
use rustc_errors::Applicability;
66
use rustc_lint::{EarlyContext, EarlyLintPass, LintContext};
77
use rustc_middle::lint::in_external_macro;
8-
use rustc_session::{declare_tool_lint, impl_lint_pass};
8+
use rustc_session::impl_lint_pass;
99
use rustc_span::Span;
1010

1111
declare_clippy_lint! {

src/tools/clippy/clippy_lints/src/approx_const.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use rustc_ast::ast::{FloatTy, LitFloatType, LitKind};
44
use rustc_hir::{Expr, ExprKind};
55
use rustc_lint::{LateContext, LateLintPass};
66
use rustc_semver::RustcVersion;
7-
use rustc_session::{declare_tool_lint, impl_lint_pass};
7+
use rustc_session::impl_lint_pass;
88
use rustc_span::symbol;
99
use std::f64::consts as f64;
1010

src/tools/clippy/clippy_lints/src/arc_with_non_send_sync.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use rustc_lint::{LateContext, LateLintPass};
66
use rustc_middle::ty;
77
use rustc_middle::ty::print::with_forced_trimmed_paths;
88
use rustc_middle::ty::GenericArgKind;
9-
use rustc_session::{declare_lint_pass, declare_tool_lint};
9+
use rustc_session::declare_lint_pass;
1010
use rustc_span::symbol::sym;
1111

1212
declare_clippy_lint! {

src/tools/clippy/clippy_lints/src/as_conversions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use clippy_utils::is_from_proc_macro;
33
use rustc_hir::{Expr, ExprKind};
44
use rustc_lint::{LateContext, LateLintPass, LintContext};
55
use rustc_middle::lint::in_external_macro;
6-
use rustc_session::{declare_lint_pass, declare_tool_lint};
6+
use rustc_session::declare_lint_pass;
77

88
declare_clippy_lint! {
99
/// ### What it does

src/tools/clippy/clippy_lints/src/asm_syntax.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::fmt;
33
use clippy_utils::diagnostics::span_lint_and_help;
44
use rustc_ast::ast::{Expr, ExprKind, InlineAsmOptions};
55
use rustc_lint::{EarlyContext, EarlyLintPass, Lint};
6-
use rustc_session::{declare_lint_pass, declare_tool_lint};
6+
use rustc_session::declare_lint_pass;
77

88
#[derive(Clone, Copy, PartialEq, Eq)]
99
enum AsmStyle {

src/tools/clippy/clippy_lints/src/assertions_on_constants.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use clippy_utils::diagnostics::span_lint_and_help;
33
use clippy_utils::macros::{find_assert_args, root_macro_call_first_node, PanicExpn};
44
use rustc_hir::Expr;
55
use rustc_lint::{LateContext, LateLintPass};
6-
use rustc_session::{declare_lint_pass, declare_tool_lint};
6+
use rustc_session::declare_lint_pass;
77
use rustc_span::sym;
88

99
declare_clippy_lint! {

src/tools/clippy/clippy_lints/src/assertions_on_result_states.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use rustc_hir::def::Res;
99
use rustc_hir::{Expr, ExprKind};
1010
use rustc_lint::{LateContext, LateLintPass};
1111
use rustc_middle::ty::{self, Ty};
12-
use rustc_session::{declare_lint_pass, declare_tool_lint};
12+
use rustc_session::declare_lint_pass;
1313
use rustc_span::sym;
1414

1515
declare_clippy_lint! {

src/tools/clippy/clippy_lints/src/async_yields_async.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use clippy_utils::ty::implements_trait;
44
use rustc_errors::Applicability;
55
use rustc_hir::{Body, BodyId, CoroutineKind, CoroutineSource, ExprKind, QPath};
66
use rustc_lint::{LateContext, LateLintPass};
7-
use rustc_session::{declare_lint_pass, declare_tool_lint};
7+
use rustc_session::declare_lint_pass;
88

99
declare_clippy_lint! {
1010
/// ### What it does

src/tools/clippy/clippy_lints/src/attrs.rs

+30-9
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use rustc_hir::{
1717
use rustc_lint::{EarlyContext, EarlyLintPass, LateContext, LateLintPass, Level, LintContext};
1818
use rustc_middle::lint::in_external_macro;
1919
use rustc_middle::ty;
20-
use rustc_session::{declare_lint_pass, declare_tool_lint, impl_lint_pass};
20+
use rustc_session::{declare_lint_pass, impl_lint_pass};
2121
use rustc_span::symbol::Symbol;
2222
use rustc_span::{sym, Span, DUMMY_SP};
2323
use semver::Version;
@@ -120,7 +120,8 @@ declare_clippy_lint! {
120120
declare_clippy_lint! {
121121
/// ### What it does
122122
/// Checks for `#[deprecated]` annotations with a `since`
123-
/// field that is not a valid semantic version.
123+
/// field that is not a valid semantic version. Also allows "TBD" to signal
124+
/// future deprecation.
124125
///
125126
/// ### Why is this bad?
126127
/// For checking the version of the deprecation, it must be
@@ -405,20 +406,26 @@ declare_clippy_lint! {
405406
/// Checks for `#[cfg(features = "...")]` and suggests to replace it with
406407
/// `#[cfg(feature = "...")]`.
407408
///
409+
/// It also checks if `cfg(test)` was misspelled.
410+
///
408411
/// ### Why is this bad?
409-
/// Misspelling `feature` as `features` can be sometimes hard to spot. It
412+
/// Misspelling `feature` as `features` or `test` as `tests` can be sometimes hard to spot. It
410413
/// may cause conditional compilation not work quietly.
411414
///
412415
/// ### Example
413416
/// ```no_run
414417
/// #[cfg(features = "some-feature")]
415418
/// fn conditional() { }
419+
/// #[cfg(tests)]
420+
/// mod tests { }
416421
/// ```
417422
///
418423
/// Use instead:
419424
/// ```no_run
420425
/// #[cfg(feature = "some-feature")]
421426
/// fn conditional() { }
427+
/// #[cfg(test)]
428+
/// mod tests { }
422429
/// ```
423430
#[clippy::version = "1.69.0"]
424431
pub MAYBE_MISUSED_CFG,
@@ -473,7 +480,7 @@ impl<'tcx> LateLintPass<'tcx> for Attributes {
473480
&& let MetaItemKind::NameValue(lit) = &mi.kind
474481
&& mi.has_name(sym::since)
475482
{
476-
check_semver(cx, item.span(), lit);
483+
check_deprecated_since(cx, item.span(), lit);
477484
}
478485
}
479486
}
@@ -754,9 +761,9 @@ fn check_attrs(cx: &LateContext<'_>, span: Span, name: Symbol, attrs: &[Attribut
754761
}
755762
}
756763

757-
fn check_semver(cx: &LateContext<'_>, span: Span, lit: &MetaItemLit) {
764+
fn check_deprecated_since(cx: &LateContext<'_>, span: Span, lit: &MetaItemLit) {
758765
if let LitKind::Str(is, _) = lit.kind {
759-
if Version::parse(is.as_str()).is_ok() {
766+
if is.as_str() == "TBD" || Version::parse(is.as_str()).is_ok() {
760767
return;
761768
}
762769
}
@@ -923,21 +930,35 @@ fn check_nested_cfg(cx: &EarlyContext<'_>, items: &[NestedMetaItem]) {
923930
fn check_nested_misused_cfg(cx: &EarlyContext<'_>, items: &[NestedMetaItem]) {
924931
for item in items {
925932
if let NestedMetaItem::MetaItem(meta) = item {
926-
if meta.has_name(sym!(features))
933+
if let Some(ident) = meta.ident()
934+
&& ident.name.as_str() == "features"
927935
&& let Some(val) = meta.value_str()
928936
{
929937
span_lint_and_sugg(
930938
cx,
931939
MAYBE_MISUSED_CFG,
932940
meta.span,
933-
"feature may misspelled as features",
934-
"use",
941+
"'feature' may be misspelled as 'features'",
942+
"did you mean",
935943
format!("feature = \"{val}\""),
936944
Applicability::MaybeIncorrect,
937945
);
938946
}
939947
if let MetaItemKind::List(list) = &meta.kind {
940948
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+
"did you mean",
959+
"test".to_string(),
960+
Applicability::MaybeIncorrect,
961+
);
941962
}
942963
}
943964
}

src/tools/clippy/clippy_lints/src/await_holding_invalid.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use rustc_hir::def_id::DefId;
66
use rustc_hir::{Body, CoroutineKind, CoroutineSource};
77
use rustc_lint::{LateContext, LateLintPass};
88
use rustc_middle::mir::CoroutineLayout;
9-
use rustc_session::{declare_tool_lint, impl_lint_pass};
9+
use rustc_session::impl_lint_pass;
1010
use rustc_span::{sym, Span};
1111

1212
declare_clippy_lint! {

src/tools/clippy/clippy_lints/src/blocks_in_if_conditions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use rustc_errors::Applicability;
88
use rustc_hir::{BlockCheckMode, Expr, ExprKind};
99
use rustc_lint::{LateContext, LateLintPass, LintContext};
1010
use rustc_middle::lint::in_external_macro;
11-
use rustc_session::{declare_lint_pass, declare_tool_lint};
11+
use rustc_session::declare_lint_pass;
1212
use rustc_span::sym;
1313

1414
declare_clippy_lint! {

src/tools/clippy/clippy_lints/src/bool_assert_comparison.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use rustc_errors::Applicability;
77
use rustc_hir::{Expr, ExprKind, Lit};
88
use rustc_lint::{LateContext, LateLintPass, LintContext};
99
use rustc_middle::ty::{self, Ty};
10-
use rustc_session::{declare_lint_pass, declare_tool_lint};
10+
use rustc_session::declare_lint_pass;
1111
use rustc_span::symbol::Ident;
1212

1313
declare_clippy_lint! {

src/tools/clippy/clippy_lints/src/bool_to_int_with_if.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use clippy_utils::higher::If;
22
use rustc_ast::LitKind;
33
use rustc_hir::{Block, ExprKind};
44
use rustc_lint::{LateContext, LateLintPass};
5-
use rustc_session::{declare_lint_pass, declare_tool_lint};
5+
use rustc_session::declare_lint_pass;
66

77
use clippy_utils::diagnostics::span_lint_and_then;
88
use clippy_utils::sugg::Sugg;

src/tools/clippy/clippy_lints/src/booleans.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use rustc_errors::Applicability;
77
use rustc_hir::intravisit::{walk_expr, FnKind, Visitor};
88
use rustc_hir::{BinOpKind, Body, Expr, ExprKind, FnDecl, UnOp};
99
use rustc_lint::{LateContext, LateLintPass, Level};
10-
use rustc_session::{declare_lint_pass, declare_tool_lint};
10+
use rustc_session::declare_lint_pass;
1111
use rustc_span::def_id::LocalDefId;
1212
use rustc_span::{sym, Span};
1313

src/tools/clippy/clippy_lints/src/borrow_deref_ref.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use rustc_hir::{ExprKind, UnOp};
88
use rustc_lint::{LateContext, LateLintPass};
99
use rustc_middle::mir::Mutability;
1010
use rustc_middle::ty;
11-
use rustc_session::{declare_lint_pass, declare_tool_lint};
11+
use rustc_session::declare_lint_pass;
1212

1313
declare_clippy_lint! {
1414
/// ### What it does

0 commit comments

Comments
 (0)