Skip to content

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

Draft
charlieHsiuC wants to merge 1 commit intorust-lang:masterfrom
charlieHsiuC:dev/fix_question_mark_suggestion
Draft

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

Conversation

@charlieHsiuC
Copy link
Copy Markdown

@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

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

1 participant