Skip to content

Clippy subtree update#154809

Merged
rust-bors[bot] merged 68 commits intorust-lang:mainfrom
flip1995:clippy-subtree-update
Apr 5, 2026
Merged

Clippy subtree update#154809
rust-bors[bot] merged 68 commits intorust-lang:mainfrom
flip1995:clippy-subtree-update

Conversation

@flip1995
Copy link
Copy Markdown
Member

@flip1995 flip1995 commented Apr 4, 2026

r? Manishearth

2 days late due to some sync difficulties.

jakubadamw and others added 30 commits March 5, 2026 19:33
Detects `a.and_then(|x| b.map(|y| (x, y)))` and suggests `a.zip(b)`.
Co-authored-by: Ada Alakbarova <58857108+ada4a@users.noreply.github.com>
Add a HasAttrs<'tcx, Tcx> trait to rustc_hir that allows find_attr! to
accept DefId, LocalDefId, OwnerId, and HirId directly, instead of
requiring callers to manually fetch the attribute slice first.

The trait is defined in rustc_hir with a generic Tcx parameter to avoid
a dependency cycle (rustc_hir cannot depend on rustc_middle). The four
concrete impls for TyCtxt are in rustc_middle.
The pretty printer now correctly parenthesizes or-patterns inside
`box` patterns, which changes the Clippy `unnested_or_patterns` lint
suggestion from `box box (0 | 2 | 4)` to `box (box (0 | 2 | 4))`.
The new output is more correct — the old suggestion was itself missing
parens and would have been parsed as `box (box 0) | 2 | 4`.

Signed-off-by: Andrew V. Teylu <andrew.teylu@vector.com>
properly select post operation for identity map according to map method kind

changelog: [`iter_kv_map`]: handle identity map for `map` and `flat_map`

Signed-off-by: Zihan <zihanli0822@gmail.com>
Detects manual implementations of the newly implemented
[`BinaryHeap::pop_if()`](rust-lang#151828)
in `manual_pop_if`.

I wasn't sure about how best to handle checking for the nightly feature.
Could we let people compiling with nightly know that the feature is
available even if they don't have it enabled?

changelog: [`manual_pop_if`]: detect manual implementations of
`BinaryHeap::pop_if()`
…chenyukang

Parenthesize or-patterns in prefix pattern positions in pretty printer

The AST pretty printer was dropping parentheses around or-patterns when they appeared inside `@` bindings, `&` references, or `box` patterns. For example:

- `v @ (1 | 2 | 3)` was printed as `v @ 1 | 2 | 3`
- `&(1 | 2 | 3)` was printed as `&1 | 2 | 3`
- `box (1 | 2 | 3)` was printed as `box 1 | 2 | 3`

Since `|` has the lowest precedence among pattern operators, all of these are parsed incorrectly without parentheses — e.g. `v @ 1 | 2 | 3` becomes `(v @ 1) | 2 | 3`, binding `v` only to the first alternative.

This caused E0408 ("variable not bound in all patterns") when the expanded output was fed back to the compiler, affecting crates like html5ever and wgpu-core that use macros expanding to or-patterns after `@`.

The fix adds a `print_pat_paren_if_or` helper that wraps `PatKind::Or` subpatterns in parentheses, and uses it in the `@`, `&`, and `box` printing arms. This is similar in spirit to the existing `FixupContext` parenthesization approach used for expression printing.

## Example

**before** (`rustc 1.96.0-nightly (3b1b0ef 2026-03-11)`):

```rust
#![feature(prelude_import)]
#![no_std]
#![feature(box_patterns)]
extern crate std;
#[prelude_import]
use ::std::prelude::rust_2015::*;

//@ pretty-compare-only
//@ pretty-mode:expanded
//@ pp-exact:or-pattern-paren.pp

macro_rules! or_pat { ($($name:pat),+) => { $($name)|+ } }

fn check_at(x: Option<i32>) {
    match x {
        Some(v @ 1 | 2 | 3) =>

            {
            ::std::io::_print(format_args!("{0}\n", v));
        }
        _ => {}
    }
}
fn check_ref(x: &i32) { match x { &1 | 2 | 3 => {} _ => {} } }
fn check_box(x: Box<i32>) { match x { box 1 | 2 | 3 => {} _ => {} } }
fn main() { check_at(Some(2)); check_ref(&1); check_box(Box::new(1)); }
```

**after** (this branch):

```rust
#![feature(prelude_import)]
#![no_std]
#![feature(box_patterns)]
extern crate std;
#[prelude_import]
use ::std::prelude::rust_2015::*;

//@ pretty-compare-only
//@ pretty-mode:expanded
//@ pp-exact:or-pattern-paren.pp

macro_rules! or_pat { ($($name:pat),+) => { $($name)|+ } }

fn check_at(x: Option<i32>) {
    match x {
        Some(v @ (1 | 2 | 3)) =>

            {
            ::std::io::_print(format_args!("{0}\n", v));
        }
        _ => {}
    }
}
fn check_ref(x: &i32) { match x { &(1 | 2 | 3) => {} _ => {} } }
fn check_box(x: Box<i32>) { match x { box (1 | 2 | 3) => {} _ => {} } }
fn main() { check_at(Some(2)); check_ref(&1); check_box(Box::new(1)); }
```

Notice `v @ 1 | 2 | 3` becomes `v @ (1 | 2 | 3)`, `&1 | 2 | 3` becomes `&(1 | 2 | 3)`, and `box 1 | 2 | 3` becomes `box (1 | 2 | 3)`. Without parens, the or-pattern binds incorrectly — only the first alternative gets the `@`/`&`/`box`, causing E0408.
…id, r=JonathanBrouwer

Simplify find_attr! for HirId usage

Add a `HasAttrs<'tcx, Tcx>` trait to `rustc_hir` that allows `find_attr!` to accept `DefId`, `LocalDefId`, `OwnerId`, and `HirId` directly, instead of requiring callers to manually fetch the attribute slice first.

Before:
  `find_attr!(tcx.hir_attrs(hir_id), SomeAttr)`

After:
  `find_attr!(tcx, hir_id, SomeAttr)`

The trait is defined in `rustc_hir` with a generic `Tcx` parameter to avoid a dependency cycle (`rustc_hir` cannot depend on `rustc_middle`). The four concrete impls for `TyCtxt` are in `rustc_middle`.

Fixes rust-lang#153103
Extend the lint to detect the case where the popped value is used, but
in such cases just emit the lint with no suggestion.
Also detect the pop().unwrap_unchecked() case.

changelog: none
…nathanBrouwer

Rollup of 13 pull requests

Successful merges:

 - rust-lang#154241 (`rust-analyzer` subtree update)
 - rust-lang#153686 (`std`: include `dlmalloc` for all non-wasi Wasm targets)
 - rust-lang#154105 (bootstrap: Pass `--features=rustc` to rustc_transmute)
 - rust-lang#153069 ([BPF] add target feature allows-misaligned-mem-access)
 - rust-lang#154085 (Parenthesize or-patterns in prefix pattern positions in pretty printer)
 - rust-lang#154191 (refactor RangeFromIter overflow-checks impl)
 - rust-lang#154207 (Refactor query loading)
 - rust-lang#153540 (drop derive helpers during attribute parsing)
 - rust-lang#154140 (Document consteval behavior of ub_checks, overflow_checks, is_val_statically_known.)
 - rust-lang#154161 (On E0277 tweak help when single type impls traits)
 - rust-lang#154218 (interpret/validity: remove unreachable error kind)
 - rust-lang#154225 (diagnostics: avoid ICE in confusable_method_name for associated functions)
 - rust-lang#154228 (Improve inline assembly error messages)
Turns out that `manual_is_ascii_check` was taking up 820 million instructions
of `wasmi`'s 23 billion. Now... it doesn't. It now takes 23 million, still too much, but not
as noticeable.

Profiled in `wasmi`. 23,821,891,527 icount -> 23,035,885,185 icount

changelog:[`manual_is_ascii_check`]: Optimize by 97.125%
…ng#16755)

Turns out that `manual_is_ascii_check` was taking up 820 million
instructions of `wasmi`'s 23 billion. Now... it doesn't. It now takes 23
million, still too much, but not as noticeable.

Profiled in `wasmi`. 23,821,891,527 icount -> 23,010,885,185 icount,
3.3% performance improvement.

changelog:[`manual_is_ascii_check`]: Optimize by 97.125%
llogiq and others added 12 commits March 28, 2026 21:58
…ust-lang#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
…ulacrum

don't drop arguments' temporaries in `dbg!`

Fixes rust-lang#153850

Credit to @theemathas for help with macro engineering ^^

r? libs
---

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

changelog: none
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.
r? @ghost

changelog: none
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 4, 2026

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-clippy Relevant to the Clippy team. labels Apr 4, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 4, 2026

⚠️ Warning ⚠️

@Manishearth
Copy link
Copy Markdown
Member

@bors r+ p=1 rollup=never

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors bot commented Apr 4, 2026

📌 Commit 29bd9b3 has been approved by Manishearth

It is now in the queue for this repository.

@rust-bors rust-bors bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 4, 2026
@Zalathar
Copy link
Copy Markdown
Member

Zalathar commented Apr 5, 2026

Scheduling: Make sure this runs next after the current rollup (was: p=1).

@bors p=5

@rust-bors

This comment has been minimized.

@rust-bors rust-bors bot added merged-by-bors This PR was explicitly merged by bors. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Apr 5, 2026
@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors bot commented Apr 5, 2026

☀️ Test successful - CI
Approved by: Manishearth
Duration: 3h 9m 9s
Pushing f92020a to main...

@rust-bors rust-bors bot merged commit f92020a into rust-lang:main Apr 5, 2026
14 of 15 checks passed
@rustbot rustbot added this to the 1.96.0 milestone Apr 5, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 5, 2026

What is this? This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.

Comparing c92036b (parent) -> f92020a (this PR)

Test differences

No test diffs found

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard f92020a676251cf985cbe5134a1fd976b5207ab6 --output-dir test-dashboard

And then open test-dashboard/index.html in your browser to see an overview of all executed tests.

Job duration changes

  1. dist-i686-msvc: 2h 23m -> 1h 48m (-24.5%)
  2. dist-x86_64-mingw: 2h -> 2h 26m (+22.0%)
  3. aarch64-apple: 3h 9m -> 2h 43m (-14.0%)
  4. x86_64-rust-for-linux: 53m 6s -> 45m 41s (-14.0%)
  5. pr-check-2: 44m 25s -> 38m 18s (-13.8%)
  6. x86_64-gnu-llvm-22-3: 1h 56m -> 1h 40m (-13.8%)
  7. x86_64-gnu-aux: 2h 24m -> 2h 5m (-13.0%)
  8. x86_64-gnu: 2h 23m -> 2h 7m (-11.6%)
  9. x86_64-gnu-llvm-21-3: 1h 54m -> 1h 41m (-11.6%)
  10. aarch64-gnu-llvm-21-2: 50m 24s -> 44m 35s (-11.5%)
How to interpret the job duration changes?

Job durations can vary a lot, based on the actual runner instance
that executed the job, system noise, invalidated caches, etc. The table above is provided
mostly for t-infra members, for simpler debugging of potential CI slow-downs.

@rust-timer
Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (f92020a): comparison URL.

Overall result: ✅ improvements - no action needed

@rustbot label: -perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.3% [-0.3%, -0.3%] 2
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.3% [-0.3%, -0.3%] 2

Max RSS (memory usage)

Results (secondary 0.4%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
4.3% [3.7%, 4.8%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.5% [-4.3%, -2.7%] 2
All ❌✅ (primary) - - 0

Cycles

Results (primary -2.3%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-2.3% [-2.3%, -2.3%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -2.3% [-2.3%, -2.3%] 1

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 488.313s -> 492.059s (0.77%)
Artifact size: 395.05 MiB -> 395.04 MiB (-0.00%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged-by-bors This PR was explicitly merged by bors. T-clippy Relevant to the Clippy team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.