@@ -947,25 +947,29 @@ fn classify_name_ref<'db>(
947947 None
948948 }
949949 } ;
950- let after_if_expr = |node : SyntaxNode | {
951- let prev_expr = ( || {
952- let node = match node. parent ( ) . and_then ( ast:: ExprStmt :: cast) {
953- Some ( stmt) => stmt. syntax ( ) . clone ( ) ,
954- None => node,
955- } ;
956- let prev_sibling = non_trivia_sibling ( node. into ( ) , Direction :: Prev ) ?. into_node ( ) ?;
950+ let prev_expr = |node : SyntaxNode | {
951+ let node = match node. parent ( ) . and_then ( ast:: ExprStmt :: cast) {
952+ Some ( stmt) => stmt. syntax ( ) . clone ( ) ,
953+ None => node,
954+ } ;
955+ let prev_sibling = non_trivia_sibling ( node. into ( ) , Direction :: Prev ) ?. into_node ( ) ?;
957956
958- match_ast ! {
959- match prev_sibling {
960- ast:: ExprStmt ( stmt) => stmt. expr( ) . filter( |_| stmt. semicolon_token( ) . is_none( ) ) ,
961- ast:: LetStmt ( stmt) => stmt. initializer( ) . filter( |_| stmt. semicolon_token( ) . is_none( ) ) ,
962- ast:: Expr ( expr) => Some ( expr) ,
963- _ => None ,
964- }
957+ match_ast ! {
958+ match prev_sibling {
959+ ast:: ExprStmt ( stmt) => stmt. expr( ) . filter( |_| stmt. semicolon_token( ) . is_none( ) ) ,
960+ ast:: LetStmt ( stmt) => stmt. initializer( ) . filter( |_| stmt. semicolon_token( ) . is_none( ) ) ,
961+ ast:: Expr ( expr) => Some ( expr) ,
962+ _ => None ,
965963 }
966- } ) ( ) ;
964+ }
965+ } ;
966+ let after_if_expr = |node : SyntaxNode | {
967+ let prev_expr = prev_expr ( node) ;
967968 matches ! ( prev_expr, Some ( ast:: Expr :: IfExpr ( _) ) )
968969 } ;
970+ let after_incomplete_let = |node : SyntaxNode | {
971+ prev_expr ( node) . and_then ( |it| it. syntax ( ) . parent ( ) ) . and_then ( ast:: LetStmt :: cast)
972+ } ;
969973
970974 // We do not want to generate path completions when we are sandwiched between an item decl signature and its body.
971975 // ex. trait Foo $0 {}
@@ -1265,10 +1269,14 @@ fn classify_name_ref<'db>(
12651269 } ;
12661270 let is_func_update = func_update_record ( it) ;
12671271 let in_condition = is_in_condition ( & expr) ;
1272+ let after_incomplete_let = after_incomplete_let ( it. clone ( ) ) . is_some ( ) ;
1273+ let incomplete_expr_stmt =
1274+ it. parent ( ) . and_then ( ast:: ExprStmt :: cast) . map ( |it| it. semicolon_token ( ) . is_none ( ) ) ;
12681275 let incomplete_let = it
12691276 . parent ( )
12701277 . and_then ( ast:: LetStmt :: cast)
1271- . is_some_and ( |it| it. semicolon_token ( ) . is_none ( ) ) ;
1278+ . is_some_and ( |it| it. semicolon_token ( ) . is_none ( ) )
1279+ || after_incomplete_let && incomplete_expr_stmt. unwrap_or ( true ) ;
12721280 let in_value = it. parent ( ) . and_then ( Either :: < ast:: LetStmt , ast:: ArgList > :: cast) . is_some ( ) ;
12731281 let impl_ = fetch_immediate_impl ( sema, original_file, expr. syntax ( ) ) ;
12741282
@@ -1292,6 +1300,7 @@ fn classify_name_ref<'db>(
12921300 self_param,
12931301 in_value,
12941302 incomplete_let,
1303+ after_incomplete_let,
12951304 impl_,
12961305 in_match_guard,
12971306 } ,
0 commit comments