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
|
@Kivooeo Hi, sorry for the ping, it's been another 2 weeks. Is there a chance you could have another look? I have addressed the nits |
|
I'll review today-tomorrow |
|
Got very busy today, will review tomorrow 100%, sorry for a delay |
Ok thanks so much, I appreciate you! |
|
@Kivooeo I addressed the comment concerns |
|
@bors r+ rollup |
…erns, r=Kivooeo Fix unused_parens for pinned reference patterns 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 `mut` binding. That was too conservative for pinned reference patterns such as `&pin const (mut x)`. The `pin const` part belongs to the outer reference pattern, so removing the inner parentheses still leaves `mut x` as the subpattern. This updates the ambiguity check so the leading-`mut` suppression 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 `mut` bindings to all binding modes whose binding mutability is `Mutability::Mut`, covering forms such as `mut ref pin const`. @rustbot label F-pin_ergonomics
…erns, r=Kivooeo Fix unused_parens for pinned reference patterns 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 `mut` binding. That was too conservative for pinned reference patterns such as `&pin const (mut x)`. The `pin const` part belongs to the outer reference pattern, so removing the inner parentheses still leaves `mut x` as the subpattern. This updates the ambiguity check so the leading-`mut` suppression 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 `mut` bindings to all binding modes whose binding mutability is `Mutability::Mut`, covering forms such as `mut ref pin const`. @rustbot label F-pin_ergonomics
…uwer Rollup of 15 pull requests Successful merges: - #155763 (Promotes 5 Thumb-mode bare-metal Arm targets to Tier 2) - #156953 (delegation: emit error when there is an infer lifetime in user-specified args) - #157248 (delegation: move statements out of the first arg) - #157263 (rustc_codegen_ssa: Refactor `ArchiveEntry` to include entry kind) - #157311 (Use weak linkage for EII defaults) - #156089 (Fix unused_parens for pinned reference patterns) - #156928 (Remove -Zemscripten-wasm-eh) - #157236 (Reorganize `tests/ui/issues` [3/N]) - #157287 (Const generics: remove AliasTerm::kind(), and small fixes) - #157294 (Split coroutine layout computation to its own file) - #157328 (windows: Elide division-by-zero checks in Instant::now()) - #157331 (Rewrite target checking for `#[link]`) - #157336 (Enable `clippy::mem_replace_with_default`) - #157362 (Fix trivial wf module argument/doc comment name mismatches) - #157364 (Rewrite target checking of `rustc_dummy`) Failed merges: - #157332 (Rewrite target checking for `#[sanitize]`)
Rollup merge of #156089 - P8L1:fix-unused-parens-pinned-patterns, r=Kivooeo Fix unused_parens for pinned reference patterns 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 `mut` binding. That was too conservative for pinned reference patterns such as `&pin const (mut x)`. The `pin const` part belongs to the outer reference pattern, so removing the inner parentheses still leaves `mut x` as the subpattern. This updates the ambiguity check so the leading-`mut` suppression 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 `mut` bindings to all binding modes whose binding mutability is `Mutability::Mut`, covering forms such as `mut ref pin const`. @rustbot label F-pin_ergonomics
View all comments
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.@rustbot label F-pin_ergonomics