Skip to content

fix: guard replace_let_with_if_let against malformed input#22126

Open
Brumbelow wants to merge 1 commit intorust-lang:masterfrom
Brumbelow:fix/replace-let-unterminated-panic
Open

fix: guard replace_let_with_if_let against malformed input#22126
Brumbelow wants to merge 1 commit intorust-lang:masterfrom
Brumbelow:fix/replace-let-unterminated-panic

Conversation

@Brumbelow
Copy link
Copy Markdown
Contributor

Changes

  • added let_stmt.semicolon_token()? guard at the top of the assist handler.
  • A malformed let swallows the trailing ;, which is the reliable signal. Previously that state flowed through to make::expr_if, whose re-parse produced an IfExpr without a then-branch and panicked at constructors.rs:1155.
  • also added regression test replace_let_not_applicable_on_unterminated_string

Closes #22106

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 21, 2026
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.

replace_let_with_if_let panics on unterminated string literal

2 participants