Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
165 commits
Select commit Hold shift + click to select a range
691fbb4
fix: `collapsible_match` suggests wrongly when match body has no braces
profetia Apr 20, 2026
553132d
`doc_markdown`: add common database engines to whitelist
profetia Apr 26, 2026
0e60608
Changelog for Clippy 1.96
alex-semenyuk May 23, 2026
22833b4
Fix `explicit_counter_loop` FP when the counter is only modified inside
relaxcn May 16, 2026
42eae42
fix(result_large_err): trigger lint for async functions
Gri-ffin May 25, 2026
87bfa9b
test(len_without_is_empty): expect result_unit_err on async Result<_,…
Gri-ffin May 25, 2026
d082244
Improve excessive bools docs
joshka May 27, 2026
96bdb47
Changelog for Clippy 1.96 🦀 (#17066)
flip1995 May 28, 2026
e8fdfcc
Merge commit '9fca3bc9fc2bc83c60bde26d18ed68f11564b228' into clippy-s…
flip1995 May 28, 2026
b8953cb
Add manual_isolate_lowest_one lint
arunsingh May 19, 2026
41feaac
faster has_arg search
hkBst May 29, 2026
87aaa5a
Faster has_arg (#17112)
samueltardieu May 29, 2026
4858a73
add new lint: `for_unbounded_range`
Erk- Dec 18, 2025
aede4dc
add new lint: `for_unbounded_range` (#16257)
samueltardieu May 29, 2026
7112c38
Improve excessive bools docs (#17080)
samueltardieu May 29, 2026
79f8f33
driver: remove unnecessary use of vec
hkBst May 29, 2026
c05f438
check `has_nested_let_chain` earlier
ada4a May 30, 2026
2272895
misc improvements
ada4a May 30, 2026
30c60b7
`redundant_pattern_match`: improve suggestions
ada4a May 30, 2026
395967e
Attributes cleanup in tests [03/20]
samueltardieu May 21, 2026
4251e35
Attributes cleanup in tests [04/20]
samueltardieu May 21, 2026
2e7220f
`redundant_pattern_match`: improve suggestions (#17116)
llogiq May 31, 2026
d3dbe42
Attributes cleanup in tests [05/20]
samueltardieu May 21, 2026
e73ae69
Attributes cleanup in tests [05/20] (#17089)
ada4a May 31, 2026
f85bd2b
Obtaining the metadata of a const pointer is a const operation
samueltardieu May 31, 2026
8e4617d
Attributes cleanup in tests [02/20]
samueltardieu May 21, 2026
776fd6c
Attributes cleanup in tests [02/20] (#17086)
ada4a Jun 1, 2026
8f1792f
Attributes cleanup in tests [03/20] (#17087)
ada4a Jun 1, 2026
ff74cf4
Attributes cleanup in tests [04/20] (#17088)
ada4a Jun 1, 2026
213c8bf
Put myself on vacation
ada4a Jun 1, 2026
83b1994
Put myself on vacation (#17128)
ada4a Jun 1, 2026
294e68c
perf: fold all late lint passes into one statically-combined pass
xmakro Jun 1, 2026
68d2b73
perf: fold all late lint passes into one statically-combined pass (#1…
blyxyas Jun 1, 2026
d5c0121
perf: fold all early lint passes into one statically-combined pass
xmakro Jun 1, 2026
0729e6e
perf: skip disabled off-by-default doc reparses
xmakro Jun 1, 2026
5bde439
Attributes cleanup in tests [06/20]
samueltardieu May 21, 2026
106c238
Attributes cleanup in tests [06/20] (#17090)
ada4a Jun 1, 2026
16efafa
Memoize first_node_in_macro for consecutive queries
xmakro Jun 1, 2026
2b4f8f5
perf: Memoize first_node_in_macro for consecutive queries (#17134)
samueltardieu Jun 1, 2026
8b50a7d
perf: skip disabled off-by-default doc reparses (#17126)
llogiq Jun 2, 2026
a9a7ce5
remove AliasTerm::kind() method
khyperia Jun 2, 2026
6d336d5
perf: fold all early lint passes into one statically-combined pass (#…
llogiq Jun 2, 2026
53d6868
test: remove outdated test file for `find_map`
ada4a Jun 2, 2026
9ca5050
test: remove outdated test file for `find_map` (#17140)
samueltardieu Jun 2, 2026
bfcc6aa
ui_test: bump to latest version
durin42 Jun 2, 2026
a1374e4
Attributes cleanup in tests [07/20]
samueltardieu May 21, 2026
9501ebe
Add tests for async functions in `result_unit_err`
Gri-ffin Jun 2, 2026
724592c
Suppress `result_unit_err` with `#[expect]` in `len_without_is_empty`…
Gri-ffin Jun 2, 2026
453f444
Avoid redundant `Adt` check in `result_unit_err`
Gri-ffin Jun 2, 2026
9a3d32b
Fix `result_large_err` and `result_unit_err` not triggering on async …
samueltardieu Jun 2, 2026
c048c1e
ui_test: bump to latest version (#17142)
samueltardieu Jun 3, 2026
7098a65
Do not compute coroutine layout in non-Codegen typing mode.
cjgillot Aug 14, 2025
bf73658
[`double_must_use`]: make the lint machine-applicable in single-attri…
LebedevRI Jun 3, 2026
ae3153b
[`double_must_use`]: make the lint machine-applicable in single-attri…
samueltardieu Jun 3, 2026
5c6a4de
update lint description
durationextender Jun 3, 2026
e676765
clippy_lints: support iter_mut in ITER_NEXT_SLICE fixes #17115 (#17122)
samueltardieu Jun 3, 2026
c05be4b
Attributes cleanup in tests [07/20] (#17091)
ada4a Jun 3, 2026
fa7bf19
`large_const_arrays`: detect nested large arrays
theirix Jun 2, 2026
515697e
Auto merge of #145477 - cjgillot:codegen-mode, r=oli-obk
bors Jun 3, 2026
bd48927
feat: `large_const_arrays`: check nested large arrays (#17141)
dswij Jun 4, 2026
77b0350
Attributes cleanup in tests [08/20]
samueltardieu May 21, 2026
11a07fb
docs: Remove extra paren.
Jun 4, 2026
e6e3a40
Attributes cleanup in tests [08/20] (#17092)
ada4a Jun 4, 2026
8164c7d
docs: Remove extra paren. (#17151)
samueltardieu Jun 4, 2026
52ad766
update to term-1 which has fewer deps
hkBst Jun 4, 2026
9e94337
Add manual_isolate_lowest_one lint (#17037)
samueltardieu Jun 4, 2026
2db0c3a
driver: change has_args to is_arg and make it test a single arg
hkBst May 29, 2026
7cd8b78
driver: arg_value: return bool instead of unused str slice
hkBst May 29, 2026
dbe9641
Driver cleanup 2 (#17113)
blyxyas Jun 5, 2026
04db093
Do not trigger `inline_trait_bounds` on auto-derived code
samueltardieu Jun 1, 2026
ce33751
Do not trigger `inline_trait_bounds` on auto-derived code (#17131)
Jarcho Jun 5, 2026
4a2388c
perf: avoid cloning associated items in empty_line_after
xmakro Jun 1, 2026
5a50f03
perf: avoid cloning associated items in empty_line_after (#17135)
Jarcho Jun 5, 2026
2f56ba5
Detect more ranges in single_range_in_vec_init
arunsingh Jun 3, 2026
2982668
perf: skip the inline_always relevance walk for items without the att…
xmakro Jun 1, 2026
b0be101
needless_borrow: same-name methods false positive
notriddle Jun 6, 2026
2ba3d1c
perf: skip the inline_always relevance walk for items without the att…
Jarcho Jun 6, 2026
f69a253
fix duplicate clippy attribute validation
Gri-ffin Jun 5, 2026
a9fa02b
misc improvements:
ada4a Jun 6, 2026
0877257
misc: do the cheaper `TyKind` check first
ada4a Jun 6, 2026
b6d0978
improve suggestion
ada4a Jun 6, 2026
a991b84
extend the let chain
ada4a Jun 6, 2026
8e7be63
misc improvements
ada4a Jun 6, 2026
996a5b0
clean-up tests
ada4a Jun 6, 2026
15c9677
move the suggestion into the suggestion message
ada4a Jun 6, 2026
3c7da10
destructure arrays in patterns already
ada4a Jun 6, 2026
8657c54
give clearer names to things
ada4a Jun 6, 2026
bc274fe
perf: skip the boxed_local walk for functions without a Box parameter
xmakro Jun 6, 2026
0bdca3c
split off the suggestion from the main message
ada4a Jun 6, 2026
05a1ffe
perf: skip the boxed_local walk for functions without a Box parameter…
Jarcho Jun 6, 2026
f2a72d4
Detect more ranges in single_range_in_vec_init (#17146)
samueltardieu Jun 6, 2026
20e2299
Obtaining the metadata of a const pointer is a const operation (#17121)
llogiq Jun 7, 2026
12f05ee
Fix lints duplications in `unknown_attribute` and `renamed_builtin_at…
llogiq Jun 7, 2026
0ddce95
`borrowed_box`: clean-up, improve suggestion message (#17173)
llogiq Jun 7, 2026
6f94be9
Fix unused_async_trait_impl suggestions with return statements
Wassasin Jun 7, 2026
3e3db3f
`iter_cloned_collect`: split off the suggestion from the main message…
samueltardieu Jun 7, 2026
0db591d
Fix unused_async_trait_impl suggestions with return statements (#17181)
dswij Jun 7, 2026
78323ba
Attributes cleanup in tests [09/20]
samueltardieu May 21, 2026
163f085
Attributes cleanup in tests [09/20] (#17093)
ada4a Jun 7, 2026
875f463
Attributes cleanup in tests [10/20]
samueltardieu May 21, 2026
45157f0
Attributes cleanup in tests [10/20] (#17094)
ada4a Jun 7, 2026
3111338
Syntactically reject equality predicates
fmease Mar 6, 2026
7b581b1
test(`manual_let_else`): extract unfixable cases to a separate file
ada4a Jun 6, 2026
1fd6906
Attributes cleanup in tests [11/20]
samueltardieu May 21, 2026
d00aff4
Attributes cleanup in tests [11/20] (#17095)
ada4a Jun 7, 2026
fdadd62
docs: update lint registration for statically-combined passes
xmakro Jun 8, 2026
bbfff70
docs: update lint registration for statically-combined passes (#17178)
ada4a Jun 8, 2026
bbb3510
Fix redundant closure call async false positive
lkirkwood Apr 21, 2026
39f4f7f
Cleanup test files by swapping allow for expect
lkirkwood Jun 7, 2026
68df040
Make the `inline` field on the `Const` `ConstContext` more clearly ta…
oli-obk Nov 11, 2025
e166faa
Remove possibly footgunny `is_const` method
oli-obk May 3, 2026
d368774
dummy: update to term-1 which has fewer deps (#17152)
flip1995 Jun 8, 2026
0bbbfcc
test(`manual_let_else`): extract unfixable cases to a separate file (…
samueltardieu Jun 8, 2026
1c889b8
Extend extra_unused_lifetimes for spurious for<'a>
TheNeikos May 18, 2026
dc46f29
Extend extra_unused_lifetimes for spurious for<'a> (#17031)
Jarcho Jun 8, 2026
53308b5
Fix `explicit_counter_loop` FP when the counter is only modified insi…
Jarcho Jun 8, 2026
4603426
manual_is_variant_and: lint `result.ok().is_some_and(f)`
sylvestre Jun 7, 2026
bb32db3
Add `with_capacity_zero` lint
zachshallbetter Jun 8, 2026
77f1ac0
Change `with_capacity_zero` category to `pedantic`
zachshallbetter Jun 8, 2026
cd49ee2
misc: `mem::take` the vec of enums to avoid copying
ada4a Jun 7, 2026
80df069
explain why we have hint+suggestion instead of multipart suggestion
ada4a Jun 7, 2026
1389f57
clean-up suggestion messages
ada4a Jun 8, 2026
ef6e711
clean-up tests, first pass
ada4a Jun 8, 2026
a78f667
rename `repl_uninit.rs` to `mem_replace_with_uninit.rs`, clean-up
ada4a Jun 8, 2026
a5b5cef
extract `mem_replace_option_with_none` tests into their own file
ada4a Jun 8, 2026
d9825ad
extract `mem_replace_option_with_some` tests into their own file
ada4a Jun 8, 2026
2ae2877
rename the remains to `mem_replace_with_default.rs`
ada4a Jun 8, 2026
75bff05
`mem_replace`: clean-up (#17190)
samueltardieu Jun 9, 2026
f736c1e
Add profile-specific configuration for disallowed methods and types
Lallapallooza Sep 29, 2025
286f01e
fix review
Lallapallooza Nov 17, 2025
74f3823
config: add [profiles.*] disallowed lists
Lallapallooza Dec 14, 2025
37482e2
fix: address review feedback
Lallapallooza Dec 17, 2025
03128d7
fix: address final review feedback
Lallapallooza Apr 21, 2026
bf2b6ed
feat: Add profile-specific configuration for disallowed methods and t…
blyxyas Jun 9, 2026
5b79a64
internal(`manual_non_exhaustive`): explain why we have hint+suggestio…
samueltardieu Jun 9, 2026
b8c36b0
feat: also emit `mem_replace_with_default` inside macros
ada4a Jun 8, 2026
42e5232
manual_is_variant_and: lint `result.ok().is_some_and(f)` (#17184)
Jarcho Jun 9, 2026
0889c92
feat(`mem_replace_with_default`): also emit inside macros (#17191)
dswij Jun 9, 2026
13915be
enhance never_loop to emit diagnostic notes for non obvious divergence
MassimilianoBaglioni Jun 1, 2026
ad42d05
Enhance never loop (#17145)
samueltardieu Jun 10, 2026
6b498e8
Cleanup: remove unneeded references
samueltardieu Jun 10, 2026
5a53de3
Cleanup: remove unneeded references (#17203)
dswij Jun 10, 2026
64805da
Remove `PROFILE` forwarding from `build.rs`
Jarcho May 27, 2026
bfe323a
Remove `PROFILE` forwarding from `build.rs` (#17077)
Jarcho Jun 10, 2026
941d80c
Refactor with_capacity_zero to address PR review comments
zachshallbetter Jun 11, 2026
b09831f
Add common database engines to `doc_markdown` whitelist (#16917)
samueltardieu Jun 11, 2026
7731cac
Fix `collapsible_match` suggests wrongly when match body has no brace…
samueltardieu Jun 11, 2026
0bcbc9d
Fix redundant closure call async false positive (#17107)
samueltardieu Jun 11, 2026
f1c1d90
Add `with_capacity_zero` lint (#17192)
samueltardieu Jun 11, 2026
ab9ee11
Deprecate the `from_iter_instead_of_collect` lint
samueltardieu Jun 11, 2026
917d94a
Deprecate the `from_iter_instead_of_collect` lint (#17208)
llogiq Jun 11, 2026
7743464
docs: Clarify lint configuration text.
Jun 11, 2026
a66d7fd
Docs: properly link to main page of docs.
Jun 11, 2026
fced4cf
Docs: Remove added link, since it appears earlier in the text.
Jun 11, 2026
8408727
Merge remote-tracking branch 'upstream/master' into rustup
flip1995 Jun 11, 2026
9cadea6
Bump nightly version -> 2026-06-11
flip1995 Jun 11, 2026
8428a85
Rustup (#17211)
flip1995 Jun 11, 2026
7813792
docs: Clarify lint configuration text. (#17210)
samueltardieu Jun 11, 2026
5071656
`infallible_destructuring_match`: clean-up, split off the suggestion …
samueltardieu Jun 11, 2026
1c70a8b
needless_borrow: same-name methods false positive (#17171)
samueltardieu Jun 11, 2026
de60dd8
Replace style uses of `is_integer_const` with `is_integer_literal`.
Jarcho Jun 10, 2026
f7dfee2
Replace `is_integer_const` with `eval_int`.
Jarcho Jun 10, 2026
5f29bd0
Remove `is_integer_const` (#17204)
samueltardieu Jun 11, 2026
dd7e6f1
Merge commit '5f29bd0df789f92cd494061f9223dbb5d96e8e16' into clippy-s…
flip1995 Jun 11, 2026
97d2da8
Update Cargo.lock
flip1995 Jun 11, 2026
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
  •  
  •  
  •  
8 changes: 4 additions & 4 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5948,15 +5948,15 @@ checksum = "2896d95c02a80c6d6a5d6e953d479f5ddf2dfdb6a244441010e373ac0fb88971"

[[package]]
name = "ui_test"
version = "0.30.5"
version = "0.30.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "980133b75aa9a95dc94feaf629d92d22c1172186f1fa1266b91f5b91414cf9a5"
checksum = "8c8811281d587a786747c0c49245925016c07767bc996305bdd34d5ce076786a"
dependencies = [
"annotate-snippets 0.11.5",
"anyhow",
"bstr",
"cargo-platform 0.1.9",
"cargo_metadata 0.18.1",
"cargo-platform 0.3.1",
"cargo_metadata 0.23.1",
"color-eyre",
"colored",
"comma",
Expand Down
100 changes: 99 additions & 1 deletion src/tools/clippy/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,101 @@ document.

## Unreleased / Beta / In Rust Nightly

[df995e...master](https://github.com/rust-lang/rust-clippy/compare/df995e...master)
[88f787...master](https://github.com/rust-lang/rust-clippy/compare/88f787...master)

## Rust 1.96

Current stable, released 2026-05-28

[View all 48 merged pull requests](https://github.com/rust-lang/rust-clippy/pulls?q=merged%3A2026-02-24T12%3A30%3A17Z..2026-04-03T17%3A32%3A48Z+base%3Amaster)

### New Lints

* Added [`manual_noop_waker`] to `complexity`
[#16687](https://github.com/rust-lang/rust-clippy/pull/16687)
* Added [`manual_option_zip`] to `complexity`
[#16600](https://github.com/rust-lang/rust-clippy/pull/16600)
* Added [`manual_pop_if`] to `complexity`
[#16582](https://github.com/rust-lang/rust-clippy/pull/16582)

### Enhancements

* [`explicit_counter_loop`] suggest `(init..).take(n)` when loop variable is unused and range is
`0..n`
[#16658](https://github.com/rust-lang/rust-clippy/pull/16658)
* [`iter_kv_map`] handle identity map for `map` and `flat_map`
[#16743](https://github.com/rust-lang/rust-clippy/pull/16743)
* [`manual_noop_waker`] add an MSRV check
[#16850](https://github.com/rust-lang/rust-clippy/pull/16850)
* [`manual_pop_if`] in case the popped value is used, just emit the lint with no suggestion
[#16683](https://github.com/rust-lang/rust-clippy/pull/16683)
* [`manual_pop_if`] also cover `.pop().unwrap_unchecked()`
[#16683](https://github.com/rust-lang/rust-clippy/pull/16683)
* [`manual_pop_if`] detect manual implementations of `BinaryHeap::pop_if()`
[#16734](https://github.com/rust-lang/rust-clippy/pull/16734)
* [`unnecessary_option_map_or_else`] function definitions are no longer traversed when checking if
an expression is the identity
[#15889](https://github.com/rust-lang/rust-clippy/pull/15889)
* [`unnecessary_result_map_or_else`] function definitions are no longer traversed when checking if
an expression is the identity
[#15889](https://github.com/rust-lang/rust-clippy/pull/15889)
* [`question_mark`] fix suggestion-caused error caused by semicolon inference relying only on
parent-node shape
[#16656](https://github.com/rust-lang/rust-clippy/pull/16656)
* Format-related lints now handle `core::panic!`
[#16597](https://github.com/rust-lang/rust-clippy/pull/16597)
* [`explicit_counter_loop`] fix FN when the initializer is not integral
[#16647](https://github.com/rust-lang/rust-clippy/pull/16647)
* [`suboptimal_flops`] fix FN on add and sub assign
[#16625](https://github.com/rust-lang/rust-clippy/pull/16625)
* [`infinite_loop`] fix wrong suggestion to add `-> !` when the loop is inside a conditional branch
[#16619](https://github.com/rust-lang/rust-clippy/pull/16619)
* [`unnecessary_cast`] preserve parentheses in presence of cascaded casts
[#16483](https://github.com/rust-lang/rust-clippy/pull/16483)
* [`cmp_owned`] fix wrong suggestions on `PathBuf`
[#16628](https://github.com/rust-lang/rust-clippy/pull/16628)
* [`redundant_closure`] fix wrong suggestions when local is dereferenced to callable
[#16648](https://github.com/rust-lang/rust-clippy/pull/16648)

### False Positive Fixes

* [`collapsible_if`] fix FP when the inner if contains cfg
[#16757](https://github.com/rust-lang/rust-clippy/pull/16757)
* [`collapsible_match`] fix FP when the pat binding is moved or mutated
[#16708](https://github.com/rust-lang/rust-clippy/pull/16708)
* [`collapsible_match`] fix a case where a suggested transformation changes runtime behavior
[#16878](https://github.com/rust-lang/rust-clippy/pull/16878)
* [`match_same_arms`] fix FP with associated consts
[#16701](https://github.com/rust-lang/rust-clippy/pull/16701)
* [`semicolon_inside_block`] fix FP in `try` blocks where moving `;` changes the block's return
type and causes type errors
[#16697](https://github.com/rust-lang/rust-clippy/pull/16697)
* [`unnecessary_safety_comment`] fix FP on code blocks inside inner docs
[#16559](https://github.com/rust-lang/rust-clippy/pull/16559)
* [`doc_paragraphs_missing_punctuation`] no longer lints punctuated paragraphs with a trailing
emoji
[#16514](https://github.com/rust-lang/rust-clippy/pull/16514)

### ICE Fixes

* [`match_same_arms`] fix ICE in `match_same_arms`
[#16685](https://github.com/rust-lang/rust-clippy/pull/16685)
* [`nonminimal_bool`] fix ICE in `swap_binop()` by using the proper `TypeckResults`
[#16659](https://github.com/rust-lang/rust-clippy/pull/16659)
* Fix ICE when using the `min_generic_const_args` incomplete feature
[#16692](https://github.com/rust-lang/rust-clippy/pull/16692)

### Documentation Improvements

* [`similar_names`] changed the lint docs to reflect its actual behavior
[#16300](https://github.com/rust-lang/rust-clippy/pull/16300)

### Performance Improvements

* [`repeat_vec_with_capacity`] optimized by 96.876% (784M -> 24M instructions)
[#16756](https://github.com/rust-lang/rust-clippy/pull/16756)
* [`manual_is_ascii_check`] optimized by 97.125% (822M -> 23M instructions)
[#16755](https://github.com/rust-lang/rust-clippy/pull/16755)

## Rust 1.95

Expand Down Expand Up @@ -6746,6 +6840,7 @@ Released 2018-09-13
[`for_loop_over_option`]: https://rust-lang.github.io/rust-clippy/master/index.html#for_loop_over_option
[`for_loop_over_result`]: https://rust-lang.github.io/rust-clippy/master/index.html#for_loop_over_result
[`for_loops_over_fallibles`]: https://rust-lang.github.io/rust-clippy/master/index.html#for_loops_over_fallibles
[`for_unbounded_range`]: https://rust-lang.github.io/rust-clippy/master/index.html#for_unbounded_range
[`forget_copy`]: https://rust-lang.github.io/rust-clippy/master/index.html#forget_copy
[`forget_non_drop`]: https://rust-lang.github.io/rust-clippy/master/index.html#forget_non_drop
[`forget_ref`]: https://rust-lang.github.io/rust-clippy/master/index.html#forget_ref
Expand Down Expand Up @@ -6906,6 +7001,7 @@ Released 2018-09-13
[`manual_is_multiple_of`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_is_multiple_of
[`manual_is_power_of_two`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_is_power_of_two
[`manual_is_variant_and`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_is_variant_and
[`manual_isolate_lowest_one`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_isolate_lowest_one
[`manual_let_else`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_let_else
[`manual_main_separator_str`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_main_separator_str
[`manual_map`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_map
Expand Down Expand Up @@ -7424,6 +7520,7 @@ Released 2018-09-13
[`wildcard_enum_match_arm`]: https://rust-lang.github.io/rust-clippy/master/index.html#wildcard_enum_match_arm
[`wildcard_imports`]: https://rust-lang.github.io/rust-clippy/master/index.html#wildcard_imports
[`wildcard_in_or_patterns`]: https://rust-lang.github.io/rust-clippy/master/index.html#wildcard_in_or_patterns
[`with_capacity_zero`]: https://rust-lang.github.io/rust-clippy/master/index.html#with_capacity_zero
[`write_literal`]: https://rust-lang.github.io/rust-clippy/master/index.html#write_literal
[`write_with_newline`]: https://rust-lang.github.io/rust-clippy/master/index.html#write_with_newline
[`writeln_empty_string`]: https://rust-lang.github.io/rust-clippy/master/index.html#writeln_empty_string
Expand Down Expand Up @@ -7511,6 +7608,7 @@ Released 2018-09-13
[`module-items-ordered-within-groupings`]: https://doc.rust-lang.org/clippy/lint_configuration.html#module-items-ordered-within-groupings
[`msrv`]: https://doc.rust-lang.org/clippy/lint_configuration.html#msrv
[`pass-by-value-size-limit`]: https://doc.rust-lang.org/clippy/lint_configuration.html#pass-by-value-size-limit
[`profiles`]: https://doc.rust-lang.org/clippy/lint_configuration.html#profiles
[`pub-underscore-fields-behavior`]: https://doc.rust-lang.org/clippy/lint_configuration.html#pub-underscore-fields-behavior
[`recursive-self-in-type-definitions`]: https://doc.rust-lang.org/clippy/lint_configuration.html#recursive-self-in-type-definitions
[`semicolon-inside-block-ignore-singleline`]: https://doc.rust-lang.org/clippy/lint_configuration.html#semicolon-inside-block-ignore-singleline
Expand Down
34 changes: 19 additions & 15 deletions src/tools/clippy/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,11 @@ To have `rust-analyzer` also work in the `clippy_dev` and `lintcheck` crates, ad

## How Clippy works

[`clippy_lints/src/lib.rs`][lint_crate_entry] imports all the different lint modules and registers in the [`LintStore`].
For example, the [`else_if_without_else`][else_if_without_else] lint is registered like this:
[`clippy_lints/src/lib.rs`][lint_crate_entry] imports all the different lint modules and registers them in the
[`LintStore`]. All early passes are folded into a single `CombinedEarlyLintPass`, and all late passes into a single
`CombinedLateLintPass`, each registered once with the store. A pass is added to one of these by listing it in the
`early_lint_methods!` or `late_lint_methods!` macro invocation. For example, the
[`else_if_without_else`][else_if_without_else] lint is added like this:

```rust
// ./clippy_lints/src/lib.rs
Expand All @@ -134,18 +137,21 @@ For example, the [`else_if_without_else`][else_if_without_else] lint is register
pub mod else_if_without_else;
// ...

pub fn register_lints(store: &mut rustc_lint::LintStore, conf: &'static Conf) {
// ...
store.register_early_pass(|| Box::new(else_if_without_else::ElseIfWithoutElse));
// ...
}
rustc_lint::early_lint_methods!(
crate::combined_early_lint_pass,
[CombinedEarlyLintPass, (/* ... */), [
// ...
ElseIfWithoutElse: else_if_without_else::ElseIfWithoutElse = else_if_without_else::ElseIfWithoutElse,
// ...
]]
);
```

The [`rustc_lint::LintStore`][`LintStore`] provides two methods to register lints:
[register_early_pass][reg_early_pass] and [register_late_pass][reg_late_pass]. Both take an object
that implements an [`EarlyLintPass`][early_lint_pass] or [`LateLintPass`][late_lint_pass] respectively. This is done in
every single lint. It's worth noting that the majority of `clippy_lints/src/lib.rs` is autogenerated by `cargo dev
update_lints`. When you are writing your own lint, you can use that script to save you some time.
Each entry has the form `Field: Type = constructor`, where the constructor builds the pass (passing `conf` when the pass
needs the user configuration). The combined passes implement [`EarlyLintPass`][early_lint_pass] and
[`LateLintPass`][late_lint_pass] respectively, so each listed pass must also implement the matching trait. It's worth
noting that the majority of `clippy_lints/src/lib.rs` is autogenerated by `cargo dev update_lints`. When you are
writing your own lint, you can use that script to save you some time.

```rust
// ./clippy_lints/src/else_if_without_else.rs
Expand All @@ -167,14 +173,12 @@ The difference between `EarlyLintPass` and `LateLintPass` is that the methods of
AST information. The methods of the `LateLintPass` trait are executed after type checking and contain type information
via the `LateContext` parameter.

That's why the `else_if_without_else` example uses the `register_early_pass` function. Because the
That's why the `else_if_without_else` example is listed in `early_lint_methods!`. Because the
[actual lint logic][else_if_without_else] does not depend on any type information.

[lint_crate_entry]: https://github.com/rust-lang/rust-clippy/blob/master/clippy_lints/src/lib.rs
[else_if_without_else]: https://github.com/rust-lang/rust-clippy/blob/4253aa7137cb7378acc96133c787e49a345c2b3c/clippy_lints/src/else_if_without_else.rs
[`LintStore`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_lint/struct.LintStore.html
[reg_early_pass]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_lint/struct.LintStore.html#method.register_early_pass
[reg_late_pass]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_lint/struct.LintStore.html#method.register_late_pass
[early_lint_pass]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_lint/trait.EarlyLintPass.html
[late_lint_pass]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_lint/trait.LateLintPass.html

Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ anstream = "0.6.18"

[dev-dependencies]
cargo_metadata = "0.23"
ui_test = "0.30.5"
ui_test = "0.30.7"
regex = "1.5.5"
serde = { version = "1.0.145", features = ["derive"] }
serde_json = "1.0.122"
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/book/src/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ cargo clippy -- -A clippy::all -W clippy::useless_format -W clippy::...
#### Lints Section in `Cargo.toml`

Finally, lints can be allowed/denied using [the lints
section](https://doc.rust-lang.org/nightly/cargo/reference/manifest.html#the-lints-section)) in the `Cargo.toml` file:
section](https://doc.rust-lang.org/nightly/cargo/reference/manifest.html#the-lints-section) in the `Cargo.toml` file:

To deny `clippy::enum_glob_use`, put the following in the `Cargo.toml`:

Expand Down
15 changes: 8 additions & 7 deletions src/tools/clippy/book/src/development/adding_lints.md
Original file line number Diff line number Diff line change
Expand Up @@ -282,21 +282,22 @@ When using `cargo dev new_lint`, the lint is automatically registered and
nothing more has to be done.

When declaring a new lint by hand and `cargo dev update_lints` is used, the lint
pass may have to be registered manually in the `register_lints` function in
`clippy_lints/src/lib.rs`:
pass may have to be registered manually by adding an entry to the
`early_lint_methods!` macro invocation in `clippy_lints/src/lib.rs`, at the
`// add early passes here` marker:

```rust,ignore
store.register_early_pass(|| Box::new(foo_functions::FooFunctions));
FooFunctions: foo_functions::FooFunctions = foo_functions::FooFunctions,
```

As one may expect, there is a corresponding `register_late_pass` method
available as well. Without a call to one of `register_early_pass` or
`register_late_pass`, the lint pass in question will not be run.
As one may expect, there is a corresponding `late_lint_methods!` macro available
as well. Without an entry in one of `early_lint_methods!` or `late_lint_methods!`,
the lint pass in question will not be run.

One reason that `cargo dev update_lints` does not automate this step is that
multiple lints can use the same lint pass, so registering the lint pass may
already be done when adding a new lint. Another reason that this step is not
automated is that the order that the passes are registered determines the order
automated is that the order that the passes are listed determines the order
the passes actually run, which in turn affects the order that any emitted lints
are output in.

Expand Down
11 changes: 6 additions & 5 deletions src/tools/clippy/book/src/development/defining_lints.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,18 +184,19 @@ However, sometimes we might want to declare a new lint by hand. In this case,
we'd use `cargo dev update_lints` command afterwards.

When a lint is manually declared, we might need to register the lint pass
manually in the `register_lints` function in `clippy_lints/src/lib.rs`:
manually by adding an entry to the `late_lint_methods!` macro invocation in
`clippy_lints/src/lib.rs`, at the `// add late passes here` marker:

```rust
store.register_late_pass(|_| Box::new(foo_functions::FooFunctions));
FooFunctions: foo_functions::FooFunctions = foo_functions::FooFunctions,
```

As you might have guessed, where there's something late, there is something
early: in Clippy there is a `register_early_pass` method as well. More on early
early: in Clippy there is an `early_lint_methods!` macro as well. More on early
vs. late passes in the [Lint Passes] chapter.

Without a call to one of `register_early_pass` or `register_late_pass`, the lint
pass in question will not be run.
Without an entry in one of `early_lint_methods!` or `late_lint_methods!`, the
lint pass in question will not be run.


[all_lints]: https://rust-lang.github.io/rust-clippy/master/
Expand Down
Loading
Loading