File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed
crates/ide-assists/src/handlers Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -695,10 +695,24 @@ impl FunctionBody {
695695 . statements ( )
696696 . filter ( |stmt| text_range. contains_range ( stmt. syntax ( ) . text_range ( ) ) )
697697 . filter_map ( |stmt| match stmt {
698- ast:: Stmt :: ExprStmt ( expr_stmt) => expr_stmt. expr ( ) ,
698+ ast:: Stmt :: ExprStmt ( expr_stmt) => expr_stmt. expr ( ) . map ( |e| vec ! [ e ] ) ,
699699 ast:: Stmt :: Item ( _) => None ,
700- ast:: Stmt :: LetStmt ( stmt) => stmt. initializer ( ) ,
700+ ast:: Stmt :: LetStmt ( stmt) => {
701+ let init = stmt. initializer ( ) ;
702+ let let_else = stmt
703+ . let_else ( )
704+ . and_then ( |le| le. block_expr ( ) )
705+ . map ( ast:: Expr :: BlockExpr ) ;
706+
707+ match ( init, let_else) {
708+ ( Some ( i) , Some ( le) ) => Some ( vec ! [ i, le] ) ,
709+ ( Some ( i) , _) => Some ( vec ! [ i] ) ,
710+ ( _, Some ( le) ) => Some ( vec ! [ le] ) ,
711+ _ => None ,
712+ }
713+ }
701714 } )
715+ . flatten ( )
702716 . for_each ( |expr| preorder_expr ( & expr, cb) ) ;
703717 if let Some ( expr) = parent
704718 . tail_expr ( )
You can’t perform that action at this time.
0 commit comments