Skip to content

Clippy subtree update #141044

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 121 commits into
base: master
Choose a base branch
from
Open

Conversation

flip1995
Copy link
Member

r? @Manishearth

Cargo.lock update due to Clippy version bump.

GuillaumeGomez and others added 30 commits April 17, 2025 16:31
The lint becomes part of stable in 1.87, not in 1.84
Supersedes rust-lang/rust-clippy#12550

`layout_of` no longer contains a `delay_bug` so there's no need for this
anymore.

changelog: None
I'm working on rust-lang/rust-clippy#14542 and
I decided to name the lint `unnecessary_map` originally. However when I
ran the command, I got:

```
thread 'main' panicked at clippy_dev/src/new_lint.rs:450:5:
Lint `unnecessary_map` already defined in `/home/imperio/rust/clippy/clippy_lints/src/methods/mod.rs`
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
```

It's because there is already a `unnecessary_map_or`, which matches the
`.contains()` call. This PR strengthens this check.

changelog: Fix `new_lint` clippy command

r? @flip1995
Closes rust-lang/rust-clippy#14685

changelog: [`manual_slice_fill`] fix FP on `IndexMut` overload
add allow_unused config to missing_docs_in_private_items for underscored field
Fixes
rust-lang/rust-clippy#14397 (comment)

r? @samueltardieu

changelog: Don't warn about clippy.toml disallowed paths for crates that
were not loaded
Closes rust-lang/rust-clippy#14704

changelog: [`unused_async`] fix FP on default impl
Simplifies the implementation a bit, also makes the message an error
annotation

changelog: none
Closes rust-lang/rust-clippy#14716

changelog: [`manual_unwrap_or_default`] fix FP on ref binding
The `&[&str]` path based `clippy_utils` have been removed and replace
with a new type `PathLookup`:

-
[`match_trait_method`](https://doc.rust-lang.org/nightly/nightly-rustc/clippy_utils/fn.match_trait_method.html)
-
[`match_qpath`](https://doc.rust-lang.org/nightly/nightly-rustc/clippy_utils/fn.match_qpath.html)
-
[`match_path`](https://doc.rust-lang.org/nightly/nightly-rustc/clippy_utils/fn.match_path.html)
-
[`match_any_def_paths`](https://doc.rust-lang.org/nightly/nightly-rustc/clippy_utils/fn.match_any_def_paths.html)
-
[`match_def_path`](https://doc.rust-lang.org/nightly/nightly-rustc/clippy_utils/fn.match_def_path.html)
-
[`match_type`](https://doc.rust-lang.org/nightly/nightly-rustc/clippy_utils/ty/fn.match_type.html)
-
[`get_trait_def_id`](https://doc.rust-lang.org/nightly/nightly-rustc/clippy_utils/fn.get_trait_def_id.html)

Internally `PathLookup` is a lazy call to `lookup_path` (the new name
for
[`def_path_res`](https://doc.rust-lang.org/nightly/nightly-rustc/clippy_utils/fn.def_path_res.html)
to distinguish it from
[`path_res`](https://doc.rust-lang.org/nightly/nightly-rustc/clippy_utils/fn.path_res.html))

The `invalid_paths` internal lint is removed, it could be reimplemented
but it feels redundant since every path should be covered by a test
anyway

### User facing changes

- `manual_saturating_arithmetic` now checks for `u32::MAX/MIN` instead
of only detecting the legacy numeric consts (`std::u32::MAX/MIN`),
`clippy::legacy_numeric_constants` will redirect usages of the legacy
versions to the new one

- `allow-invalid = true` now suppresses all invalid path warnings,
currently you can run into a warning that can't be ignored in some
situations, e.g. with `serde` without the `derive` feature

  ```
  warning: expected a macro, found a trait
   --> /home/gh-Alexendoo/temp/clippy.toml:2:5
    |
  2 |     { path = "serde::Serialize", allow-invalid = true },
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  ```

- Re-exports of primitives types like `std::primitive::*` no longer work
in `disallowed-types`, this seems acceptable since it would be unusual
to deny a primitive this way rather than writing e.g. `usize`. Type
aliases such as `c_char` are unaffected

- A similar slight performance improvement to
rust-lang/rust-clippy#14650
  ```bash
$ hyperfine -w 2 -p 'touch src/cargo/lib.rs' 'cargo +master clippy'
'cargo +lazy-paths clippy'
  ```
  ```
  Benchmark 1: cargo +master clippy
Time (mean ± σ): 6.829 s ± 0.064 s [User: 6.079 s, System: 0.673 s]
    Range (min … max):    6.705 s …  6.907 s    10 runs

  Benchmark 2: cargo +lazy-paths clippy
Time (mean ± σ): 6.765 s ± 0.064 s [User: 5.984 s, System: 0.698 s]
    Range (min … max):    6.636 s …  6.834 s    10 runs

  Summary
    cargo +lazy-paths clippy ran
      1.01 ± 0.01 times faster than cargo +master clippy
  ```

changelog: none
Jarcho and others added 18 commits May 12, 2025 17:07
remove merge

removed false positive and improved tests

clarify known problems for `cloned_ref_to_slice_refs`
Added lint for catching `&[foo.clone()]` where foo is a reference and
suggests `std::slice::from_ref(foo)`.

changelog: new lint: [`cloned_ref_to_slice_refs`]
)

Adds an internal lint to check for `#[derive(serde::Deserialize)]`
without
[`#[serde(deny_unknown_fields)]`](https://serde.rs/container-attrs.html#deny_unknown_fields).

Today, if you run Clippy with the following clippy.toml, Clippy will
produce a warning, but there will be no accompanying note:
```toml
# In the following configuration, "recommendation" should be "reason" or "replacement".
disallowed-macros = [
    { path = "std::panic", recommendation = "return a `std::result::Result::Error` instead" },
]
```
```sh
$ cargo clippy
    Checking a v0.1.0 (/home/smoelius/tmp/a)
warning: use of a disallowed macro `std::panic`
 --> src/lib.rs:2:5
  |
2 |     panic!();
  |     ^^^^^^^^
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_macros
  = note: `#[warn(clippy::disallowed_macros)]` on by default
```
The underlying problem is: the enum that derives `serde::Deserialize`
([`DisallowedPathEnum`](https://github.com/rust-lang/rust-clippy/blob/81643e297cf44ce3c7648b8443fc4d6592fa81eb/clippy_config/src/types.rs#L47))
does not have the attribute `#[serde(deny_unknown_fields)]`.

This lint identifies such problems by checking trait `impl`s. An
alternative I considered was to walk `clippy_config::conf::Conf`
directly. However, that would not catch the `DisallowedPathEnum` case
because it [is not used in `Conf`
directly](https://github.com/rust-lang/rust-clippy/blob/81643e297cf44ce3c7648b8443fc4d6592fa81eb/clippy_config/src/types.rs#L31).

Just to be clear, no one asked for this. So I hope the maintainers do
not mind.

changelog: none
…ang#14740)

When a `non_std_lazy_statics` warning is generated about an item type
which can be replaced by a standard library one, ensure that the lint
happens on the item HIR node so that it can be expected.

changelog: [`non_std_lazy_statics`]: generate the warning onto the right
node

Fixes rust-lang/rust-clippy#14729

Note that this doesn't change anything on lints generated for the
`lazy_static::lazy_static` macro because the `expect` attribute cannot
be applied to a macro.
…tions` lint (rust-lang#14261)

changelog: [`module_name_repetitions`]: new configuration option
`allow_exact_repetitions`, enabled by default

Closes rust-lang#14226
Based on rust-lang/rust-clippy#13223

Various refactoring on `clippy_dev` before upgrading rename and
splitting `clippy_lints` into multiple crates.

Some improvements:
* The working directory is set to the root clippy directory. Running
from a subdirectory was kind of supported before sometimes. Now it just
works.
* File won't be written unless they're actually updated. Most of the
time they weren't written, but a few cases slipped through.
* Buffers are reused more for the negligible speed boost.

changelog: None
r? @ghost

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

rustbot commented May 15, 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.

@rust-log-analyzer

This comment has been minimized.

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label May 15, 2025
@Manishearth
Copy link
Member

@bors r+ p=2 rollup=never

@bors
Copy link
Collaborator

bors commented May 16, 2025

📌 Commit 60750ca 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 May 16, 2025
@bors
Copy link
Collaborator

bors commented May 16, 2025

⌛ Testing commit 60750ca with merge 1b9efcd...

bors added a commit to rust-lang-ci/rust that referenced this pull request May 16, 2025
…nishearth

Clippy subtree update

r? `@Manishearth`

Cargo.lock update due to Clippy version bump.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.