Skip to content

Clippy subtree update #142451

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 94 commits into from
Jun 13, 2025
Merged

Clippy subtree update #142451

merged 94 commits into from
Jun 13, 2025

Conversation

flip1995
Copy link
Member

r? @Manishearth

1 day late. Got distracted yesterday evening and forgot about it.

Alexendoo and others added 30 commits April 30, 2025 13:12
Looks for `TryFrom` implementations with uninhabited error types and
suggests to implement `From` instead.
Keep the `P` constructor function for now, to minimize immediate churn.

All the `into_inner` calls are removed, which is nice.
If an early return is found under the HIR local declaration node but
before the child process is created, it should not trigger the lint
because the child process has not yet been created.
Specifically `TyAlias`, `Enum`, `Struct`, `Union`. So the fields match
the textual order in the source code.

The interesting part of the change is in
`compiler/rustc_hir/src/hir.rs`. The rest is extremely mechanical
refactoring.
When determining when a function or method can be called from a `const`
context, the determination must be made on the instance, not on the
declaration. This makes a difference, for example, with `const_trait`
traits whose implementations may or may not be `const`.
…atten, r=jhpratt

Stabilize feature `result_flattening`

Stabilizes the `Result::flatten` method

## Implementations

- [x] Implementation `Result::flatten`: rust-lang#70140
- [x] Implementation `const` `Result::flatten`: rust-lang#130692
- [x] Update stabilization attribute macros (this PR)

## Stabilization process

- [x] Created this PR [suggested](rust-lang#70142 (comment)) by ``@RalfJung``
- [x] FCP (haven't found any, is it applicable here?)
- [ ] Close issue rust-lang#70142
I read a blog post about kernel security, and how various features might
get lost while porting to Rust. In kernel C, they have some guardrails
against divulging pointers. An easy way to replicate that in Rust is a
lint for pointer formatting. So that's what this lint does.

---

changelog: new [`pointer_format`] lint
In order to be consistent with our documentation, deprecated lints
should not be counted when displaying the total number of lints on the
[web site](https://rust-lang.github.io/rust-clippy/master/index.html).

For example, as of 2025-06-01, there are 784 non-deprecated lints which
are referred to as "over 750 lints" in the documentation, but the web site
displays "Total number: 799". When one new lint will be added, there
will be a discrepancy ("over 750 lints" vs. "Total number: 800") if this
is not fixed.
In order to be consistent with our documentation, deprecated lints
should not be counted when displaying the total number of lints on the
[web site](https://rust-lang.github.io/rust-clippy/master/index.html).

For example, as of 2025-06-01, there are 784 non-deprecated lints which
are referred to as "over 750 lints" in the documentation, but the web
site displays "Total number: 799". When one new lint will be added,
there will be a discrepancy ("over 750 lints" vs. "Total number: 800")
if this is not fixed.

changelog: none

r? @llogiq
I find it much easier to think about in the positive sense.
…st-lang#14954)

Closes rust-lang/rust-clippy#14926

changelog: [`semicolon_outside_block`] fix wrong suggestions when inside
macros
`clippy_lints::casts::utils::int_ty_to_nbits` used to return `0` to
indicate that the argument was not an integral type. It is more
idiomatic to use `Option<u64>` as a return type.
Looks for `TryFrom` implementations with uninhabited error types and
suggests to implement `From` instead.

Fixes rust-lang/rust-clippy#2144

---

changelog: Add [`infallible_try_from`] lint
samueltardieu and others added 8 commits June 12, 2025 23:21
Closes rust-lang/rust-clippy#14857

changelog: [`unit_arg`] fix wrong suggestion for `Default::default`
Fixes: rust-lang/rust-clippy#14931

changelog: Fix [`manual_swap`]'s suggestion-causes-error when the
variable is mutable or as loop variable.
So this is funny, the query `tcx.module_children` was top 3 in most
time consuming functions in Clippy, it was being called 24384 times in
tokio. "Unacceptable!" I thought. Digging a bit around, turns out that
`clippy::strlen_on_c_strings` was calling for `get_def_path` via
`match_libc_symbol`. This query pretty-prints things and performs some
analysis.

Yes, we were running early lint checks to see if symbols were from `libc`.
I don't really trust callgrind when it says I've turn 81 billion instructions
into like 10 million. So I benchmarked this the good ol' "compiling 20 times
without incr" method and it went from 0.31s-0.45s to 0.25s constistently.

(Profiled, and "benchmarked") on tokio.
So this is funny, the query `tcx.module_children` was top 3 in most
time consuming functions in Clippy, it was being called 24384 times in
tokio. "Unacceptable!" I thought. Digging a bit around, turns out that
`clippy::strlen_on_c_strings` was calling for `get_def_path` via
`match_libc_symbol`. This query pretty-prints things and performs some
analysis.

Yes, we were running early lint checks to see if symbols were from
`libc`.
I don't really trust callgrind when it says I've turn 81 billion
instructions
into like 10 million. So I benchmarked this the good ol' "compiling 20
times
without incr" method and it went from 0.31s-0.45s to 0.25s
constistently.

(Profiled, and "benchmarked") on tokio.

What I can get behind is via `strlen_on_c_strings` changing from 31
million instructions into 76k. 🎉 🥳

changelog: [`strlen_on_c_strings`]: Optimize it by 99.75%
r? @ghost

changelog: none
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 13, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jun 13, 2025

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

@rustbot
Copy link
Collaborator

rustbot commented Jun 13, 2025

⚠️ Warning ⚠️

@rust-log-analyzer

This comment has been minimized.

@flip1995
Copy link
Member Author

We're running clippy on bootstrap now 👀 that's good news. Now I have to figure out how to do that locally.

@matthiaskrgr
Copy link
Member

maybe ./x.py clippy --stage 1 src/bootstrap

@flip1995
Copy link
Member Author

That's a FP: rust-lang/rust-clippy#15045

I moved the lint to nursery, as I think this is significant and a lot of people will encounter this.

@flip1995
Copy link
Member Author

maybe ./x.py clippy --stage 1 src/bootstrap

Thanks! That's it. As I have profile = "tools" in my bootstrap.toml for Clippy syncs, I left out the --stage 1 flag.

@Manishearth
Copy link
Member

@bors r+ p=2 rollup=never

@bors
Copy link
Collaborator

bors commented Jun 13, 2025

📌 Commit 9cb0a64 has been approved by Manishearth

It is now in the queue for this repository.

@bors bors 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 Jun 13, 2025
@bors
Copy link
Collaborator

bors commented Jun 13, 2025

⌛ Testing commit 9cb0a64 with merge 0d6ab20...

@bors
Copy link
Collaborator

bors commented Jun 13, 2025

☀️ Test successful - checks-actions
Approved by: Manishearth
Pushing 0d6ab20 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jun 13, 2025
@bors bors merged commit 0d6ab20 into rust-lang:master Jun 13, 2025
11 checks passed
@rustbot rustbot added this to the 1.89.0 milestone Jun 13, 2025
Copy link
Contributor

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 c359117 (parent) -> 0d6ab20 (this PR)

Test differences

No test diffs found

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard 0d6ab209c525e276cbe7544cbd39a3c3619b6b18 --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. aarch64-apple: 6099.5s -> 4854.6s (-20.4%)
  2. x86_64-apple-2: 5492.1s -> 4441.9s (-19.1%)
  3. dist-apple-various: 6030.1s -> 7103.0s (17.8%)
  4. x86_64-apple-1: 7083.2s -> 8260.5s (16.6%)
  5. dist-x86_64-apple: 8252.3s -> 9531.4s (15.5%)
  6. x86_64-rust-for-linux: 2935.5s -> 2547.4s (-13.2%)
  7. i686-gnu-2: 6077.6s -> 5327.8s (-12.3%)
  8. mingw-check-1: 1892.0s -> 1680.7s (-11.2%)
  9. i686-gnu-nopt-1: 7988.3s -> 7120.0s (-10.9%)
  10. x86_64-gnu-llvm-19-1: 3674.9s -> 3318.5s (-9.7%)
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
Collaborator

Finished benchmarking commit (0d6ab20): comparison URL.

Overall result: ❌ regressions - 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.2% [0.2%, 0.2%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (secondary -0.1%)

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)
2.3% [2.3%, 2.3%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.4% [-2.4%, -2.4%] 1
All ❌✅ (primary) - - 0

Cycles

Results (secondary -1.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)
3.1% [3.1%, 3.1%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-5.7% [-5.7%, -5.7%] 1
All ❌✅ (primary) - - 0

Binary size

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

Bootstrap: 755.253s -> 755.964s (0.09%)
Artifact size: 372.23 MiB -> 372.26 MiB (0.01%)

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. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.