Commit Graph

25158 Commits

Author SHA1 Message Date
Samuel Tardieu 7f0774a151 Fix wrong suggestion for println_empty_string with non-parenthesis delimiters (#16846)
Fixes rust-lang/rust-clippy#16843

changelog: [`println_empty_string`]: fix wrong suggestion with
non-parenthesis delimiters
2026-04-13 15:59:32 +00:00
lapla 7f096cff9d Fix wrong suggestion for println_empty_string with non-parenthesis delimiters 2026-04-12 20:47:54 +09:00
dswij ea2b4d224f Fix unused_async FP for stubs with args (#16832)
Closes rust-lang/rust-clippy#16825

changelog: [`unused_async`] fix FP for stubs with args
2026-04-12 10:26:20 +00:00
Ada Alakbarova 08fa871dcc Even more fixes for handling of macros (#16443)
*[View all
comments](https://triagebot.infra.rust-lang.org/gh-comments/rust-lang/rust-clippy/pull/16443)*

Continuation rust-lang/rust-clippy#16337

Even more fixes for handling macros

changelog: [`manual_rotate`] fix wrongly unmangled macros
changelog: [`map_with_unused_argument_over_ranges`] fix wrongly
unmangled macros
changelog: [`needless_bool`] fix wrongly unmangled macros
changelog: [`manual_is_power_of_two`] fix wrongly unmangled macros
changelog: [`manual_div_ceil`] fix wrongly unmangled macros
changelog: [`implicit_saturating_sub`] fix wrongly unmangled macros
changelog: [`range_minus_one`] fix wrongly unmangled macros
changelog: [`range_plus_one`] fix wrongly unmangled macros
changelog: [`manual_swap`] fix wrongly unmangled macros
changelog: [`let_and_return`] fix wrongly unmangled macros
2026-04-11 10:53:58 +00:00
Ada Alakbarova d588ba3068 Extend manual_filter to cover and_then (#16456)
*[View all
comments](https://triagebot.infra.rust-lang.org/gh-comments/rust-lang/rust-clippy/pull/16456)*

Closes rust-lang/rust-clippy#14440

Implemented as enhancement to `manual_filter`

changelog: [`manual_filter`] enhance to cover `and_then`
2026-04-11 09:34:11 +00:00
linshuy2 878feaa4dd fix: unused_async FP for stubs with args 2026-04-09 15:36:06 +00:00
Jason Newcomb 46a80c238f fn_to_numeric_cast_any: Do not warn cast to raw pointer (#14109)
Fixes #12638

changelog: [`fn_to_numeric_cast_any`]: Fix false positive on a cast to
raw pointer
2026-04-09 15:20:47 +00:00
linshuy2 3351369d43 Enhance manual_filter to cover and_then 2026-04-07 22:58:06 +00:00
Jason Newcomb f5f3c2f30a Truncate constants to target type in comparison (#16782)
changelog: [`bad_bit_mask`]: truncate constant to target type before
warning about impossible equality

Fixes rust-lang/rust-clippy#16781
2026-04-07 19:34:09 +00:00
Samuel Tardieu c4e5a77b76 unneeded_wildcard_pattern.rs: fix typo (rathter -> rather) (#16818)
changelog: none
2026-04-07 07:33:22 +00:00
Daniel Scherzer c40e988d19 unneeded_wildcard_pattern.rs: fix typo (rathter -> rather) 2026-04-06 16:45:50 -07:00
Ada Alakbarova 49a2f386f9 Unneeded wildcard improvement (#16733)
*[View all
comments](https://triagebot.infra.rust-lang.org/gh-comments/rust-lang/rust-clippy/pull/16733)*

changelog: [`unneeded_wildcard_pattern`]: add support for struct
constructs.

Closes [#16638](https://github.com/rust-lang/rust-clippy/issues/16638)

The existing lint only looks at tuples and tuplestructs. This change
adds support for standard structs, looking for cases
where one or more `_` immediately preceed a `..`. The preceeding `_`
members may be omitted, as they will be collected by the `..` operator.
2026-04-06 15:04:13 +00:00
jim df2f81b8e7 add struct support to unneeded_wildcard_pattern lint
Apply suggestions from code review

Co-authored-by: Ada Alakbarova <58857108+ada4a@users.noreply.github.com>
2026-04-05 14:26:56 -04:00
Samuel Tardieu 389a32a4c3 perf: disable nonminimal_bool by default (#16761)
After performance concers on the `nonminimal_bool` lint, we [performed a
crater run](https://github.com/rust-lang/rust/issues/153883)

This crater run revealed that in 19120 suggestions taken from 1.3
million crates, only about 36% had resulted in multi-terminal
suggestions (suggestions that were not only a single boolean).

This suggests that most cases of this lint firing, the expression that
triggered was pretty simple. And thus, we should not take such a huge
toll for a lint that isn't that useful.

In the future, a rewrite of that `bool_expr` function could be very
useful to alleviate the performance toll. Because clearly running the
Quine McCluskey algorithm on all those boolean operations is not ideal.

---

## Performance report:

`cargo clippy` -> 5,077,447,157 icount
`cargo check` -> 3,629,576,891 icount

So the Clippy that `rustup` delivers is about 1.4b instructions more
than `cargo check`.

`NonminimalBool` lint pass -> 318,169,034

$$\frac{nonminimal\\_bool}{clippy-check}*100 = 21.97496844$$

So, the `NonminimalBool` lint pass is about 22% of all Clippy-exclusive
instruction count.

---

After this change, we can now compare the Clippy BUILT FROM MASTER, NOT
DELIVERED BY RUSTUP, with the Clippy from this PR.

`master/target/release/cargo-clippy` -> 5,296,838,955 (Slower than
Rustup)
`pr/target/release/cargo-clippy` -> 4,977,035,941.

So, $master - PR = 319803014$, which is the exact icount of
`Nonminimal_bool` and about 22% of Clippy's whole execution time.

Profiled on `syn-2.0.71`, with Callgrind.

changelog:[`nonminimal_bool`]: Move to `pedantic`.
changelog:[`overly_complex_bool_expr`]: Move to `pedantic`.
2026-04-05 11:54:26 +00:00
llogiq ab9cb427b8 Rework expr_use_ctxt into an iterator over successive use sites. (#16784)
This is going to be used as part of more thoroughly checking whether we
can change the type of an expression. e.g. `range_plus_one` suggests
changing `Range` to `RangeInclusive`.

changelog: none
2026-04-05 06:02:51 +00:00
llogiq 1e0b66ef7e fix: unnecessary type cast causing a compile error (#16796)
In some cases, removing a cast that looks unnecessary can
still change type inference, even when the cast is to the
expected same type.

The lint now handles casts that flow through
intermediate expressions (e.g. calls, blocks, let
bindings, loops...). It also treats placeholder
generics (e.g. `::<_>`) as inference sensitive.

Added regression tests with similar behavior
as the original bug, some edge cases and
tests to check if false negative cases
weren't created.

Closes rust-lang/rust-clippy#16449

changelog: [`unnecessary_cast`]: fixed a suggestion to remove a cast
that can cause a compilation error if followed.
2026-04-04 20:12:58 +00:00
llogiq 3cd5a6569a [unsafe_removed_from_name]: skip linting when renaming to '_' (#16802)
closes: rust-lang/rust-clippy#16768

I agree with the:
> importing it just to get the side effects of the trait being in scope
(anonymously, via as _) is not renaming it...

even without changing the name, we still not able to see it's original
name when calling a trait method, so I think this should be fine.

---

changelog: [`unsafe_removed_from_name`]: skip linting when renaming to
'_'
2026-04-04 19:32:30 +00:00
dswij ee4aff91c5 Multiple fixes to FNs of question_mark (#16769)
Closes rust-lang/rust-clippy#16751

changelog: [`question_mark`] fix FN for manual unwrap with `if let` or
`match`
changelog: [`question_mark`] fix FN when the match scrutinee is behind
reference
changelog: [`question_mark`] fix FN when match binding is behind `ref`
or `mut`
2026-04-04 15:56:33 +00:00
llogiq 80d86e3465 Update cargo_metadata to 0.23 (#16803)
Updates cargo_metadata to 0.23 and fixes all the resultant issues.

changelog: none
2026-04-04 13:23:04 +00:00
Jacob Adam 26799d9112 Update cargo_metadata to 0.23. 2026-04-03 20:11:43 +01:00
J-ZhengLi d5f106507b [unsafe_removed_from_name]: skip lint when renaming to '_' 2026-04-04 02:07:40 +08:00
llogiq 88f787d193 Rustup (#16791)
r? @ghost

changelog: none
2026-04-03 17:24:39 +00:00
Philipp Krones f4d6d6935c Remove internal lint DERIVE_DESERIALIZE_ALLOWING_UNKNOWN
rustc doesn't keep around proc macro helper attributes in the HIR. So it is no
longer possible to lint this. In a LateLintPass the necessary information isn't
around anymore, in an EarlyPassLint derive attributes are already expanded and
dropped and it is not possible to relate an impl with the type it is implemented
on. Doing that with `ast::Path`s is brittle.
2026-04-03 14:19:09 +02:00
Guilherme Silva b269a2b71f fix: unnecessary type cast causing a compile error
In some cases, removing a cast that looks unnecessary
can still change type inference, even when the cast is
to the expected same type.

The lint now handles casts that flow through
intermediate expressions (e.g. calls, blocks, let
bindings, loops...). It also treats placeholder
generics (e.g. `::<_>`) as inference sensitive.

Added regression tests with similar behavior
as the original bug, some edge cases and
tests to check if false negative cases
weren't created.

Closes #16449
2026-04-02 22:47:35 +01:00
Jason Newcomb 174df86e5f Few small fixes for clippy_dev/new_lint (#16795)
---

*Please write a short comment explaining your change (or "none" for
internal only changes)*

changelog: none
2026-04-02 20:53:11 +00:00
Pavel Grigorenko a390a52e74 clippy_dev/new_lint: sort imports in the snippet 2026-04-02 22:33:18 +03:00
Pavel Grigorenko 750e578195 clippy_dev/new_lint: fix path to the file where MSRVs reside 2026-04-02 22:30:26 +03:00
Philipp Krones 994d5b4ac8 Bump nightly version -> 2026-04-02 2026-04-02 13:49:57 +02:00
Philipp Krones 1d55118849 Merge remote-tracking branch 'upstream/master' into rustup 2026-04-02 13:31:08 +02:00
Jason Newcomb 8322ae2cfb Rework expr_use_ctxt into an iterator over successive use sites. 2026-03-30 11:54:43 -04:00
Samuel Tardieu ab1279e967 Truncate constants to target type in comparison 2026-03-30 13:11:55 +02:00
Jonathan Brouwer 4efda7afee Rollup merge of #154074 - dianne:dbg-temp-scopes, r=Mark-Simulacrum
don't drop arguments' temporaries in `dbg!`

Fixes rust-lang/rust#153850

Credit to @theemathas for help with macro engineering ^^

r? libs
2026-03-29 21:39:26 +02:00
dianne e689235a7e update diagnostic for variables moved by dbg! 2026-03-29 09:48:41 -07:00
dianne 7d9ab57a4f don't drop arguments' temporaries in dbg! 2026-03-29 06:38:38 -07:00
llogiq c07baa4cc9 Add manual_option_zip lint (a.and_then(|x| b.map(|y| (x, y)))) (#16600)
*[View all
comments](https://triagebot.infra.rust-lang.org/gh-comments/rust-lang/rust-clippy/pull/16600)*

changelog: [`manual_option_zip`]: new lint that detects `a.and_then(|a|
b.map(|b| (a, b)))` and suggests using `a.zip(b)` instead

This PR introduces a new lint `manual_option_zip` that identifies cases
where `Option::and_then` is followed by `Option::map` in the provided
closure to construct a tuple that could be more concisely shaped using
`Option::zip`.

The lint detects the pattern:
```rust
a.and_then(|x| b.map(|y| (x, y)))
```

And suggests replacing it with:
```rust
a.zip(b)
```

Closes rust-lang/rust-clippy#16599
2026-03-28 21:58:47 +00:00
Samuel Tardieu e4683d27a9 impl manual_noop_waker lint (#16687)
*[View all
comments](https://triagebot.infra.rust-lang.org/gh-comments/rust-lang/rust-clippy/pull/16687)*

Fixes rust-lang/rust-clippy#16639

### Description

This PR introduces a new lint manual\_noop\_waker that detects manual,
empty implementations of the std::task::Wake trait. These can be
replaced with std::task::Waker::noop(), which is more performant (avoids
Arc allocation) and cleaner.

### Example

```rust
struct MyWaker;
impl Wake for MyWaker {
    fn wake(self: Arc<Self>) {}
    fn wake_by_ref(self: &Arc<Self>) {}
}
````
Can be replaced with:

```rust
let waker = Waker::noop();

````

* \[x\] I've followed the [contribution
guidelines](https://github.com/rust-lang/rust-clippy/blob/master/CONTRIBUTING.md)

*   \[x\] I've added UI tests for the new lint

*   \[x\] I've run `cargo dev update_lints`

changelog: `[manual_noop_waker]`: Added a lint to detect manual no-op
Wake implementations.
2026-03-28 17:49:00 +00:00
Jaroslaw Roszyk 26740ea4ab impl manual_noop_waker lint 2026-03-28 15:17:02 +01:00
Jason Newcomb fee9100776 Issue #16110: similar_names not triggered by example (#16300)
*Please write a short comment explaining your change (or "none" for
internal only changes)*
Fixes rust-lang/rust-clippy#16110
changelog: [`similar_names`] : Changed the lint docs to reflect its
actual behavior
2026-03-28 00:33:40 +00:00
alt440 453a482373 Ran cargo dev fmt 2026-03-27 20:13:15 -04:00
alt440 ee7896e041 similar_names not triggered by example 2026-03-27 20:13:13 -04:00
alt440 837e8917a6 Revert "similar_names not triggered by example"
This reverts commit e82f527e21415da49f30473d4562adb967f867e4.
2026-03-27 20:10:48 -04:00
alt440 111b8dc87e Revert "Correct dogfood tests"
This reverts commit 74578256f1f009de382589b87fa356906c18a61b.
2026-03-27 20:10:46 -04:00
alt440 c5b3fcf243 Revert "Executed cargo fmt"
This reverts commit 9b9de0f218d504a5682649ea3745ea8887698656.
2026-03-27 20:09:44 -04:00
alt440 df8f576cdf Executed cargo fmt 2026-03-27 20:09:44 -04:00
alt440 44435734ff Correct dogfood tests 2026-03-27 20:09:42 -04:00
alt440 ea5bc07c19 similar_names not triggered by example 2026-03-27 20:07:42 -04:00
Jason Newcomb 75813d35fd Preserve parentheses in suggestion in presence of cascaded casts (#16483)
changelog: [`unnecessary_cast`]: preserve parentheses in presence of
cascaded casts

Fixes rust-lang/rust-clippy#16475
2026-03-27 23:19:50 +00:00
Jason Newcomb e43491b0df chore(deps): update rust crate tar to v0.4.45 (#16771)
Fix
[RUSTSEC-2026-0068](https://rustsec.org/advisories/RUSTSEC-2026-0068.html):
tar-rs incorrectly ignores PAX size headers if header size is nonzero
Fix
[RUSTSEC-2026-0067](https://rustsec.org/advisories/RUSTSEC-2026-0067.html):
`unpack_in` can chmod arbitrary directories by following symlinks

cc: @clubby789

changelog: none
2026-03-27 17:57:00 +00:00
xtqqczze a7a0fc3cc7 chore(deps): update rust crate tar to v0.4.45 2026-03-27 13:32:41 +00:00
Daria Sukhonina 6e68667da9 Use tcx.local_parent() more often 2026-03-27 15:36:29 +03:00