when invoking Replace let with if let on a let binding whose initializer is an unterminated string literal r-a panics inside the assist handler. the syntax tree is parseable but incomplete and SyntaxFactory::expr_if calls ast.then_branch().unwrap() on the constructed node without guarding against the case where the branch is absent returning None for malformed input and causing an unconditional unwrap failure.
reproduce:
place cursor on the l of let and apply Replace let with if let.
expected:
the assist should either transform the binding correctly or report that it cannot handle the incomplete expression, without crashing the server.
actual:
thread 'main' panicked at 'called Option::unwrap() on a None value', crates/syntax/src/ast/syntax_factory/constructors.rs:1141
the language server crashes and the editor loses all diagnostics and completions until it restarts.
env:
- rustc: 1.94.0
- rust-analyzer: 0.3.2854
- OS: Ubuntu
- Editor: VS Code
when invoking
Replace let with if leton aletbinding whose initializer is an unterminated string literal r-a panics inside the assist handler. the syntax tree is parseable but incomplete andSyntaxFactory::expr_ifcallsast.then_branch().unwrap()on the constructed node without guarding against the case where the branch is absent returningNonefor malformed input and causing an unconditionalunwrapfailure.reproduce:
let s = "fooplace cursor on the
lofletand applyReplace let with if let.expected:
the assist should either transform the binding correctly or report that it cannot handle the incomplete expression, without crashing the server.
actual:
thread 'main' panicked at 'called
Option::unwrap()on aNonevalue', crates/syntax/src/ast/syntax_factory/constructors.rs:1141the language server crashes and the editor loses all diagnostics and completions until it restarts.
env: