Commit graph

10305 commits

Author SHA1 Message Date
Timo
871df561a0
Fix match_ref_pats FP on match scrutinee of never type (#15474)
Closes rust-lang/rust-clippy#15378

changelog: [`match_ref_pats`] fix FP on match scrutinee of never type
2025-08-14 18:02:36 +00:00
yanglsh
05c2d72abc fix: match_ref_pats FP on match scrutinee of never type 2025-08-14 11:23:31 +08:00
Jason Newcomb
355e4bacf5
as_ptr_cast: move the unfixable case into a separate file (#15475)
allows creating `.fixed` for the main file

changelog: none
2025-08-13 17:11:14 +00:00
Ada Alakbarova
ff2b5e66a1
test: make suggestions the main file
since it's the one that has suggestions
2025-08-13 16:34:24 +02:00
Ada Alakbarova
ad9686e0c7
test: move the main file to unfixable
since it's the one that makes no suggestions
2025-08-13 16:33:48 +02:00
Ada Alakbarova
f0bb5cde69
as_ptr_cast: move the unfixable case into a separate file
allows creating `.fixed` for the main file
2025-08-13 16:09:04 +02:00
Ada Alakbarova
af2dd2d3bc
fix unnecessary_semicolon: don't lint on stmts with attrs 2025-08-12 19:12:47 +02:00
Timo
14dfc03597
feat: introduce path_to_local_with_projections (#15396)
As suggested in
https://github.com/rust-lang/rust-clippy/pull/15268#discussion_r2249249661

WIP because:
- [x] what should be done with the now-error-pattern-less
`tests/ui/double_ended_iterator_last_unfixable.rs`?
- [x] is the change in behaviour of `double_ended_iterator_last` okay in
general?
- cc @samueltardieu because this changes the code you added in
https://github.com/rust-lang/rust-clippy/pull/14140

changelog: none

r? @y21
2025-08-10 10:33:05 +00:00
Samuel Tardieu
e6b63d15fa
fix &str type check in from_str_radix_10 (#15410)
minor fix in `from_str_radix_10` lint, `is_type_diagnostic_item` only
checks `Adt`, use `.is_str()` instead

changelog: [`from_str_radix_10`]: properly lint references to `&str` as
well
2025-08-09 22:30:18 +00:00
Ada Alakbarova
04606e27dc
introduce path_to_local_with_projections
combine two similar arms

use in `eager_transmute`

use in `double_ended_iterator_last`

use different numbers in the new test case to avoid possible confusion

move the other "unfixable" case as well; it shouldn't lint anyway, so
having it in the main test file is fine
2025-08-09 20:27:30 +02:00
Dave Rolsky
5c617b4867
Add "PowerPC" to the list of valid CamelCase strings in docs 2025-08-09 10:28:14 -05:00
dswij
386372a0e4
[[infinite_loop] fix infinite loop false positive (#15157)
changelog: [infinite_loop]: Improve handling of infinite loops in async
blocks

Fix rust-lang/rust-clippy#14000

This PR refines the [infinite_loop] lint to avoid false positives when
infinite loops occur inside async blocks that are not awaited (such as
those that are spawned or assigned to variables for later use). The lint
will now only trigger when the async block containing the loop is
directly awaited.
2025-08-09 15:08:54 +00:00
Jason Newcomb
ea7ebaa825
Do not attempt to compute size of a type with escaping lifetimes (#15434)
A type with escaping bound vars cannot be wrapped in a dummy binder
during size computation.

Fixes rust-lang/rust-clippy#15429

changelog: [`zero_sized_hashmap_values`]: fix ICE in types with escaping
lifetimes

r? Jarcho

<!-- TRIAGEBOT_START -->

<!-- TRIAGEBOT_SUMMARY_START -->

### Summary Notes

- [Beta
nomination](https://github.com/rust-lang/rust-clippy/pull/15434#issuecomment-3164866684)
by [samueltardieu](https://github.com/samueltardieu)

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

<!-- TRIAGEBOT_SUMMARY_END -->
<!-- TRIAGEBOT_END -->
2025-08-09 14:09:43 +00:00
Ada Alakbarova
ac9361e18a
eta_reduction: don't refer to ADT constructors as "function"s 2025-08-08 11:00:49 +02:00
Chengxu Bian
c945393f67 fix inf loop 2025-08-07 22:17:37 -04:00
Samuel Tardieu
c752fb2802
Do not attempt to compute size of a type with escaping lifetimes
A type with escaping bound vars cannot be wrapped in a dummy binder
during size computation.
2025-08-07 18:29:10 +02:00
Philipp Krones
f2b7e9ff52
Merge remote-tracking branch 'upstream/master' into rustup 2025-08-07 16:47:42 +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
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
Zihan
7a113811fa
fix &str type check in from_str_radix_10
changelog: none

Signed-off-by: Zihan <zihanli0822@gmail.com>
2025-08-05 09:50:17 -04: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
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
Fayti1703
5b22c0c1ed Remove rogue comma from infallible_try_from lint message 2025-08-04 16:38:31 +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
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
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
xizheyin
d7b7e236e7 Extend is_case_difference to handle digit-letter confusables
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-07-31 13:55:59 +08: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
Samuel Tardieu
436efbba90
Fix min_ident_chars: ignore on trait impl. (#15275)
fixes rust-lang/rust-clippy#13396

changelog: [`min_ident_chars`]: ignore lint when implementing a trait,
to respect [`renamed_function_params`]
2025-07-30 07:57:34 +00:00
houpo-bob
64276e688c chore: fix some minor issues in comments
Signed-off-by: houpo-bob <houpocun@outlook.com>
2025-07-30 15:49:56 +08:00
Tom Webber
e8db4aa470 Fix min_ident_chars: add trait/impl awareness 2025-07-30 07:10:07 +02:00
Samuel Tardieu
642bec7617
Optimize some usages of double unary operators in suggestions
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.

Also, when adding a unary operator to a suggestion, do not enclose the
operator argument in parentheses if it starts with a unary operator
itself unless it is a binary operation (including `as`), because in this
case parentheses are required to not bind the lhs only.

Some suggestions will now be shown as `x` instead of `!!x`. Right now,
no suggestion seems to produce `--x`.
2025-07-30 00:34:26 +02:00
Alejandra González
c7dd98c809
Do not autofix comments containing bare CR (#15175)
When a bare CR is present in a four slashes comment, keep triggering the
lint but do not issue a fix suggestion as bare CRs are not supported in
doc comments. An extra note is added to the diagnostic to warn the user
about it.

I have put the test in a separate file to make it clear that the bare CR
is not a formatting error.

Fixes rust-lang/rust-clippy#15174

changelog: [`four_forward_slashes`]: warn about bare CR in comment, and
do not propose invalid autofix
2025-07-29 17:05:13 +00:00
Alejandra González
b7cc5c45bd
Fix search_is_some suggests wrongly inside macro (#15135)
Closes rust-lang/rust-clippy#15102

changelog: [`search_is_some`] fix wrong suggestions inside macro
2025-07-29 16:31:55 +00:00
Samuel Tardieu
431f95ec85
Fix typo in internal error message 2025-07-28 17:32:40 +02:00
Samuel Tardieu
4f1044a5a6
Do not specialize for if_chain any longer
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.
2025-07-28 17:26:38 +02:00
Alex Macleod
d73a6b797f
Do not treat NixOS as a Pascal-cased identifier (#15361)
changelog: [`doc_markdown`]: do not treat NixOS as a Pascal-cased
identifier

Fixes rust-lang/rust-clippy#15360
2025-07-28 14:53:08 +00:00