Fix unused_parens for pinned reference patterns#156089
Conversation
|
r? @nnethercote rustbot has assigned @nnethercote. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
same as here: #156087 (comment) @rustbot author |
|
Reminder, once the PR becomes ready for a review, use |
I gated the pinned-pattern unused-parens rustfix path on |
|
@rustbot ready Addressed the review feedback by gating the pinned-pattern unused_parens rustfix path on I also added a FIXME next to the gate saying to remove it once |
|
r? @Kivooeo |
|
@Kivooeo Please review this as well |
|
it's been only two days since it's open, review may take up to two weeks since i'm pretty busy with other stuff i'd ask you to wait, because it may take a little longer |
|
Hey @Kivooeo, just wanted to gently bump this since it’s been about two weeks. I think I’ve addressed the previous feedback, but please let me know if there’s anything else you’d like changed. Thanks! |
This comment has been minimized.
This comment has been minimized.
696ca4a to
582523b
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
@Kivooeo ready |
582523b to
ffe1dba
Compare
The unused_parens lint previously treated pinned shared-reference patterns like plain shared-reference patterns when deciding whether removing parentheses could change the meaning of a leading
mutbinding.That was too conservative for pinned reference patterns such as
&pin const (mut x). Thepin constpart belongs to the outer reference pattern, so removing the inner parentheses still leavesmut xas the subpattern.This updates the ambiguity check so the leading-
mutsuppression only applies to plain shared reference patterns. Pinned reference patterns can now receive correct rustfix suggestions.The patch also broadens the binding check from only plain
mutbindings to all binding modes whose binding mutability isMutability::Mut, covering forms such asmut ref pin const.Tests cover:
&pin const (...)&pin mut (...)mut _x @ _ref pin const/ref pin mutmut ref pin const/mut ref pin mut&(mut ...)cases remaining suppressed