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

[beta] Clippy backports #129618

Merged
merged 3 commits into from
Aug 28, 2024
Merged

[beta] Clippy backports #129618

merged 3 commits into from
Aug 28, 2024

Conversation

Jarcho
Copy link
Contributor

@Jarcho Jarcho commented Aug 26, 2024

r? @Mark-Simulacrum

Backports:

Both 12892 and 13290 are fixes for stable regressions. The first is a little large, but mostly just reverts the change that caused the regression. 13168 is to handle the Error trait moving to core in 1.81.

bors added 3 commits August 26, 2024 11:33
… r=xFrednet

needless_borrows_for_generic_args: Fix for &mut

This commit fixes a bug introduced in rust-lang#12706, where the behavior of the lint has been changed, to avoid suggestions that introduce a move. The motivation in the commit message is quite poor (if the detection for significant drops is not sufficient because it's not transitive, the proper fix would be to make it transitive). However, rust-lang#12454, the linked issue, provides a good reason for the change — if the value being borrowed is bound to a variable, then moving it will only introduce friction into future refactorings.

Thus rust-lang#12706 changes the logic so that the lint triggers if the value being borrowed is Copy, or is the result of a function call, simplifying the logic to the point where analysing "is this the only use of this value" isn't necessary.

However, said PR also introduces an undocumented carveout, where referents that themselves are mutable references are treated as Copy, to catch some cases that we do want to lint against. However, that is not sound — it's possible to consume a mutable reference by moving it.

To avoid emitting false suggestions, this PR reintroduces the referent_used_exactly_once logic and runs that check for referents that are themselves mutable references.

Thinking about the code shape of &mut x, where x: &mut T, raises the point that while removing the &mut outright won't work, the extra indirection is still undesirable, and perhaps instead we should suggest reborrowing: &mut *x. That, however, is left as possible future work.

Fixes rust-lang#12856

changelog: none
…=Manishearth

Make `std_instead_of_core` somewhat MSRV aware

For rust-lang#13158, this catches some things e.g. `core::net` and the recently stable `core::error` but not things moved individually like `UnwindSafe`, as far as I can see the version for those isn't easily available

Beta nominating since ideally we'd get this change in the same version as `core::error` becomes stable

cc `@kpreid`

changelog: none
`declare_interior_mutable_const`: Ignore pointer types.

fixes rust-lang#12951
fixes rust-lang#13233

changelog: `declare_interior_mutable_const`: Ignore pointer types.
@rustbot
Copy link
Collaborator

rustbot commented Aug 26, 2024

⚠️ Warning ⚠️

  • Pull requests are usually filed against the master branch for this repo, but this one is against beta. Please double check that you specified the right target!

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 26, 2024
@rustbot
Copy link
Collaborator

rustbot commented Aug 26, 2024

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

@Mark-Simulacrum
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Aug 26, 2024

📌 Commit 1f4f9d8 has been approved by Mark-Simulacrum

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 Aug 26, 2024
@Mark-Simulacrum
Copy link
Member

@bora rollup=never

@Jarcho
Copy link
Contributor Author

Jarcho commented Aug 26, 2024

I think you typoed that.

@Mark-Simulacrum
Copy link
Member

@bors rollup=never

Indeed.

@bors
Copy link
Contributor

bors commented Aug 28, 2024

⌛ Testing commit 1f4f9d8 with merge 4a765c0...

@bors
Copy link
Contributor

bors commented Aug 28, 2024

☀️ Test successful - checks-actions
Approved by: Mark-Simulacrum
Pushing 4a765c0 to beta...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Aug 28, 2024
@bors bors merged commit 4a765c0 into rust-lang:beta Aug 28, 2024
7 checks passed
@rustbot rustbot added this to the 1.81.0 milestone Aug 28, 2024
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.

4 participants