Skip to content
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

Clippy subtree update #131205

Merged
merged 55 commits into from
Oct 3, 2024
Merged

Clippy subtree update #131205

merged 55 commits into from
Oct 3, 2024

Conversation

flip1995
Copy link
Member

@flip1995 flip1995 commented Oct 3, 2024

vHugoObject and others added 30 commits September 18, 2024 06:10
…riggers false positive

chore: Moved new tests into needless_return.rs

chore: Ran cargo uibless

Initial commit
…1995

Update actions/setup-node to v4

changelog: none

Required for using Node.js 20.x in CI
* Changelog for actions/checkout@v4 https://github.com/actions/checkout/blob/main/CHANGELOG.md?rgh-link-date=2024-09-04T18%3A38%3A10Z#v400
* GitHub Blog post https://github.blog/changelog/2024-03-07-github-actions-all-actions-will-run-on-node20-instead-of-node16-by-default/

Example warning: https://github.com/rust-lang/rust-clippy/actions/runs/11003847751
> The following actions use a deprecated Node.js version and will be forced to run on node20: actions/setup-node@v3.
Replace hand-crafted tests by the a call to the `std_or_core()` utility
function.
`invalid_null_ptr_usage`: fix false positives for `std::ptr::slice_from_raw_parts` functions

fixes rust-lang#13445
changelog: [`invalid_null_ptr_usage`]: fix false positives for `std::ptr::slice_from_raw_parts` functions
Separate collection of crate-local inherent impls from error tracking

rust-lang#119895 changed the return type of the `crate_inherent_impls` query from `CrateInherentImpls` to `Result<CrateInherentImpls, ErrorGuaranteed>` to avoid needing to use the non-parallel-friendly `track_errors()` to track if an error was reporting from within the query... This was mostly fine until rust-lang#121113, which stopped halting compilation when we hit an `Err(ErrorGuaranteed)` in the `crate_inherent_impls` query.

Thus we proceed onwards to typeck, and since a return type of `Result<CrateInherentImpls, ErrorGuaranteed>` means that the query can *either* return one of "the list inherent impls" or "error has been reported", later on when we want to assemble method or associated item candidates for inherent impls, we were just treating any `Err(ErrorGuaranteed)` return value as if Rust had no inherent impls defined anywhere at all! This leads to basically every inherent method call failing with an error, lol, which was reported in rust-lang#127798.

This PR changes the `crate_inherent_impls` query to return `(CrateInherentImpls, Result<(), ErrorGuaranteed>)`, i.e. returning the inherent impls collected *and* whether an error was reported in the query itself. It firewalls the latter part of that query into a new `crate_inherent_impls_validity_check` just for the `ensure()` call.

This fixes rust-lang#127798.
Add reasons for or remove some `//@no-rustfix` annotations

changelog: none
Use std_or_core to determine the correct prefix

This is a cleanup commit. It replaces hand-crafted tests by the a call to the `std_or_core()` utility function.

changelog: none
…nishearth

Clippy subtree update

r? `@Manishearth`

Really delayed sync (2 1/2 weeks), because of a `debug_assertion` we hit, and I didn't have the time to investigate earlier.

It would be nice to merge this PR with some priority, as it includes a lot of formatting changes due to the rustfmt bump.

Include Cargo.lock update due to Clippy version bump and ui_test bump in Clippy.
fix: Specifying reason in expect(clippy::needless_return) no longer triggers false positive

fixes rust-lang#13366
changelog: none
…triggered for types annotated with #[nonexhaustive]
fix(clippy_lints/matches): wildcard_in_or_patterns will no longer be triggered for types annotated with #[nonexhaustive]

fixes rust-lang#13350

----

changelog: none
…ttern

Instead of

```
error[E0277]: the size for values of type `(dyn ThriftService<(), AssocType = _> + 'static)` cannot be known at compilation time
  --> $DIR/issue-59324.rs:23:20
   |
LL | fn with_factory<H>(factory: dyn ThriftService<()>) {}
   |                    ^^^^^^^ doesn't have a size known at compile-time
```

output

```
error[E0277]: the size for values of type `(dyn ThriftService<(), AssocType = _> + 'static)` cannot be known at compilation time
  --> $DIR/issue-59324.rs:23:29
   |
LL | fn with_factory<H>(factory: dyn ThriftService<()>) {}
   |                             ^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
```
nyurik and others added 15 commits September 28, 2024 19:51
Convert `&Option<T>` to `Option<&T>`

Run `ref_option` (rust-lang#13336) on the Clippy's own code, quiet a few hits. Per mentioned video, this may actually improve performance as well.  Switch lint to `pedantic`

----

changelog: [`ref_option`]: upgrade lint to `pedantic`
…lexendoo

Extend `needless_lifetimes` to suggest eliding `impl` lifetimes

Example:
```
error: the following explicit lifetimes could be elided: 'a
  --> tests/ui/needless_lifetimes.rs:332:10
   |
LL |     impl<'a> Foo for Baz<'a> {}
   |          ^^              ^^
   |
help: elide the lifetimes
   |
LL -     impl<'a> Foo for Baz<'a> {}
LL +     impl Foo for Baz<'_> {}
```
The main change is in how `impl` lifetime uses are tracked. Previously, a hashmap was created, and lifetimes were removed from the hashmap as their uses were discovered. However, the uses are needed to generate elision suggestions. So, now, uses are added to the hashmap as they are discovered.

The PR is currently organized as six commits, which I think are self-explanatory:
- Extend `needless_lifetimes` to suggest eliding `impl` lifetimes
- Reorder functions _[not strictly necessary, but IMHO, the code is better structured as a result]_
- Fix lifetime tests
- Fix non-lifetime tests
- Fix `clippy_lints` and `clippy_utils`
- Fix typo in `needless_lifetimes` test

r? `@Alexendoo` (I think you are `needless_lifetimes`' primary author? Sorry if I have this wrong.)

---

changelog: Extend `needless_lifetimes` to suggest eliding `impl` lifetimes
`zombie_processes`: consider `wait()` calls in nested bodies

Fixes rust-lang#13459

Small oversight. We weren't considering uses of the local in closures.

changelog: none
When there is are multiple references where one of the references
isn't mutable then this results in a false-positive for
`mut_mutex_lock` as it only checks the mutability of the first
reference level.

Fix this by using `peel_mid_ty_refs_is_mutable` which correctly
determines whether the reference is ultimately mutable and thus
whether `Mutex::get_lock()` can actually be used.

Fixes rust-lang#9854
Fix `mut_mutex_lock` when reference not ultimately mutable

When there is are multiple references where one of the references isn't mutable then this results in a false-positive for `mut_mutex_lock` as it only checks the mutability of the first reference level.

Fix this by using `peel_mid_ty_refs_is_mutable` which correctly determines whether the reference is ultimately mutable and thus whether `Mutex::get_lock()` can actually be used.

Fixes rust-lang#9854

changelog: [`mut_mutex_lock`]: No longer lints if the mutex is behind multiple references and one of those references isn't mutable
…, r=xFrednet

Simplify negative `Option::{is_some_and,is_none_or}`

Closes rust-lang#13436.

Improved based on the existing lint `nonminimal_bool`, since there is already handling of similar methods `Option::{is_some,is_none}` and `Result::{is_ok,is_err}`, and there is a lot of reusable code.

When `is_some_and` or `is_none_or` have a negation, we invert it into another method by removing the Not sign and inverting the expression in the closure.

For the case where the closure block has statements, currently no simplification is implemented. (Should we do it?)

```rust
// Currently will not simplify this
_ = !opt.is_some_and(|x| {
    let complex_block = 100;
    x == complex_block
});
```

changelog: [`nonminimal_bool`]: Simplify negative `Option::{is_some_and,is_none_or}`
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 3, 2024
@rustbot
Copy link
Collaborator

rustbot commented Oct 3, 2024

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

@Manishearth
Copy link
Member

@bors r+ p=1 rollup=never

@bors
Copy link
Contributor

bors commented Oct 3, 2024

📌 Commit b823547 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 Oct 3, 2024
@bors
Copy link
Contributor

bors commented Oct 3, 2024

⌛ Testing commit b823547 with merge 56e35a5...

@bors
Copy link
Contributor

bors commented Oct 3, 2024

☀️ Test successful - checks-actions
Approved by: Manishearth
Pushing 56e35a5 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Oct 3, 2024
@bors bors merged commit 56e35a5 into rust-lang:master Oct 3, 2024
7 checks passed
@rustbot rustbot added this to the 1.83.0 milestone Oct 3, 2024
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (56e35a5): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

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

Max RSS (memory usage)

Results (primary 1.1%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
4.5% [4.5%, 4.5%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-2.2% [-2.2%, -2.2%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 1.1% [-2.2%, 4.5%] 2

Cycles

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

Binary size

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

Bootstrap: 773.547s -> 772.786s (-0.10%)
Artifact size: 342.00 MiB -> 342.00 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. 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.