Skip to content

fix unused_braces suggestion for wildcard assignment#158011

Open
pbkx wants to merge 1 commit into
rust-lang:mainfrom
pbkx:issue-116536-unused-braces-wildcard-assignment
Open

fix unused_braces suggestion for wildcard assignment#158011
pbkx wants to merge 1 commit into
rust-lang:mainfrom
pbkx:issue-116536-unused-braces-wildcard-assignment

Conversation

@pbkx

@pbkx pbkx commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Fixes #116536.

The unused_braces lint could suggest removing braces from wildcard assignments like:

_ = { e };

producing:

_ = e;

These are not equivalent: _ = { e }; moves/drops e, while _ = e; does not. This PR suppresses unused_braces for assignment RHS blocks when the assignment LHS contains _.

ui regression test covers both the simple wildcard assignment case and a tuple destructuring assignment case

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 17, 2026
@pbkx pbkx marked this pull request as ready for review June 17, 2026 10:09
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 17, 2026
@rustbot rustbot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jun 17, 2026
@rustbot

rustbot commented Jun 17, 2026

Copy link
Copy Markdown
Collaborator

r? @TaKO8Ki

rustbot has assigned @TaKO8Ki.
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

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 73 candidates
  • Random selection from 21 candidates

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. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

unused_braces false positive with assignment to wildcard

3 participants