Commit graph

23295 commits

Author SHA1 Message Date
Alejandra González
4cb43f4c41
Optimize needless_bool lint (#15423)
Two optimizations have been done when checking for the context in which
to apply the lint:

- Checking for the mere presence of comments does not require building a
`String` with the comment to then check if it is empty and discard it.
- Checking for the presence of comment can be done after we have checked
that we do have a `if` construct that we intend to lint instead of for
every expression.

changelog: none

r? blyxyas
2025-08-06 17:59:23 +00:00
Samuel Tardieu
8602faa6ff
Optimize needless_bool lint
Two optimizations have been done when checking for the context in which
to apply the lint:

- Checking for the mere presence of comments does not require building a
  `String` with the comment to then check if it is empty and discard it.
- Checking for the presence of comment can be done after we have checked
  that we do have a `if` construct that we intend to lint instead of for
  every expression.
2025-08-06 19:49:22 +02:00
Alejandra González
a4d43215b8
Optimize incompatible_msrv lint (#15422)
This limits repeated lookups in pre-checks (to determine if a MSRV
should be checked), especially when those require locking up an
interner:

- The `core` crate is looked up once when creating the lint, instead of
comparing the crate name with `sym::core` at every check.
- `span.ctxt().outer_expn_data()` is lookup up only once.

changelog: none
r? blyxyas
2025-08-06 16:25:34 +00:00
Philipp Krones
925710d73e
Remove CSS bootstrap dependency (#15251)
Follow-up of https://github.com/rust-lang/rust-clippy/pull/15208.

This PR removes the CSS `bootstrap` dependency which contains 1504 CSS
rules and weights 16.1 kB minified. Considering we used less than 50 of
these rules, it's quite a waste.

So this time, there are minor UI changes:
* The "expand/collapse all" buttons icon changed. It now uses the one
from font-awesome. It's quite close but not exactly the same.
* The layout is slightly different (you need to switch between two tabs
to actually see the difference).

Before this PR:

<img width="719" height="515" alt="image"
src="https://github.com/user-attachments/assets/1f067046-4ee9-49ee-bf38-50a8bf9888f2"
/>

With this PR:

<img width="719" height="515" alt="image"
src="https://github.com/user-attachments/assets/80331c98-1a1e-418f-b481-5b3f5c276926"
/>

With this, we will be able to go even further on reducing the page size
next. =D

This time, the DOM size itself reduced a bit but the difference is too
small to be noteworthy.

r? @samueltardieu

changelog: Remove CSS bootstrap dependency
2025-08-06 16:02:08 +00:00
Samuel Tardieu
26911aa32c
Optimize incompatible_msrv lint
This limits repeated lookups in pre-checks (to determine if a MSRV
should be checked), especially when those require locking up
an interner:

- The `core` crate is looked up once when creating the lint, instead of
  comparing the crate name with `sym::core` at every check.
- `span.ctxt().outer_expn_data()` is lookup up only once.
2025-08-06 16:30:31 +02:00
llogiq
d98d7c0ee8
Fix suggestion for collapsible_if and collapsible_else_if when the inner if is enclosed in parentheses (#15304)
changelog: [`collapsible_else_if`]: fix suggestion when inner `if` as
wrapped in parentheses
changelog: [`collapsible_if`]: fix suggestion when inner `if` as wrapped
in parentheses

fixes https://github.com/rust-lang/rust-clippy/issues/15303

I'm sure this is a bit dirty, but don't currently see a better way.
2025-08-06 12:45:27 +00:00
Guillaume Gomez
102e39fa51 Remove CSS bootstrap dependency 2025-08-06 11:46:53 +02:00
Guillaume Gomez
04e794a0b9 Fix CSS indent 2025-08-06 11:30:09 +02:00
Philipp Krones
7673826138
expand the issue template for new lints (#15336)
When I first tried contributing to clippy,
I encountered the problem that a lot of lint suggestions overlapped with
existing lints, so I would spend a bunch of time implementing something
only to figure out it wasn't actually needed.

The "comparison with existing lints" field should hopefully reduce this
somewhat, while not incresing the burden of
requesting a new lint too much due to not being mandatory.

changelog: none
2025-08-06 09:03:10 +00:00
Alejandra González
03ae8b0464
Do not lint for wildcard_imports in external macro (#15413)
Fixes rust-lang/rust-clippy#15412

changelog: [`wildcard_imports`]: do not lint code coming from an
external macro
2025-08-05 22:32:08 +00:00
Samuel Tardieu
8396d73798
Fix unnecessary_sort_by lint method consistency in message and suggestion (#15416)
The `unnecessary_sort_by` lint displays different method names in
message and suggestion, which is a bit confusing.

Also got a question about `UNNECESSARY_SORT_BY` lint definition. Should
we extend its message to also cover *_unstable_* methods?

changelog: [`unnecessary-sort-by`]: sort method consistency in message
and suggestion
2025-08-05 12:50:25 +00:00
Huterenok
6249f33ca1 fix: unnecessary_sort_by lint method consistency in message and suggestion 2025-08-05 15:23:10 +03:00
Philipp Krones
4d1962c282
Move cognitive_complexity lint from nursery to restriction (#15415)
changelog: [`cognitive_complexity`]: move the lint from `nursery` to the
`restriction`

r? @flip1995
2025-08-05 12:20:27 +00:00
Samuel Tardieu
cdee4f8e1d
Move cognitive_complexity lint from nursery to restriction 2025-08-05 13:52:58 +02:00
Samuel Tardieu
b98252f6ca
Generate lint count in template (#15414)
Removes the pop-in of the element on page load

changelog: none
2025-08-05 11:49:09 +00:00
Alex Macleod
0ea413fe6b Generate lint count in template 2025-08-05 11:40:05 +00:00
Samuel Tardieu
6c7fa3b2cb
Do not lint for wildcard_imports in external macro 2025-08-05 11:29:18 +02:00
Alejandra González
264bc97b26
Split possible_missing_else from suspicious_else_formatting (#15317)
This has always been one lint (added in rust-lang/rust-clippy#720), but
the two cases are also quite distinct.

changelog: Split `possible_missing_else` from
`suspicious_else_formatting`

<!-- TRIAGEBOT_START -->

<!-- TRIAGEBOT_SUMMARY_START -->

### Summary Notes

-
[Feature-freeze](https://github.com/rust-lang/rust-clippy/pull/15317#issuecomment-3094592022)
by [github-actions[bot]](https://github.com/github-actions[bot])

*Managed by `@rustbot`—see
[help](https://forge.rust-lang.org/triagebot/note.html) for details*

<!-- TRIAGEBOT_SUMMARY_END -->
<!-- TRIAGEBOT_END -->
2025-08-04 22:57:06 +00:00
Alejandra González
826e514e44
Issues priority (#15393)
We can actualize "Issue and PR triage" section. Seems labels
[P-medium](https://github.com/rust-lang/rust-clippy/labels/P-medium),
[P-high](https://github.com/rust-lang/rust-clippy/labels/P-high),
[L-sync-blocker](https://github.com/rust-lang/rust-clippy/labels/L-sync-blocker)
are not relevant anymore. Suppose that we can save the priority from
[feature
freeze](https://github.com/alex-semenyuk/rust-clippy/blob/master/book/src/development/feature_freeze.md?plain=1)
since the only difference accepting new lints.

changelog: none
2025-08-04 20:13:24 +00:00
Samuel Tardieu
d6cf7b905f
Remove rogue comma from infallible_try_from lint message (#15409)
Spotted while reading through the new lints in the changelog for Clippy
1.89:

```
 1 | error: infallible TryFrom impl; consider implementing From, instead
   |                                                           ^ this comma looks out of place
```

---

changelog: [`infallible_try_from`]: Fix a typo in the lint message
2025-08-04 14:51:12 +00:00
Fayti1703
5b22c0c1ed Remove rogue comma from infallible_try_from lint message 2025-08-04 16:38:31 +02:00
Alex Macleod
048e8f2d01
Fix not showing deprecated lints (#15407)
As discussed at rust-lang/rust-clippy#15387 revert changes
https://github.com/rust-lang/rust-clippy/pull/15315 to show deprecated.

changelog: none
2025-08-04 14:17:59 +00:00
Alexey Semenyuk
0708b6a1e6 Fix not showing deprecated lints 2025-08-04 19:08:25 +05:00
Philipp Krones
7a179313b9
Changelog for Clippy 1.89 🌽 (#15375)
Violets are red,
Roses are blue,
As August winds whisper,
Take a chance, then rest too.

<hr>

Appreciate it as always @xFrednet

<img width="601" height="744" alt="image"
src="https://github.com/user-attachments/assets/a0e4af41-da97-4565-881b-549ed51d7fc5"
/>

<hr>

Cats for the next release can be traditionally nominated in the comments
:D
Please be more active and cat-minded 😻

changelog: none

r? flip1995
2025-08-04 10:55:20 +00:00
Samuel Tardieu
2b9fb32c62
clean-up semicolon_inside_block (#15390)
changelog: none
2025-08-04 08:59:43 +00:00
Ada Alakbarova
1fc5e81436
clean-up semicolon_inside_block
match on `StmtKind` directly

use a let-chain

break up match for a nicer let-chain

shorten `get_line`

move `expr` check down in the inside case as well

for consistency

use `shrink_to_hi`

Apply suggestion

Co-authored-by: Samuel Tardieu <sam@rfc1149.net>
2025-08-04 00:53:27 +02:00
alexey semenyuk
68ef9c4cee Task priority 2025-08-04 01:50:44 +05:00
llogiq
470ee4f01d
don't allocate a Vec in an Iterator::chain (#15400)
changelog: none
2025-08-03 16:58:15 +00:00
llogiq
151a045fdd
clean-up SourceFileRange::as_str (#15401)
changelog: none
2025-08-03 16:56:11 +00:00
Ada Alakbarova
2d8d45e201
use ? for brevity 2025-08-03 17:16:28 +02:00
Ada Alakbarova
3b907eada7
use parens for clearer formatting
the first and second lines now each represent one approach to getting a
`source`
2025-08-03 17:16:28 +02:00
Ada Alakbarova
02ebef4c6a
don't allocate a Vec in an Iterator::chain 2025-08-03 17:13:54 +02:00
Jason Newcomb
88bcf1ca19
fix option-if-let-else lint (#15394)
some simple twists
Fixes rust-lang/rust-clippy#15002
Fixes rust-lang/rust-clippy#15379

changelog: [`option_if_let_else`]: Don't remove raw pointer derefs in
suggestions
changelog: [`option_if_let_else`]: Don't suggest passing argless
functions to `Result::map_or_else`
2025-08-03 06:55:48 +00:00
Jason Newcomb
fa09b86bfc
Simplify boolean expression in manual_assert (#15368)
Fixes rust-lang/rust-clippy#15359

changelog: [`manual_assert`]: simplify boolean expression
2025-08-03 05:41:51 +00:00
Zihan
8f6b43dd65
fix: option_if_let_else don't suggest argless function for Result::map_or_else
closes rust-clippy/issues/15002

Signed-off-by: Zihan <zihanli0822@gmail.com>
2025-08-02 16:58:18 -04:00
Zihan
b8c16e47f4
fix: option_if_let_else keep deref op if the inner expr is a raw pointer
closes rust-clippy/issues/15379

Signed-off-by: Zihan <zihanli0822@gmail.com>
2025-08-02 13:07:11 -04:00
Timo
e8185ec091
Extend implicit_clone to handle to_string calls (#14177)
Put another way, merge `string_to_string` into `implicit_clone`, as
suggested here:
https://github.com/rust-lang/rust-clippy/issues/14173#issuecomment-2645846915

Note: [I
wrote](b8913894a1)
this comment:
6cdb7f68c3/clippy_lints/src/methods/implicit_clone.rs (L43-L45)

Here is the context for why I wrote it:
https://github.com/rust-lang/rust-clippy/pull/7978#discussion_r769128853

Regardless, it's probably time for the comment to go away. Extending
`implicit_clone` to handle `to_string` calls yields many hits within
Clippy's codebase.

changelog: extend `implicit_clone` to handle `to_string` calls
2025-08-02 11:41:00 +00:00
Timo
ffcd12946e
{flat_,}map_identity: recognize (tuple) struct de- and restructuring (#15261)
Follow-up of rust-lang/rust-clippy#15229, as described in
https://github.com/rust-lang/rust-clippy/pull/15229#issuecomment-3050279790
-- it turned out to be not that difficult after all!

changelog: [`map_identity`,`flat_map_identity`]: also recognize (tuple)
struct de- and resctructuring

r? @y21
2025-08-02 11:37:12 +00:00
Samuel Tardieu
e42586d495
fix: let_with_type_underscore don't eat closing paren in let (i): _ = 0; (#15386)
Apparently, one can surround a pattern with an arbitrary number of
parens, and the resulting `Pat` won't include the span of those parens.
And the previous approach extended the to-be-deleted span all the way to
the end of `Pat`'s span, so it included the closing paren.

I think the new approach is more robust anyway, since all we care to
remove (besides the `_`) is the `:`, so we search just for that.

~This does leave one extra whitespace in one of the test cases, but I'd
say let rustfmt handle that.~ fixed in the third commit

changelog: [`let_with_type_underscore`]: don't eat closing paren in `let
(i): _ = 0;`

fixes https://github.com/rust-lang/rust-clippy/issues/15377
2025-08-02 07:53:32 +00:00
Ada Alakbarova
0f98da7c5c
fix: let_with_type_underscore don't eat closing paren in let (i): _ = 0;
add failing tests

fix

also remove whitespace before `:`
2025-08-02 09:48:12 +02:00
Samuel Tardieu
cde155d1c1
Optimize broken_links by 99.77% (#15385)
We were calling an expensive functions lots of times resulting in 12
million instructions for `broken_links`, the doc lint optimization is
not over yet...

Now the instruction count for `broken_links` is at a healthy 27
thousand. This improvement is a difference of 1.5% in the total analysis
time for `tokio`.

changelog:[`broken_links`]: Optimize by 99.77%
2025-08-02 07:30:04 +00:00
blyxyas
01d960f645 Optimize broken_links by 99.77% 2025-08-02 01:59:48 +02:00
dswij
94b703588e
Do not specialize for if_chain any longer (#15362)
Now that `if let` chains have been introduced, the `if_chain` external
crate is no longer necessary. Dropping special support for it also
alleviates the need to keep the crate as a dependency in tests.

This is a cleanup PR.

changelog: none
2025-08-01 15:52:00 +00:00
Ada Alakbarova
eea4d6dc3c
{flat_,}map_identity: recognize (tuple) struct de- and restructuring
base check

same fields different struct

reordered fields

different paths to the same struct

same for tuple structs

style: use `zip`-the-function all over the place

makes the code a bit more concise by removing the need for explicit
`.iter()`

style: move precondition checking to the match guard

the match arms above put the "sanity" checks in the guard, and call only
`check_pat` in the body. With this commit, the (tuple) struct cases
follow that convention as well. Well, almost -- I think the ident check
belongs to the second category of checks, so I put it in the body as
well

misc: use `None` in the pattern directly

this'll probably be marginally faster thanks to the equality check being
now structural

move the tests to the right file
2025-08-01 11:24:44 +02:00
Alexey Semenyuk
9f7a8f8f9e Changelog for Clippy 1.89 2025-07-31 20:38:41 +05:00
Alejandra González
fab7eab7fb
Output lintcheck summary HTML markdown in order (#15371)
The data in the table needs to be in the same order as the headings.

changelog: none

Fixes rust-lang/rust-clippy#15370
2025-07-31 12:37:06 +00:00
Samuel Tardieu
e295a7d9f9
Simplify boolean expression in manual_assert 2025-07-30 20:11:04 +02:00
Jason Newcomb
3c54672d1a
Optimize some usages of !! and -- in suggestions (#15366)
When an expression is made of a `!` or `-` unary operator which does not
change the type of the expression, use a new variant in `Sugg` to denote
it. This allows replacing an extra application of the same operator by
the removal of the original operator instead.

Some suggestions will now be shown as `x` instead of `!!x`. Right now,
no suggestion seems to produce `--x`.

changelog: none
2025-07-30 17:35:10 +00:00
Alejandra González
445d41909e
Fix iter_on_single_items FP on function pointers and let stmts (#15013)
Closes rust-lang/rust-clippy#14981

changelog: [`iter_on_single_items`] fix FP on function pointers and let
stmts
2025-07-30 16:42:12 +00:00
Samuel Tardieu
18e8ac3778
chore: fix some minor issues in comments (#15372)
fix some minor issues in comments

changelog:none
2025-07-30 08:01:10 +00:00