Skip to content

Fix diagnostics for non-exhaustive destructuring assignments (#157553)#157578

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
MaximilianAzendorf:issue-157553
Jun 8, 2026
Merged

Fix diagnostics for non-exhaustive destructuring assignments (#157553)#157578
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
MaximilianAzendorf:issue-157553

Conversation

@MaximilianAzendorf

@MaximilianAzendorf MaximilianAzendorf commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

Assigning to a refutable pattern (e.g. Foo::One = Foo::One;) is a destructuring assignment, which is lowered to a let binding. When the pattern was refutable, the refutability check reported it as a let binding. This detects the AssignDesugar origin during match checking and reports it as an assignment instead, dropping the let-specific note and suggestion.

Fixes #157553.

@rustbot

rustbot commented Jun 7, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred in match checking

cc @Nadrieril

@rustbot rustbot added 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. labels Jun 7, 2026
@rustbot

rustbot commented Jun 7, 2026

Copy link
Copy Markdown
Collaborator

r? @adwinwhite

rustbot has assigned @adwinwhite.
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 20 candidates

@rustbot

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

Comment thread tests/ui/destructuring-assignment/non-exhaustive-destructure.stderr
@Nadrieril

Nadrieril commented Jun 7, 2026

Copy link
Copy Markdown
Member

Hi, thanks for your PR! You'll have to run ./x.py test tidy --bless to fix CI.

@Nadrieril

Copy link
Copy Markdown
Member

Yep, LGTM. Thank you!

@bors r+ rollup

@rust-bors

rust-bors Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

📌 Commit b791fd7 has been approved by Nadrieril

It is now in the queue for this repository.

@rust-bors rust-bors Bot 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 Jun 8, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jun 8, 2026
…=Nadrieril

Fix diagnostics for non-exhaustive destructuring assignments (rust-lang#157553)

Assigning to a refutable pattern (e.g. `Foo::One = Foo::One;`) is a destructuring assignment, which is lowered to a `let` binding. When the pattern was refutable, the refutability check reported it as a `let` binding. This detects the `AssignDesugar` origin during match checking and reports it as an assignment instead, dropping the `let`-specific note and suggestion.

Fixes rust-lang#157553.
rust-bors Bot pushed a commit that referenced this pull request Jun 8, 2026
…uwer

Rollup of 13 pull requests

Successful merges:

 - #147302 (asm! support for the Xtensa architecture)
 - #148820 (Add very basic "comptime" fn implementation)
 - #157299 (Fix unstable diagnostics in tests)
 - #143511 (Improve TLS codegen by marking the panic/init path as cold)
 - #154608 (Add `_value` API for number literals in proc-macro)
 - #156762 (xfs support in `test_rename_directory_to_non_empty_directory`)
 - #157300 (Relax test requirements for consistency)
 - #157383 (tests: codegen-llvm: Ignore BPF targets in c-variadic-opt)
 - #157413 (fix: don't suggest .into_iter() for .cloned()/.copied() on non-reference Option)
 - #157578 (Fix diagnostics for non-exhaustive destructuring assignments (#157553))
 - #157587 (explain that the size_of constant also serves to avoid optimizing away 'unused' size_of calls)
 - #157596 (test: remove ineffective link-extern-crate-with-drop-type test)
 - #157602 (rustdoc: Remove unnecessary fast path)
@rust-bors rust-bors Bot merged commit 7712e40 into rust-lang:main Jun 8, 2026
12 checks passed
@rustbot rustbot added this to the 1.98.0 milestone Jun 8, 2026
rust-timer added a commit that referenced this pull request Jun 8, 2026
Rollup merge of #157578 - MaximilianAzendorf:issue-157553, r=Nadrieril

Fix diagnostics for non-exhaustive destructuring assignments (#157553)

Assigning to a refutable pattern (e.g. `Foo::One = Foo::One;`) is a destructuring assignment, which is lowered to a `let` binding. When the pattern was refutable, the refutability check reported it as a `let` binding. This detects the `AssignDesugar` origin during match checking and reports it as an assignment instead, dropping the `let`-specific note and suggestion.

Fixes #157553.
@MaximilianAzendorf MaximilianAzendorf deleted the issue-157553 branch June 8, 2026 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

Assigning to refutable enum results in invalid fix

5 participants