Skip to content

Conversation

@robert-mccausland
Copy link

@robert-mccausland robert-mccausland commented Nov 17, 2025

Currently the sugg utility treats all ExprKind::Match expressions as potentially needing brackets, and therefore many lints will add parenthesis around them. However this includes desugared match expressions like the ? and .await operators.

In this PR I have updated the utility to only treat match expressions which include a code block as needing parenthesis, as the other types have similar precedence rules and expectations to things like member access and I think can be treated like as such.

While this change is small on paper it touches a large amount of code due to changing a cross cutting concern, I am happy to add additional tests if we think it is needed, but I wanted to get a feel for if this is even a sensible change to be doing and what the expectations were around the level of testing needed before investing more time into it.

Regarding not putting a specific lint in the changelog, determining all the lints this could possibly effect would be possible but take some time, and I wonder if it would be a bit too noisy in the changelog. Open to suggestions about how best to address that.

fixes #16045

changelog: stop inserting unnecessary brackets around x? and x.await expressions in suggestions

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Nov 17, 2025
@rustbot
Copy link
Collaborator

rustbot commented Nov 17, 2025

r? @Alexendoo

rustbot has assigned @Alexendoo.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@github-actions
Copy link

Lintcheck changes for 466646f

Lint Added Removed Changed
clippy::cast_sign_loss 0 0 2
clippy::if_then_some_else_none 0 0 1
clippy::option_if_let_else 0 0 7

This comment will be updated if you push new changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties

Projects

None yet

Development

Successfully merging this pull request may close these issues.

redundant_pattern_matching applies redundant parenthesis to expression with ?

3 participants