@@ -947,25 +947,29 @@ fn classify_name_ref<'db>(
947
947
None
948
948
}
949
949
} ;
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 ( ) ?;
957
956
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 ,
965
963
}
966
- } ) ( ) ;
964
+ }
965
+ } ;
966
+ let after_if_expr = |node : SyntaxNode | {
967
+ let prev_expr = prev_expr ( node) ;
967
968
matches ! ( prev_expr, Some ( ast:: Expr :: IfExpr ( _) ) )
968
969
} ;
970
+ let after_incomplete_let = |node : SyntaxNode | {
971
+ prev_expr ( node) . and_then ( |it| it. syntax ( ) . parent ( ) ) . and_then ( ast:: LetStmt :: cast)
972
+ } ;
969
973
970
974
// We do not want to generate path completions when we are sandwiched between an item decl signature and its body.
971
975
// ex. trait Foo $0 {}
@@ -1265,10 +1269,14 @@ fn classify_name_ref<'db>(
1265
1269
} ;
1266
1270
let is_func_update = func_update_record ( it) ;
1267
1271
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 ( ) ) ;
1268
1275
let incomplete_let = it
1269
1276
. parent ( )
1270
1277
. 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 ) ;
1272
1280
let in_value = it. parent ( ) . and_then ( Either :: < ast:: LetStmt , ast:: ArgList > :: cast) . is_some ( ) ;
1273
1281
let impl_ = fetch_immediate_impl ( sema, original_file, expr. syntax ( ) ) ;
1274
1282
@@ -1292,6 +1300,7 @@ fn classify_name_ref<'db>(
1292
1300
self_param,
1293
1301
in_value,
1294
1302
incomplete_let,
1303
+ after_incomplete_let,
1295
1304
impl_,
1296
1305
in_match_guard,
1297
1306
} ,
0 commit comments