Commit graph

24470 commits

Author SHA1 Message Date
Samuel Tardieu
344ddcf9f2
Move needless_type_cast lint to nursery
The lint is new and already has several bugs filed against it, including
an ICE.
2025-12-15 20:13:34 +01:00
Jason Newcomb
4d4789cdec
Count unsafe operations and macro calls once towards the innermost unsafe block (#16117)
changelog: [`multiple_unsafe_ops_per_block`]: count unsafe operations
only towards the innermost unsafe block

Fixes rust-lang/rust-clippy#16116

r? Jarcho
2025-12-15 14:57:23 +00:00
Samuel Tardieu
099062d6b0
Fix set-contains-or-insert FP when set is mutated before insert (#16009)
Closes rust-lang/rust-clippy#15990

changelog: [`set-contains-or-insert`] fix FP when set is mutated before
`insert`
2025-12-15 13:19:09 +00:00
Samuel Tardieu
95d5990b99
Fix map_entry suggests wrongly for insert with cfg-ed out code (#15800)
Closes rust-lang/rust-clippy#15781

changelog: [`map_entry`] fix wrong suggestions for insert with cfg-ed
out code
2025-12-15 13:10:42 +00:00
Samuel Tardieu
924f153dcd
Fix match_like_matches_macro wrongly unmangled macros (#16018)
Closes rust-lang/rust-clippy#16015

changelog: [`match_like_matches_macro`] fix wrongly unmangled macros
2025-12-15 12:49:30 +00:00
Samuel Tardieu
893677fc14
feat(format_push_string): give a (possibly incomplete) suggestion (#16093)
Resolves https://github.com/rust-lang/rust-clippy/issues/8824

Supersedes https://github.com/rust-lang/rust-clippy/pull/15828 -- I
wasn't able to get `TyCtxt::in_scope_traits` to work, so here's a more
basic implementation that just adds a note about the possible need to
import `std::fmt::Write`.

changelog: [`format_push_string`]: add a suggestion
2025-12-15 12:46:15 +00:00
Jason Newcomb
d36794f5ec
Add iterator reduction coverage to never_loop (#16222)
Fixes rust-lang/rust-clippy#16061.

Extend `never_loop` to also lint iterator reduction methods (e.g.
`for_each`, `try_for_each`, `fold`, `try_fold`, `reduce`, `all`, `any`)
when the closure’s body diverges (return type `!`). Add a UI test
`never_loop_iterator_reduction` to cover these cases.

Testing:
- TESTNAME=never_loop_iterator_reduction cargo uitest

changelog: [`never_loop`]: lint diverging iterator reduction closures
like `for_each` and `fold`
2025-12-15 12:00:31 +00:00
Cuong Le
c59da4f809
loops: reuse iterator checks for unused_enumerate_index 2025-12-15 15:11:48 +07:00
dswij
80fce9b0f5
Fix if_not_else wrong unmangled macros (#15931)
Closes rust-lang/rust-clippy#15924

changelog: [`if_not_else`] fix wrongly unmangled macros
2025-12-14 03:58:00 +00:00
Cuong Le
9dca2a8ad3
Refactor loops MethodCall handling into single match 2025-12-14 09:56:35 +07:00
Jason Newcomb
9a089b63a0
Fix unchecked_time_subtraction FN on Ops::sub method call (#16233)
Closes rust-lang/rust-clippy#16230
Closes rust-lang/rust-clippy#16234
Closes rust-lang/rust-clippy#16236

changelog: [`unchecked_time_subtraction`] fix FN on `Ops::sub` method
call
2025-12-13 22:19:32 +00:00
Linshu Yang
e0a74c3335 fix: manual_instant_elapsed wrongly unmangled macros 2025-12-13 20:57:44 +00:00
Linshu Yang
e95ceddbc6 fix: unchecked_time_subtraction wrongly unmangled macros 2025-12-13 20:44:14 +00:00
Linshu Yang
075548e9e9 fix: unchecked_time_subtraction FN on Ops::sub method call 2025-12-13 20:44:10 +00:00
Jason Newcomb
f206ef8452
Fix clippy::ref_as_ptr for non-temporary references in let/const (#16214)
Fix `ref_as_ptr` false positives for temporary values and
let/static/const initializers.

Fixes rust-lang/rust-clippy#16220

changelog: [`ref_as_ptr`]: Only lint on non-temporary expressions)
2025-12-13 18:42:05 +00:00
abd002
aefb01b852 Fix clippy::ref_as_ptr for non-temporary references in let/const 2025-12-13 19:27:43 +02:00
Cuong Le
51580d3835
Refine never_loop iterator reduction check 2025-12-13 21:34:20 +07:00
Jason Newcomb
d06ae84771
feat(unnecessary_fold): lint on folds with Add::add/Mul::mul (#16124)
Resurrects https://github.com/rust-lang/rust-clippy/pull/13475

changelog: [`unnecessary_fold`]: lint on `fold`s with
`Add::add`/`Mul::mul`
2025-12-12 18:39:22 +00:00
Jason Newcomb
89aeed1c24
Fix if_then_some_else_none FP when encountering await codes (#16178)
changelog: Fix FP of [`if_then_some_else_none`] when the `then` block
contains `await` codes.

That is because `bool:then` doesn't work with await code.

Closes: rust-lang/rust-clippy#16176
2025-12-12 15:44:52 +00:00
Cuong Le
fefd58b32b
Clean up unused try_reduce entry in sym 2025-12-12 10:37:34 +07:00
Cuong Le
89a848c439
Fix fmt and dogfood lints for never_loop iterator reduction 2025-12-12 10:24:49 +07:00
Cuong Le
36201bdf3e
Add iterator reduction coverage to never_loop 2025-12-12 10:01:58 +07:00
Philipp Krones
9e3e9649cb
Rustup (#16217)
r? @ghost

changelog: none
2025-12-11 18:00:44 +00:00
Philipp Krones
1ff4682590
Bump Clippy version -> 0.1.94 2025-12-11 18:48:15 +01:00
Philipp Krones
42c8b68ee9
Bump nightly version -> 2025-12-11 2025-12-11 18:48:10 +01:00
Philipp Krones
de365c057e
Merge remote-tracking branch 'upstream/master' into rustup 2025-12-11 18:48:00 +01:00
Ada Alakbarova
34551be259
feat(format_push_string): add a suggestion 2025-12-11 10:53:04 +01:00
Ada Alakbarova
2a224f3e79
clean-up 2025-12-11 10:48:45 +01:00
Ada Alakbarova
254e0cb3bc
feat(unnecessary_fold): lint on folds with Add::add/Mul::mul 2025-12-11 10:18:30 +01:00
Ada Alakbarova
4ce7628869
clean-up 2025-12-10 19:38:09 +01:00
Linshu Yang
dc0bf26dd4 fix: match_like_matches_macro wrongly unmangled macros 2025-12-10 17:59:18 +00:00
Matthias Krüger
d196db781e Rollup merge of #149489 - scottmcm:try-bikeshed, r=nnethercote
Experimentally add *heterogeneous* `try` blocks

rust-lang/rust#148725 moved the default to being homogeneous; this adds heterogeneous ones back under an obvious-bikeshed syntax so people can experiment with that as well.

Essentially resolves rust-lang/rust#149025 by letting them move to this syntax instead.

New tracking issue: rust-lang/rust#149488
Related RFC: https://github.com/rust-lang/rfcs/pull/3721#issuecomment-3208342727 (specifically about experimenting)
2025-12-10 17:16:47 +01:00
Alex Macleod
961ea1c46b
feat(manual_saturating_arithmetic): lint x.checked_sub(y).unwrap_or_default() (#15845)
Resolves https://github.com/rust-lang/rust-clippy/issues/15655

changelog: [`manual_saturating_arithmetic`]: lint
`x.checked_sub(y).unwrap_or_default()`
2025-12-10 15:53:23 +00:00
Alex Macleod
06ded880d2
fix(match_like_matches_macro): FP with guards containing if let (#15876)
Fixes https://github.com/rust-lang/rust-clippy/issues/15841

changelog: [`match_like_matches_macro`]: FP with guards containing `if
let`
2025-12-10 15:35:51 +00:00
Alex Macleod
16eaf79976
feat(transmute_ptr_to_ref): Handle a pointer wrapped in a struct (#15948)
Fixes rust-lang/rust-clippy#1966.

Now the program checks for transmutting from a struct containing a
single raw pointer to a reference.

```Rust
struct Foo(*const i32);
fn foo(foo: Foo) -> &i32 {
    unsafe { transmute(foo) }
}
```

changelog: [`transmute_ptr_to_ref`]: now checks for a pointer wrapped in
a struct
2025-12-10 15:33:36 +00:00
Philipp Krones
535725701a
Changelog for Clippy 1.92⛸️ (#16158)
Violets are red,
Roses are blue,
Snowflakes dance softly,
And winter winds brew.

--------
Alaska breaking time and space from @kyotuca is the winner at
https://github.com/rust-lang/rust-clippy/pull/15971

<img width="1134" height="1495" alt="image"
src="https://github.com/user-attachments/assets/d7878cfa-c285-4af2-af3b-26c737d57b1c"
/>

--------

Cats for the next release can be traditionally nominated in the
comments.

changelog: none

r? flip1995
2025-12-10 10:10:46 +00:00
Philipp Krones
c47bc5d1a9
Remove ICE fix that was already backported to 1.91 2025-12-10 11:00:20 +01:00
Scott McMurray
9495686c40 Update clippy for the ast TryBlock change 2025-12-09 20:18:43 -08:00
llogiq
8293d5edc7
Add needless_type_cast lint (#16139)
Clippy should warn when a const, static, or let binding is defined as
one integer type but immediately/ consistently cast to another type at
usage sites without any usage of the original type. fixes
rust-lang/rust-clippy#16137

changelog: [`needless_type_cast `]: suggests defining bindings as their
cast type
2025-12-09 22:25:09 +00:00
Samuel Onoja
1232c81a3e
Add needless_type_cast lint 2025-12-09 22:56:23 +01:00
llogiq
0cf51b1b73
Fix typo in deprecated lint string_to_string message (#16208)
Closes: rust-lang/rust-clippy#16204

----

changelog: Fix typo in deprecated lint `string_to_string` message
2025-12-09 19:03:30 +00:00
irelaxcn
d0e4b5b159 Fix typo in deprecated lint string_to_string message 2025-12-10 01:34:25 +08:00
Jason Newcomb
52fea21d5f
Fix tuple_array_conversions FP when binded vars are used before conversion (#16197)
Closes rust-lang/rust-clippy#16192

changelog: [`tuple_array_conversions`] fix FP when binded vars are used
before conversion
2025-12-09 17:05:01 +00:00
Esteban Küber
94aa13a09c Recognize type Alias = dyn Trait in fn return types
```
error[E0277]: the size for values of type `(dyn Debug + 'static)` cannot be known at compilation time
  --> $DIR/dyn-trait-type-alias-return-type.rs:4:11
   |
LL | fn f() -> T { loop {} }
   |           ^ doesn't have a size known at compile-time
   |
   = help: the trait `Sized` is not implemented for `(dyn Debug + 'static)`
note: this type alias is unsized
  --> $DIR/dyn-trait-type-alias-return-type.rs:1:1
   |
LL | type T = dyn core::fmt::Debug;
   | ^^^^^^
   = note: the return type of a function must have a statically known size
```
2025-12-09 16:46:33 +00:00
Linshu Yang
3551aeb5c3 fix: tuple_array_conversions FP when binded vars are used before conversion 2025-12-09 16:34:40 +00:00
irelaxcn
6159c1971f Fix if_then_some_else_none FP when the then block contains .await 2025-12-09 21:37:53 +08:00
Jason Newcomb
70a4d957ec
Fixes #16109: For non-sized types, use reborrow in suggestions to remove while-let loops (#16100)
Fixes rust-lang/rust-clippy#16019 by reborrowing, instead of using
by_ref, when the iterator expression is not `Sized`.

```
changelog: [`while_let_on_iterator`]: fixes broken suggestion by using reborrow instead of `by_ref` for references to traits that are not `Sized`
```
2025-12-09 03:44:14 +00:00
Samuel Tardieu
66ebabec07
Remove [no-mentions] handler in our triagebot config (#16206)
This PR removes the `[no-mentions]` handler in our triagebot config as
[GitHub is removing notifications for @-mentions in commit messages on
December 8th
2025.](https://github.blog/changelog/2025-11-07-removing-notifications-for-mentions-in-commit-messages/)

cf. https://github.com/rust-lang/triagebot/issues/2225

changelog: none
2025-12-09 00:30:27 +00:00
Urgau
4648af6751 Remove [no-mentions] handler in our triagebot config
https://github.blog/changelog/2025-11-07-removing-notifications-for-mentions-in-commit-messages/
2025-12-08 18:42:10 +01:00
Jason Newcomb
d5d644f400
refactor(missing_asserts_for_indexing): overhaul diagnostics (#16120)
changelog: [`missing_asserts_for_indexing`]: overhaul diagnostics
2025-12-08 13:34:15 +00:00