Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide-completion/src/context/analysis.rs')
-rw-r--r--crates/ide-completion/src/context/analysis.rs12
1 files changed, 9 insertions, 3 deletions
diff --git a/crates/ide-completion/src/context/analysis.rs b/crates/ide-completion/src/context/analysis.rs
index e761da7152..add637a16f 100644
--- a/crates/ide-completion/src/context/analysis.rs
+++ b/crates/ide-completion/src/context/analysis.rs
@@ -1321,9 +1321,8 @@ fn classify_name_ref<'db>(
let incomplete_expr_stmt =
it.parent().and_then(ast::ExprStmt::cast).map(|it| it.semicolon_token().is_none());
let before_else_kw = before_else_kw(it);
- let incomplete_let = it
- .parent()
- .and_then(ast::LetStmt::cast)
+ let incomplete_let = left_ancestors(it.parent())
+ .find_map(ast::LetStmt::cast)
.is_some_and(|it| it.semicolon_token().is_none())
|| after_incomplete_let && incomplete_expr_stmt.unwrap_or(true) && !before_else_kw;
let in_value = is_in_value(it);
@@ -1882,6 +1881,13 @@ fn path_or_use_tree_qualifier(path: &ast::Path) -> Option<(ast::Path, bool)> {
Some((use_tree.path()?, true))
}
+fn left_ancestors(node: Option<SyntaxNode>) -> impl Iterator<Item = SyntaxNode> {
+ node.into_iter().flat_map(|node| {
+ let end = node.text_range().end();
+ node.ancestors().take_while(move |it| it.text_range().end() == end)
+ })
+}
+
fn is_in_token_of_for_loop(path: &ast::Path) -> bool {
// oh my ...
(|| {