Skip to content

Fix wrong question_mark suggestion when match arm body is a destructuring assignment#16863

Merged
llogiq merged 1 commit intorust-lang:masterfrom
charlieHsiuC:dev/fix_question_mark_suggestion
Apr 24, 2026
Merged

Fix wrong question_mark suggestion when match arm body is a destructuring assignment#16863
llogiq merged 1 commit intorust-lang:masterfrom
charlieHsiuC:dev/fix_question_mark_suggestion

Conversation

@charlieHsiuC
Copy link
Copy Markdown
Contributor

@charlieHsiuC charlieHsiuC commented Apr 16, 2026

  • Added && sugg.starts_with('{') to the block-insertion branch. When the snippet doesn't start with { (i.e., destructuring assignment), it falls through to the else branch which correctly wraps the suggestion in an explicit block.
  • Added a new test case issue_destructuring_assignment in tests/ui/question_mark.rs to verify that the lint provides correct suggestion for match expressions with destructuring assignments that can be replaced by the ? operator.

fixes #16862

changelog: [question_mark]: Fix wrong suggestion when match arm body is a destructuring assignment

@charlieHsiuC charlieHsiuC marked this pull request as ready for review April 17, 2026 14:14
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Apr 17, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 17, 2026

r? @llogiq

rustbot has assigned @llogiq.
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: 7 candidates
  • 7 candidates expanded to 7 candidates
  • Random selection from Jarcho, dswij, llogiq, samueltardieu

Copy link
Copy Markdown
Contributor

@llogiq llogiq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Thank you.

View changes since this review

@llogiq llogiq added this pull request to the merge queue Apr 24, 2026
Merged via the queue into rust-lang:master with commit 55b5409 Apr 24, 2026
11 of 13 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Apr 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

question_mark: wrong suggestion when match arm body is a destructuring assignment

3 participants