Fix preorder_expr skipping the else block of let-else statements

Fixes exit/yield points not getting highlighted in such blocks for `highlight_related` (#14813; and possibly other bugs in features that use `preorder_expr`).
This commit is contained in:
Bastiaan Marinus van de Weerd 2023-05-18 18:30:27 -04:00
parent 54129fa113
commit 5857836047
No known key found for this signature in database
GPG key ID: 0E6045751A381BB6
2 changed files with 47 additions and 1 deletions

View file

@ -52,7 +52,10 @@ pub fn preorder_expr(start: &ast::Expr, cb: &mut dyn FnMut(WalkEvent<ast::Expr>)
}
};
if let Some(let_stmt) = node.parent().and_then(ast::LetStmt::cast) {
if Some(node.clone()) != let_stmt.initializer().map(|it| it.syntax().clone()) {
let node = Some(node.clone());
if node != let_stmt.initializer().map(|it| it.syntax().clone())
&& node != let_stmt.let_else().map(|it| it.syntax().clone())
{
// skipping potential const pat expressions in let statements
preorder.skip_subtree();
continue;