Skip to content

Clippy subtree sync #118507

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 123 commits into from
Dec 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
123 commits
Select commit Hold shift + click to select a range
c9d2961
teach `eager_or_lazy` that arithmetic ops can panic
y21 Jun 21, 2023
39eded7
Lint `flatten()` under `lines_filter_map_ok`
sjwang05 Oct 20, 2023
1032009
Use `match` on method args instead of `if let`
sjwang05 Oct 30, 2023
10f3977
Split arg/method checking into its own function
sjwang05 Oct 30, 2023
c50af35
Use `fm_method_str` in lint formatting
sjwang05 Nov 3, 2023
4388158
Fix formatting
sjwang05 Nov 3, 2023
d8c0e64
Make `macro_use_imports` lint ordering more stable
Alexendoo Nov 9, 2023
5f651da
fix iter_kv_map dont suggest into_keys and into_values if msrv is to low
matthri Nov 3, 2023
bb69461
[`ptr_arg`]: recognize methods that also exist on slices
y21 Nov 15, 2023
3e83a52
replace `Vec` with slice in lintcheck
y21 Nov 15, 2023
ef587d2
[`redundant_guards`]: lint empty string checks
y21 Nov 15, 2023
998a311
[`redundant_guards`]: lint empty slice checks
y21 Nov 15, 2023
676f1f6
[`redundant_guards`]: lint `slice::{starts_with,ends_with}`
y21 Nov 15, 2023
1b4e2ef
fix empty needle corner case and add tests
y21 Nov 15, 2023
8f9c738
dogfood clippy
y21 Nov 15, 2023
23ee332
lint when relevant sides of binops are constants
y21 Nov 14, 2023
1e0597c
[`match_same_arms`]: respect allow attrs on arms
y21 Nov 16, 2023
7696c9d
allow more div and rem operations that can be checked
y21 Nov 16, 2023
74451cd
Extend `maybe_misused_cfg` lint over `cfg(test)`
GuillaumeGomez Nov 16, 2023
a621d71
Add UI test for mispelled `test`
GuillaumeGomez Nov 16, 2023
f08037c
Update documentation for `MAYBE_MISUSED_CFG` lint
GuillaumeGomez Nov 16, 2023
6246f04
Merge commit 'edb720b199083f4107b858a8761648065bf38d86' into clippyup
flip1995 Nov 16, 2023
8d89cc4
Update rust-cache GHA in deploy workflow
flip1995 Nov 16, 2023
edefa97
Auto merge of #11824 - flip1995:ci-update-rust-cache-gha, r=Alexendoo
bors Nov 16, 2023
aca4086
simplify matching on binop result
y21 Nov 16, 2023
aec4e81
Move `lint_store` from `GlobalCtxt` to `Session`.
nnethercote Nov 6, 2023
4143acf
fix typo
CleanCut Nov 17, 2023
8c6c542
rename bound region instantiation
lcnr Nov 17, 2023
25f4f85
Auto merge of #11828 - CleanCut:patch-1, r=xFrednet
bors Nov 17, 2023
31e38fe
Auto merge of #11821 - GuillaumeGomez:misspelled-cfg, r=blyxyas
bors Nov 17, 2023
bffb664
Fix markup in recent lint documentation.
kpreid Nov 16, 2023
e8e9510
Auto merge of #11002 - y21:issue9422, r=Jarcho
bors Nov 17, 2023
a2e396b
Don't suggest `a.mul_add(b, c)` if parameters are not float
lukaslueg Nov 18, 2023
b3f4a90
Remove space and rephrase `map()` advice.
kpreid Nov 18, 2023
6eb935a
Auto merge of #11826 - kpreid:typo, r=Alexendoo
bors Nov 18, 2023
9263f80
Auto merge of #11782 - Alexendoo:macro-use-imports-ordering, r=Centri3
bors Nov 19, 2023
dbd19f9
Auto merge of #11691 - sjwang05:lines-filter-map-ok-fix, r=Centri3
bors Nov 19, 2023
3c1e0af
New Lint [`impl_hash_with_borrow_str_and_bytes`]
PartiallyUntyped Nov 19, 2023
9c3a365
Auto merge of #11781 - partiallytyped:11710, r=xFrednet
bors Nov 19, 2023
82babe0
Don't sort `span_suggestions`, leave that to caller
estebank Nov 8, 2023
dfbca7f
Improve `maybe_misused_cfg` lint output
GuillaumeGomez Nov 18, 2023
41140e3
Auto merge of #11840 - GuillaumeGomez:improve-maybe_misused_cfg, r=bl…
bors Nov 19, 2023
56cee3c
move `doc.rs` to its own subdirectory
y21 Nov 15, 2023
34d9e88
New lint `clippy::join_absolute_paths`
ofeeg Sep 2, 2023
11a2eb0
Auto merge of #11453 - xFrednet:11208-path-join-correct, r=blyxyas
bors Nov 20, 2023
72c0d80
Auto merge of #11801 - y21:split_doc_pass, r=blyxyas
bors Nov 20, 2023
abd9deb
[`missing_safety_doc`], [`unnecessary_safety_doc`], [`missing_panics_…
GuillaumeGomez Nov 19, 2023
5cdda53
Add ui test for `check_private_items` config
GuillaumeGomez Nov 19, 2023
4d56366
Auto merge of #11842 - GuillaumeGomez:check_private_items-config, r=b…
bors Nov 21, 2023
a74fa97
[`needless_return_with_question_mark`]: dont lint in case of coercion
y21 Oct 6, 2023
2fa87fb
Add tests for issues #10285, #10286, #10289, #10287
GuillaumeGomez Nov 21, 2023
43d8d51
Allow `#[deprecated(since = "TBD")]`
Noratrieb Nov 21, 2023
fa7cd25
Update itertools to 0.11.
nnethercote Nov 13, 2023
a8b0e5f
Auto merge of #11627 - y21:issue11616, r=giraffate
bors Nov 22, 2023
b21c9d4
Auto merge of #11849 - GuillaumeGomez:add-more-transmute_ref_to_ref-t…
bors Nov 22, 2023
91fc4b3
Remove underscore check for `manual_non_exhaustive` lint
GuillaumeGomez Nov 20, 2023
a72730e
Auto merge of #11844 - GuillaumeGomez:manual_non_exhaustive-rm-unders…
bors Nov 22, 2023
a20f61b
add iter_kv_map to msrv config
matthri Nov 4, 2023
c24784e
Auto merge of #11757 - matthri:iter-kv-map-msrv-fix, r=Alexendoo
bors Nov 22, 2023
c18e6ab
Add documentation update hint
matthri Nov 23, 2023
553857b
check on a per-body level instead of blocks independently
y21 Nov 23, 2023
30c743f
Auto merge of #11857 - matthri:add-collect-metadata-note, r=flip1995
bors Nov 23, 2023
2817c5f
Extend `result_map_or_into_option` lint to handle `Result::map_or_els…
GuillaumeGomez Nov 20, 2023
5d330d0
Add new test for `result_map_or_into_option` extension
GuillaumeGomez Nov 20, 2023
840e227
Auto merge of #11845 - GuillaumeGomez:result_map_or_into_option-exten…
bors Nov 23, 2023
6c84b96
Improve error messages format
GuillaumeGomez Nov 23, 2023
c3243f9
Auto merge of #11860 - GuillaumeGomez:improve-error-messages, r=flip1995
bors Nov 23, 2023
447edf9
suggest alternatives to iterate an array of ranges
christophbeberweil Nov 23, 2023
c58d692
fix: 7125 update lint applicability to Unspecified
christophbeberweil Nov 24, 2023
2512341
feat: 7125 shorten lint text
christophbeberweil Nov 24, 2023
4937fba
Nit re `matches!` formatting
smoelius Nov 24, 2023
96eab06
Auto merge of #11859 - y21:issue11856, r=blyxyas
bors Nov 24, 2023
e075823
Auto merge of #11850 - Nilstrieb:tbd, r=dswij
bors Nov 24, 2023
3e7a63b
Auto merge of #11863 - smoelius:patch-1, r=dswij
bors Nov 24, 2023
bce869f
fix: 7125 lint message should start with a small letter
christophbeberweil Nov 24, 2023
f9c6335
feat: 7125 code snippets are wrapped in backticks
christophbeberweil Nov 24, 2023
ea73317
Create new lint `option_map_or_err_ok`
GuillaumeGomez Nov 24, 2023
3a3773f
Add test for `option_map_or_err_ok` lint
GuillaumeGomez Nov 24, 2023
ef38969
Update changelog to add new `option_map_or_err_ok` lint
GuillaumeGomez Nov 24, 2023
6cfbe57
Auto merge of #11862 - christophbeberweil:7125-single-element-loop-ov…
bors Nov 24, 2023
c2c7318
Bless clippy tests
Noratrieb Nov 21, 2023
191e1bc
Manual find replace updates
Noratrieb Nov 21, 2023
148cd04
Simplify code for `result_map_or_else_none`
GuillaumeGomez Nov 25, 2023
fbf13ce
Auto merge of #11866 - GuillaumeGomez:simplify-code-result_map_or_els…
bors Nov 25, 2023
3664d63
Auto merge of #11864 - GuillaumeGomez:option_map_or_err_ok, r=flip1995
bors Nov 25, 2023
bafa200
rustc: Make `def_kind` mandatory for all `DefId`s
petrochenkov Nov 23, 2023
5689a86
move `implied_bounds_in_impls` to complexity
y21 Nov 25, 2023
7093444
Use absolute path for `declare_tool_lint` in `declare_clippy_lint`
Alexendoo Nov 25, 2023
fffee10
Appease the clippy
compiler-errors Nov 23, 2023
a79a7d6
Auto merge of #118250 - petrochenkov:optdefkind, r=compiler-errors
bors Nov 26, 2023
bf86fe1
rustc: `hir().local_def_id_to_hir_id()` -> `tcx.local_def_id_to_hir_i…
petrochenkov Nov 24, 2023
7af811b
Auto merge of #11870 - Alexendoo:declare-clippy-lint-absolute-path, r…
bors Nov 26, 2023
23d5332
Fix `box_default` behaviour with empty `vec![]` coming from macro arg
samueltardieu Nov 26, 2023
a7c59ab
`TypeckResults::node_type()` can be used inside of bodies
samueltardieu Nov 26, 2023
0d09cb0
`manual_try_fold`: check that `fold` is really `Iterator::fold`
samueltardieu Nov 26, 2023
2c56b4f
Auto merge of #11875 - samueltardieu:fix-11868, r=Jarcho
bors Nov 26, 2023
f30a859
Auto merge of #11867 - y21:implied_bounds_in_impls_complexity, r=Jarcho
bors Nov 26, 2023
5ba6480
Auto merge of #11877 - samueltardieu:doc-fix, r=flip1995
bors Nov 27, 2023
1661e7e
re-implement fix for rust-lang#11357
KisaragiEffective Nov 27, 2023
1acd806
remove double-paren on test case
KisaragiEffective Nov 27, 2023
40b6aa0
cargo uibless
KisaragiEffective Nov 27, 2023
3318249
don't add paren on occurrences that is in call args
KisaragiEffective Nov 27, 2023
0426913
fix dogfood
KisaragiEffective Nov 27, 2023
caa7394
Auto merge of #11879 - samueltardieu:issue-11876, r=Alexendoo
bors Nov 27, 2023
003e910
Auto merge of #11817 - y21:ptr_arg_mut_ref, r=Alexendoo
bors Nov 27, 2023
e6f3390
Auto merge of #11836 - lukaslueg:issue11831, r=Alexendoo
bors Nov 27, 2023
684c4bf
Rework `ast::BinOpKind::to_string` and `ast::UnOp::to_string`.
nnethercote Nov 27, 2023
0565267
rename `DocMarkdown` to `Documentation`
y21 Nov 28, 2023
91c5653
Auto merge of #11892 - y21:actually_rename_doc_for_real_this_time, r=…
bors Nov 28, 2023
57397a5
Auto merge of #11363 - KisaragiEffective:fix_redundant_closure_call_o…
bors Nov 28, 2023
0ba9bf9
add lint against unit tests in doctests
llogiq Nov 26, 2023
02e50f0
Add `never_patterns` feature gate
Nadrieril Nov 22, 2023
071f8f6
Rollup merge of #118157 - Nadrieril:never_pat-feature-gate, r=compile…
matthiaskrgr Nov 29, 2023
8b0bf64
Auto merge of #11818 - y21:more_redundant_guards, r=llogiq
bors Nov 29, 2023
e3c73f1
`option_if_let_else`: do not trigger on expressions returning `()`
samueltardieu Nov 29, 2023
665fd52
Auto merge of #11872 - llogiq:test-attr-in-doctest, r=xFrednet
bors Nov 30, 2023
646b28f
Auto merge of #11896 - samueltardieu:issue-11893, r=Alexendoo
bors Nov 30, 2023
2cda044
Allow `allow`ing `upper_case_acronyms` on enum variants
clubby789 Nov 30, 2023
d166fab
Auto merge of #11898 - clubby789:upper_case_acronyms_variants, r=Mani…
bors Dec 1, 2023
a9867e1
Merge remote-tracking branch 'upstream/master' into rustup
flip1995 Dec 1, 2023
9d36c18
Bump nightly version -> 2023-12-01
flip1995 Dec 1, 2023
f0cdee4
Auto merge of #11903 - flip1995:rustup, r=flip1995
bors Dec 1, 2023
6ae8003
Merge commit 'f0cdee4a3f094416189261481eae374b76792af1' into clippy-s…
flip1995 Dec 1, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 3 additions & 1 deletion src/tools/clippy/.github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ jobs:
run: cargo generate-lockfile

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

- name: cargo collect-metadata
run: cargo collect-metadata
Expand Down
5 changes: 5 additions & 0 deletions src/tools/clippy/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5128,6 +5128,7 @@ Released 2018-09-13
[`if_then_some_else_none`]: https://rust-lang.github.io/rust-clippy/master/index.html#if_then_some_else_none
[`ifs_same_cond`]: https://rust-lang.github.io/rust-clippy/master/index.html#ifs_same_cond
[`ignored_unit_patterns`]: https://rust-lang.github.io/rust-clippy/master/index.html#ignored_unit_patterns
[`impl_hash_borrow_with_str_and_bytes`]: https://rust-lang.github.io/rust-clippy/master/index.html#impl_hash_borrow_with_str_and_bytes
[`impl_trait_in_params`]: https://rust-lang.github.io/rust-clippy/master/index.html#impl_trait_in_params
[`implicit_clone`]: https://rust-lang.github.io/rust-clippy/master/index.html#implicit_clone
[`implicit_hasher`]: https://rust-lang.github.io/rust-clippy/master/index.html#implicit_hasher
Expand Down Expand Up @@ -5189,6 +5190,7 @@ Released 2018-09-13
[`iter_with_drain`]: https://rust-lang.github.io/rust-clippy/master/index.html#iter_with_drain
[`iter_without_into_iter`]: https://rust-lang.github.io/rust-clippy/master/index.html#iter_without_into_iter
[`iterator_step_by_zero`]: https://rust-lang.github.io/rust-clippy/master/index.html#iterator_step_by_zero
[`join_absolute_paths`]: https://rust-lang.github.io/rust-clippy/master/index.html#join_absolute_paths
[`just_underscores_and_digits`]: https://rust-lang.github.io/rust-clippy/master/index.html#just_underscores_and_digits
[`large_const_arrays`]: https://rust-lang.github.io/rust-clippy/master/index.html#large_const_arrays
[`large_digit_groups`]: https://rust-lang.github.io/rust-clippy/master/index.html#large_digit_groups
Expand Down Expand Up @@ -5380,6 +5382,7 @@ Released 2018-09-13
[`option_expect_used`]: https://rust-lang.github.io/rust-clippy/master/index.html#option_expect_used
[`option_filter_map`]: https://rust-lang.github.io/rust-clippy/master/index.html#option_filter_map
[`option_if_let_else`]: https://rust-lang.github.io/rust-clippy/master/index.html#option_if_let_else
[`option_map_or_err_ok`]: https://rust-lang.github.io/rust-clippy/master/index.html#option_map_or_err_ok
[`option_map_or_none`]: https://rust-lang.github.io/rust-clippy/master/index.html#option_map_or_none
[`option_map_unit_fn`]: https://rust-lang.github.io/rust-clippy/master/index.html#option_map_unit_fn
[`option_map_unwrap_or`]: https://rust-lang.github.io/rust-clippy/master/index.html#option_map_unwrap_or
Expand Down Expand Up @@ -5542,6 +5545,7 @@ Released 2018-09-13
[`tabs_in_doc_comments`]: https://rust-lang.github.io/rust-clippy/master/index.html#tabs_in_doc_comments
[`temporary_assignment`]: https://rust-lang.github.io/rust-clippy/master/index.html#temporary_assignment
[`temporary_cstring_as_ptr`]: https://rust-lang.github.io/rust-clippy/master/index.html#temporary_cstring_as_ptr
[`test_attr_in_doctest`]: https://rust-lang.github.io/rust-clippy/master/index.html#test_attr_in_doctest
[`tests_outside_test_module`]: https://rust-lang.github.io/rust-clippy/master/index.html#tests_outside_test_module
[`to_digit_is_some`]: https://rust-lang.github.io/rust-clippy/master/index.html#to_digit_is_some
[`to_string_in_display`]: https://rust-lang.github.io/rust-clippy/master/index.html#to_string_in_display
Expand Down Expand Up @@ -5738,4 +5742,5 @@ Released 2018-09-13
[`absolute-paths-allowed-crates`]: https://doc.rust-lang.org/clippy/lint_configuration.html#absolute-paths-allowed-crates
[`allowed-dotfiles`]: https://doc.rust-lang.org/clippy/lint_configuration.html#allowed-dotfiles
[`enforce-iter-loop-reborrow`]: https://doc.rust-lang.org/clippy/lint_configuration.html#enforce-iter-loop-reborrow
[`check-private-items`]: https://doc.rust-lang.org/clippy/lint_configuration.html#check-private-items
<!-- end autogenerated links to configuration documentation -->
4 changes: 3 additions & 1 deletion src/tools/clippy/book/src/development/adding_lints.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ is. This file has already imported some initial things we will need:

```rust
use rustc_lint::{EarlyLintPass, EarlyContext};
use rustc_session::{declare_lint_pass, declare_tool_lint};
use rustc_session::declare_lint_pass;
use rustc_ast::ast::*;
```

Expand Down Expand Up @@ -518,6 +518,8 @@ define_Conf! {

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

Afterwards update the documentation for the book as described in [Adding configuration to a lint](#adding-configuration-to-a-lint).

## Author lint

If you have trouble implementing your lint, there is also the internal `author`
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/book/src/development/type_checking.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ an `u32`. As far as `hir::Ty` is concerned those might be different types. But a
understands that they're the same type, in-depth lifetimes, etc...

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
outside of bodies the [`TypeckResults::node_type()`][node_type] method.
the [`TypeckResults::node_type()`][node_type] method inside of bodies.

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

Expand Down
14 changes: 14 additions & 0 deletions src/tools/clippy/book/src/lint_configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ The minimum rust version that the project supports. Defaults to the `rust-versio
* [`tuple_array_conversions`](https://rust-lang.github.io/rust-clippy/master/index.html#tuple_array_conversions)
* [`manual_try_fold`](https://rust-lang.github.io/rust-clippy/master/index.html#manual_try_fold)
* [`manual_hash_one`](https://rust-lang.github.io/rust-clippy/master/index.html#manual_hash_one)
* [`iter_kv_map`](https://rust-lang.github.io/rust-clippy/master/index.html#iter_kv_map)


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


## `check-private-items`


**Default Value:** `false`

---
**Affected lints:**
* [`missing_safety_doc`](https://rust-lang.github.io/rust-clippy/master/index.html#missing_safety_doc)
* [`unnecessary_safety_doc`](https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_safety_doc)
* [`missing_panics_doc`](https://rust-lang.github.io/rust-clippy/master/index.html#missing_panics_doc)
* [`missing_errors_doc`](https://rust-lang.github.io/rust-clippy/master/index.html#missing_errors_doc)


6 changes: 5 additions & 1 deletion src/tools/clippy/clippy_config/src/conf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ define_Conf! {
///
/// Suppress lints whenever the suggested change would cause breakage for other crates.
(avoid_breaking_exported_api: bool = true),
/// 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.
/// 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.
///
/// The minimum rust version that the project supports. Defaults to the `rust-version` field in `Cargo.toml`
#[default_text = ""]
Expand Down Expand Up @@ -543,6 +543,10 @@ define_Conf! {
/// for _ in &mut *rmvec {}
/// ```
(enforce_iter_loop_reborrow: bool = false),
/// Lint: MISSING_SAFETY_DOC, UNNECESSARY_SAFETY_DOC, MISSING_PANICS_DOC, MISSING_ERRORS_DOC
///
/// Whether to also run the listed lints on private items.
(check_private_items: bool = false),
}

/// Search for the configuration file.
Expand Down
1 change: 1 addition & 0 deletions src/tools/clippy/clippy_config/src/msrvs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ msrv_aliases! {
1,62,0 { BOOL_THEN_SOME, DEFAULT_ENUM_ATTRIBUTE }
1,58,0 { FORMAT_ARGS_CAPTURE, PATTERN_TRAIT_CHAR_ARRAY }
1,55,0 { SEEK_REWIND }
1,54,0 { INTO_KEYS }
1,53,0 { OR_PATTERNS, MANUAL_BITS, BTREE_MAP_RETAIN, BTREE_SET_RETAIN, ARRAY_INTO_ITERATOR }
1,52,0 { STR_SPLIT_ONCE, REM_EUCLID_CONST }
1,51,0 { BORROW_AS_PTR, SEEK_FROM_CURRENT, UNSIGNED_ABS }
Expand Down
4 changes: 2 additions & 2 deletions src/tools/clippy/clippy_dev/src/new_lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ fn get_lint_file_contents(lint: &LintData<'_>, enable_msrv: bool) -> String {
use clippy_utils::msrvs::{{self, Msrv}};
{pass_import}
use rustc_lint::{{{context_import}, {pass_type}, LintContext}};
use rustc_session::{{declare_tool_lint, impl_lint_pass}};
use rustc_session::impl_lint_pass;

"#
)
Expand All @@ -292,7 +292,7 @@ fn get_lint_file_contents(lint: &LintData<'_>, enable_msrv: bool) -> String {
r#"
{pass_import}
use rustc_lint::{{{context_import}, {pass_type}}};
use rustc_session::{{declare_lint_pass, declare_tool_lint}};
use rustc_session::declare_lint_pass;

"#
)
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/clippy_lints/src/absolute_paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use rustc_hir::def::{DefKind, Res};
use rustc_hir::def_id::{DefId, CRATE_DEF_INDEX};
use rustc_hir::{HirId, ItemKind, Node, Path};
use rustc_lint::{LateContext, LateLintPass};
use rustc_session::{declare_tool_lint, impl_lint_pass};
use rustc_session::impl_lint_pass;
use rustc_span::symbol::kw;

declare_clippy_lint! {
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/clippy_lints/src/allow_attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use rustc_ast as ast;
use rustc_errors::Applicability;
use rustc_lint::{LateContext, LateLintPass, LintContext};
use rustc_middle::lint::in_external_macro;
use rustc_session::{declare_lint_pass, declare_tool_lint};
use rustc_session::declare_lint_pass;

declare_clippy_lint! {
/// ### What it does
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/clippy_lints/src/almost_complete_range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use rustc_ast::ast::{Expr, ExprKind, LitKind, Pat, PatKind, RangeEnd, RangeLimit
use rustc_errors::Applicability;
use rustc_lint::{EarlyContext, EarlyLintPass, LintContext};
use rustc_middle::lint::in_external_macro;
use rustc_session::{declare_tool_lint, impl_lint_pass};
use rustc_session::impl_lint_pass;
use rustc_span::Span;

declare_clippy_lint! {
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/clippy_lints/src/approx_const.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use rustc_ast::ast::{FloatTy, LitFloatType, LitKind};
use rustc_hir::{Expr, ExprKind};
use rustc_lint::{LateContext, LateLintPass};
use rustc_semver::RustcVersion;
use rustc_session::{declare_tool_lint, impl_lint_pass};
use rustc_session::impl_lint_pass;
use rustc_span::symbol;
use std::f64::consts as f64;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use rustc_lint::{LateContext, LateLintPass};
use rustc_middle::ty;
use rustc_middle::ty::print::with_forced_trimmed_paths;
use rustc_middle::ty::GenericArgKind;
use rustc_session::{declare_lint_pass, declare_tool_lint};
use rustc_session::declare_lint_pass;
use rustc_span::symbol::sym;

declare_clippy_lint! {
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/clippy_lints/src/as_conversions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use clippy_utils::is_from_proc_macro;
use rustc_hir::{Expr, ExprKind};
use rustc_lint::{LateContext, LateLintPass, LintContext};
use rustc_middle::lint::in_external_macro;
use rustc_session::{declare_lint_pass, declare_tool_lint};
use rustc_session::declare_lint_pass;

declare_clippy_lint! {
/// ### What it does
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/clippy_lints/src/asm_syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::fmt;
use clippy_utils::diagnostics::span_lint_and_help;
use rustc_ast::ast::{Expr, ExprKind, InlineAsmOptions};
use rustc_lint::{EarlyContext, EarlyLintPass, Lint};
use rustc_session::{declare_lint_pass, declare_tool_lint};
use rustc_session::declare_lint_pass;

#[derive(Clone, Copy, PartialEq, Eq)]
enum AsmStyle {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use clippy_utils::diagnostics::span_lint_and_help;
use clippy_utils::macros::{find_assert_args, root_macro_call_first_node, PanicExpn};
use rustc_hir::Expr;
use rustc_lint::{LateContext, LateLintPass};
use rustc_session::{declare_lint_pass, declare_tool_lint};
use rustc_session::declare_lint_pass;
use rustc_span::sym;

declare_clippy_lint! {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use rustc_hir::def::Res;
use rustc_hir::{Expr, ExprKind};
use rustc_lint::{LateContext, LateLintPass};
use rustc_middle::ty::{self, Ty};
use rustc_session::{declare_lint_pass, declare_tool_lint};
use rustc_session::declare_lint_pass;
use rustc_span::sym;

declare_clippy_lint! {
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/clippy_lints/src/async_yields_async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use clippy_utils::ty::implements_trait;
use rustc_errors::Applicability;
use rustc_hir::{Body, BodyId, CoroutineKind, CoroutineSource, ExprKind, QPath};
use rustc_lint::{LateContext, LateLintPass};
use rustc_session::{declare_lint_pass, declare_tool_lint};
use rustc_session::declare_lint_pass;

declare_clippy_lint! {
/// ### What it does
Expand Down
39 changes: 30 additions & 9 deletions src/tools/clippy/clippy_lints/src/attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use rustc_hir::{
use rustc_lint::{EarlyContext, EarlyLintPass, LateContext, LateLintPass, Level, LintContext};
use rustc_middle::lint::in_external_macro;
use rustc_middle::ty;
use rustc_session::{declare_lint_pass, declare_tool_lint, impl_lint_pass};
use rustc_session::{declare_lint_pass, impl_lint_pass};
use rustc_span::symbol::Symbol;
use rustc_span::{sym, Span, DUMMY_SP};
use semver::Version;
Expand Down Expand Up @@ -120,7 +120,8 @@ declare_clippy_lint! {
declare_clippy_lint! {
/// ### What it does
/// Checks for `#[deprecated]` annotations with a `since`
/// field that is not a valid semantic version.
/// field that is not a valid semantic version. Also allows "TBD" to signal
/// future deprecation.
///
/// ### Why is this bad?
/// For checking the version of the deprecation, it must be
Expand Down Expand Up @@ -405,20 +406,26 @@ declare_clippy_lint! {
/// 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` can be sometimes hard to spot. It
/// 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,
Expand Down Expand Up @@ -473,7 +480,7 @@ impl<'tcx> LateLintPass<'tcx> for Attributes {
&& let MetaItemKind::NameValue(lit) = &mi.kind
&& mi.has_name(sym::since)
{
check_semver(cx, item.span(), lit);
check_deprecated_since(cx, item.span(), lit);
}
}
}
Expand Down Expand Up @@ -754,9 +761,9 @@ fn check_attrs(cx: &LateContext<'_>, span: Span, name: Symbol, attrs: &[Attribut
}
}

fn check_semver(cx: &LateContext<'_>, span: Span, lit: &MetaItemLit) {
fn check_deprecated_since(cx: &LateContext<'_>, span: Span, lit: &MetaItemLit) {
if let LitKind::Str(is, _) = lit.kind {
if Version::parse(is.as_str()).is_ok() {
if is.as_str() == "TBD" || Version::parse(is.as_str()).is_ok() {
return;
}
}
Expand Down Expand Up @@ -923,21 +930,35 @@ 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,
);
}
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,
);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/clippy_lints/src/await_holding_invalid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use rustc_hir::def_id::DefId;
use rustc_hir::{Body, CoroutineKind, CoroutineSource};
use rustc_lint::{LateContext, LateLintPass};
use rustc_middle::mir::CoroutineLayout;
use rustc_session::{declare_tool_lint, impl_lint_pass};
use rustc_session::impl_lint_pass;
use rustc_span::{sym, Span};

declare_clippy_lint! {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use rustc_errors::Applicability;
use rustc_hir::{BlockCheckMode, Expr, ExprKind};
use rustc_lint::{LateContext, LateLintPass, LintContext};
use rustc_middle::lint::in_external_macro;
use rustc_session::{declare_lint_pass, declare_tool_lint};
use rustc_session::declare_lint_pass;
use rustc_span::sym;

declare_clippy_lint! {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use rustc_errors::Applicability;
use rustc_hir::{Expr, ExprKind, Lit};
use rustc_lint::{LateContext, LateLintPass, LintContext};
use rustc_middle::ty::{self, Ty};
use rustc_session::{declare_lint_pass, declare_tool_lint};
use rustc_session::declare_lint_pass;
use rustc_span::symbol::Ident;

declare_clippy_lint! {
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/clippy_lints/src/bool_to_int_with_if.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use clippy_utils::higher::If;
use rustc_ast::LitKind;
use rustc_hir::{Block, ExprKind};
use rustc_lint::{LateContext, LateLintPass};
use rustc_session::{declare_lint_pass, declare_tool_lint};
use rustc_session::declare_lint_pass;

use clippy_utils::diagnostics::span_lint_and_then;
use clippy_utils::sugg::Sugg;
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/clippy_lints/src/booleans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use rustc_errors::Applicability;
use rustc_hir::intravisit::{walk_expr, FnKind, Visitor};
use rustc_hir::{BinOpKind, Body, Expr, ExprKind, FnDecl, UnOp};
use rustc_lint::{LateContext, LateLintPass, Level};
use rustc_session::{declare_lint_pass, declare_tool_lint};
use rustc_session::declare_lint_pass;
use rustc_span::def_id::LocalDefId;
use rustc_span::{sym, Span};

Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/clippy_lints/src/borrow_deref_ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use rustc_hir::{ExprKind, UnOp};
use rustc_lint::{LateContext, LateLintPass};
use rustc_middle::mir::Mutability;
use rustc_middle::ty;
use rustc_session::{declare_lint_pass, declare_tool_lint};
use rustc_session::declare_lint_pass;

declare_clippy_lint! {
/// ### What it does
Expand Down
Loading