Skip to content

Clippy subtree update #139983

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

Open
wants to merge 307 commits into
base: master
Choose a base branch
from
Open

Conversation

flip1995
Copy link
Member

r? @Manishearth

Cargo.lock update due to the Clippy version bump and because Clippy moved from rinja (unmaintained) to askama.

Last sync was skipped due to the askama issue and me not getting to fixing this in time.

flip1995 and others added 30 commits March 22, 2025 13:32
Fix missing comment annotations in the clippy book

changelog: none
Replace the use of `Sugg::ast()` which prevented combining `if`
together when they contained comments by span manipulation.

A new configuration option `lint_commented_code`, which is `true` by
default, opts out from this behavior.
…4438)

rust-lang#2597 appears to be already resolved, so the applicability of `op_ref`
can be set to `MachineApplicable`.

close rust-lang#2597

changelog: [`op_ref`]: set the applicability to `MachineApplicable`
Related to rust-lang#14265 which was fixed automatically by the latest rustup.

changelog: none

*Edit: description, changelog, keep only tests*
Closes rust-lang#13066 (tests that are ignored with no reason message).

changelog: Add `ignore_without_reason` lint
In rust-lang#14116 we added a benchmarking option for Lintcheck, this commit adds
a new chapter to the book AND improves that option into a more usable
state.

It's recommended to review one commit at a time.

- **Document how to benchmark with lintcheck --perf**
- **Several improvements on lintcheck perf (desc.)**

    - Now lintcheck perf deletes target directory after benchmarking,
benchmarking with a cache isn't very useful or telling of any
precise outcome.

    - Support for benchmarking several times without having to do
a cargo clean.

    - Compress perf.data

changelog: none
Replace the use of `Sugg::ast()` which prevented combining `if` together
when they contained comments by span manipulation.

A new configuration option `lint_commented_code`, which is `true` by
default, allows opting out from this behavior.

If reviewed on GitHub, the second commit of this PR is best looked at
side by side, with whitespace differences turned off.

changelog: [`collapsible_if`]: lint more cases
…#14424)

Closes rust-lang#14404

changelog: [`nonminimal_bool`]: fix macro definition wrongly showed in
suggestions.
In the current GitHub Actions CI/CD setup, the `deploy` job is not
triggered when a PR is enqueued in the merge queue but only when it is
merged. Since concurrency is not configured for this job, deployments
may fail for later PRs if multiple PRs are merged in quick succession.
(e.g. the deployment for [this
commit](rust-lang/rust-clippy@c418714)
was successful, but the deployment for [this
commit](rust-lang/rust-clippy@0a141ab)
that was pushed to `main` immediately afterward failed. (edit: the
latter deployment seems to be rerun))

changelog: none

r? flip1995
Clarify example for unconditional_recursion

changelog: none
"paren" is used throughout the Clippy codebase as an abbreviation for
"parentheses".
`warn_on_all_wildcard_imports` should warn on all wildcard imports,
including the reexported ones.
`warn_on_all_wildcard_imports` should warn on all wildcard imports,
including the reexported ones.

Fix rust-lang#13660

changelog: [`warn_on_all_wildcard_imports`]: when asked to warn on all
wildcard imports, include the reexported ones
samueltardieu and others added 18 commits April 16, 2025 23:35
Instead of looking for angle brackets in the source code, use the HIR
and Ty interfaces to either copy the original type, or complete it with
`_` placeholders if all type and const generic arguments are inferred.

Fixes rust-lang/rust-clippy#14581

changelog: [`from_iter_instead_of_collect`]: show correct type in
suggestion
- Do not replace macro results in then/else branches
- Extract condition snippet from the right context
- Make suggestion `MaybeIncorrect` if it would lead to losing comments

changelog: [`bool_to_int_with_if`]: properly handle macros

Fixes rust-lang/rust-clippy#14628
This will let people [add summary
notes](https://forge.rust-lang.org/triagebot/note.html) to an issue, for
example to add that an issue is best kept for first-timers.

changelog: none

I wanted to use it in
rust-lang/rust-clippy#14617 (comment).
Limit the recursion depth, as each level of nesting adds another deeper
projection.
)

Limit the recursion depth, as each level of nesting adds another deeper
projection.

There might be a more complex way of handling the problem, but infinite
recursions are bad, and don't allow Clippy to terminate properly.

changelog: [`significant_drop_tightening`]: do not recurse forever when
checking for attribute on type or its constituent

Fixes rust-lang/rust-clippy#13544

@rustbot label +L-nursery
This lint detects inefficient or useless `{std,core}::mem::swap()` calls
such as:

```rust
    // Should be `a = temp();`
    swap(&mut a, &mut temp());
    // Should be `*b = temp();`
    swap(b, &mut temp());
    // Should be `temp1(); temp2();` if we want to keep the side effects
    swap(&mut temp1(), &mut temp2());
```

It also takes care of using a form appropriate for a `()` context if
`swap()` is part of a larger expression (don't ask me why this wouldn't
happen, I have no idea), by suggesting `{ x = y; }` (statement in block)
or `{std,core}::mem::drop((temp1(), temp2())`.

changelog: [`swap_with_temporary`]: new lint

Close rust-lang#1968
rust-lang#14644)

Closes rust-lang/rust-clippy#14578

changelog: [`unnecessary_lazy_evaluations`] fix wrong suggestions for
async closure
…lang#14635)

changelog: [`match_single_binding`]: allow macros in scrutinee and
patterns

Fixes rust-lang/rust-clippy#14634
The `BodyLifetimeChecker` which checks for the use of any non-anonymous
non-static lifetime did not recurse into closures, missing lifetime
uses. This would lead to a bogus elision suggestion.

The `BodyLifetimeChecker` is not refined enough to avoid false
positives, as any conforming lifetime, including one coming from the
outer context, would be considered a hit. The number of false positives
might increase now that we check closures as well, in case those
closures define and use lifetimes themselves.

changelog: [`needless_lifetimes`]: do not suggest removing a lifetime
which is later used in a closure

Fixes rust-lang/rust-clippy#14607
r? @ghost

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

rustbot commented Apr 17, 2025

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

These commits modify the Cargo.lock file. Unintentional changes to Cargo.lock can be introduced when switching branches and rebasing PRs.

If this was unintentional then you should revert the changes before this PR is merged.
Otherwise, you can ignore this comment.

@Manishearth
Copy link
Member

@bors r+ p=2 rollup=never

@bors
Copy link
Collaborator

bors commented Apr 17, 2025

📌 Commit b10e7f7 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 Apr 17, 2025
@rust-log-analyzer
Copy link
Collaborator

The job mingw-check-tidy failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
info: removing rustup binaries
info: rustup is uninstalled
##[group]Image checksum input
mingw-check-tidy
# We use the ghcr base image because ghcr doesn't have a rate limit
# and the mingw-check-tidy job doesn't cache docker images in CI.
FROM ghcr.io/rust-lang/ubuntu:22.04

ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
  g++ \
  make \
---

COPY host-x86_64/mingw-check/validate-toolstate.sh /scripts/
COPY host-x86_64/mingw-check/validate-error-codes.sh /scripts/

# NOTE: intentionally uses python2 for x.py so we can test it still works.
# validate-toolstate only runs in our CI, so it's ok for it to only support python3.
ENV SCRIPT TIDY_PRINT_DIFF=1 python2.7 ../x.py test \
           --stage 0 src/tools/tidy tidyselftest --extra-checks=py,cpp
#
# This file is autogenerated by pip-compile with Python 3.10
# by the following command:
#
#    pip-compile --allow-unsafe --generate-hashes reuse-requirements.in
---
#12 2.915 Building wheels for collected packages: reuse
#12 2.916   Building wheel for reuse (pyproject.toml): started
#12 3.128   Building wheel for reuse (pyproject.toml): finished with status 'done'
#12 3.129   Created wheel for reuse: filename=reuse-4.0.3-cp310-cp310-manylinux_2_35_x86_64.whl size=132719 sha256=5bb60f62728aaedff7162745ce743c7f2f55069b3e7f82e6a37d70df455797cc
#12 3.130   Stored in directory: /tmp/pip-ephem-wheel-cache-k7pc_7wx/wheels/3d/8d/0a/e0fc6aba4494b28a967ab5eaf951c121d9c677958714e34532
#12 3.132 Successfully built reuse
#12 3.133 Installing collected packages: boolean-py, binaryornot, tomlkit, reuse, python-debian, markupsafe, license-expression, jinja2, chardet, attrs
#12 3.527 Successfully installed attrs-23.2.0 binaryornot-0.4.4 boolean-py-4.0 chardet-5.2.0 jinja2-3.1.4 license-expression-30.3.0 markupsafe-2.1.5 python-debian-0.1.49 reuse-4.0.3 tomlkit-0.13.0
#12 3.528 WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
#12 4.063 Collecting virtualenv
#12 4.104   Downloading virtualenv-20.30.0-py3-none-any.whl (4.3 MB)
#12 4.212      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 4.3/4.3 MB 41.2 MB/s eta 0:00:00
#12 4.267 Collecting platformdirs<5,>=3.9.1
#12 4.271   Downloading platformdirs-4.3.7-py3-none-any.whl (18 kB)
#12 4.290 Collecting distlib<1,>=0.3.7
#12 4.294   Downloading distlib-0.3.9-py2.py3-none-any.whl (468 kB)
#12 4.303      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 469.0/469.0 KB 63.8 MB/s eta 0:00:00
#12 4.338 Collecting filelock<4,>=3.12.2
#12 4.344   Downloading filelock-3.18.0-py3-none-any.whl (16 kB)
#12 4.426 Installing collected packages: distlib, platformdirs, filelock, virtualenv
#12 4.608 Successfully installed distlib-0.3.9 filelock-3.18.0 platformdirs-4.3.7 virtualenv-20.30.0
#12 4.608 WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
#12 DONE 4.7s

#13 [7/8] COPY host-x86_64/mingw-check/validate-toolstate.sh /scripts/
#13 DONE 0.0s
---
DirectMap4k:      131008 kB
DirectMap2M:     8257536 kB
DirectMap1G:    10485760 kB
##[endgroup]
Executing TIDY_PRINT_DIFF=1 python2.7 ../x.py test            --stage 0 src/tools/tidy tidyselftest --extra-checks=py,cpp
+ TIDY_PRINT_DIFF=1 python2.7 ../x.py test --stage 0 src/tools/tidy tidyselftest --extra-checks=py,cpp
##[group]Building bootstrap
    Finished `dev` profile [unoptimized] target(s) in 0.05s
##[endgroup]
WARN: currently no CI rustc builds have rustc debug assertions enabled. Please either set `rust.debug-assertions` to `false` if you want to use download CI rustc or set `rust.download-rustc` to `false`.
[TIMING] core::build_steps::tool::LibcxxVersionTool { target: x86_64-unknown-linux-gnu } -- 0.212
---
[TIMING] core::build_steps::tool::Tidy { compiler: Compiler { stage: 0, host: x86_64-unknown-linux-gnu, forced_compiler: false }, target: x86_64-unknown-linux-gnu } -- 0.000
fmt check
fmt: checked 5970 files
tidy check
Run `./x.py test tidy --bless` to regenerate the list
tidy error: `rinja_parser` is registered in `src/bootstrap/src/utils/proc_macro_deps.rs`, but is not a proc-macro crate dependency
tidy error: `mime_guess` is registered in `src/bootstrap/src/utils/proc_macro_deps.rs`, but is not a proc-macro crate dependency
tidy error: `mime` is registered in `src/bootstrap/src/utils/proc_macro_deps.rs`, but is not a proc-macro crate dependency
tidy error: `unicase` is registered in `src/bootstrap/src/utils/proc_macro_deps.rs`, but is not a proc-macro crate dependency
tidy: Skipping binary file check, read-only filesystem
removing old virtual environment
creating virtual environment at '/checkout/obj/build/venv' using 'python3.10' and 'venv'
creating virtual environment at '/checkout/obj/build/venv' using 'python3.10' and 'virtualenv'
Requirement already satisfied: pip in ./build/venv/lib/python3.10/site-packages (25.0.1)
linting python files
All checks passed!
checking python file formatting
26 files already formatted
checking C++ file formatting
some tidy checks failed
Command has failed. Rerun with -v to see more details.
Build completed unsuccessfully in 0:01:44
  local time: Thu Apr 17 17:07:38 UTC 2025
  network time: Thu, 17 Apr 2025 17:07:38 GMT
##[error]Process completed with exit code 1.
Post job cleanup.

@jieyouxu
Copy link
Member

jieyouxu commented Apr 17, 2025

Tidy issues @bors r-

2025-04-17T17:07:15.6558227Z tidy error: `rinja_parser` is registered in `src/bootstrap/src/utils/proc_macro_deps.rs`, but is not a proc-macro crate dependency
2025-04-17T17:07:15.6560883Z tidy error: `mime_guess` is registered in `src/bootstrap/src/utils/proc_macro_deps.rs`, but is not a proc-macro crate dependency
2025-04-17T17:07:15.6562417Z tidy error: `mime` is registered in `src/bootstrap/src/utils/proc_macro_deps.rs`, but is not a proc-macro crate dependency
2025-04-17T17:07:15.6563934Z tidy error: `unicase` is registered in `src/bootstrap/src/utils/proc_macro_deps.rs`, but is not a proc-macro crate dependency

Maybe need to rebless with ./x.py test tidy --bless?

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Apr 17, 2025
@bors
Copy link
Collaborator

bors commented Apr 18, 2025

☔ The latest upstream changes (presumably #139996) made this pull request unmergeable. Please resolve the merge conflicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author.
Projects
None yet
Development

Successfully merging this pull request may close these issues.