Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide-completion/src/context.rs')
-rw-r--r--crates/ide-completion/src/context.rs15
1 files changed, 8 insertions, 7 deletions
diff --git a/crates/ide-completion/src/context.rs b/crates/ide-completion/src/context.rs
index f6b8962df6..4a058ac261 100644
--- a/crates/ide-completion/src/context.rs
+++ b/crates/ide-completion/src/context.rs
@@ -48,6 +48,7 @@ pub(super) enum PathKind {
Expr {
in_block_expr: bool,
in_loop_body: bool,
+ in_functional_update: bool,
},
Type,
Attr {
@@ -392,10 +393,6 @@ impl<'a> CompletionContext<'a> {
matches!(self.path_context(), Some(PathCompletionCtx { kind: PathKind::Expr { .. }, .. }))
}
- pub(crate) fn expects_type(&self) -> bool {
- matches!(self.path_context(), Some(PathCompletionCtx { kind: PathKind::Type, .. }))
- }
-
pub(crate) fn is_non_trivial_path(&self) -> bool {
matches!(
self.path_context(),
@@ -1104,6 +1101,9 @@ impl<'a> CompletionContext<'a> {
})
.unwrap_or(false)
};
+ let is_in_func_update = |it: &SyntaxNode| {
+ it.parent().map_or(false, |it| ast::RecordExprFieldList::can_cast(it.kind()))
+ };
let kind = path.syntax().ancestors().find_map(|it| {
// using Option<Option<PathKind>> as extra controlflow
@@ -1114,8 +1114,8 @@ impl<'a> CompletionContext<'a> {
path_ctx.has_call_parens = it.syntax().parent().map_or(false, |it| ast::CallExpr::can_cast(it.kind()));
let in_block_expr = is_in_block(it.syntax());
let in_loop_body = is_in_loop_body(it.syntax());
-
- Some(PathKind::Expr { in_block_expr, in_loop_body })
+ let in_functional_update = is_in_func_update(it.syntax());
+ Some(PathKind::Expr { in_block_expr, in_loop_body, in_functional_update })
},
ast::TupleStructPat(it) => {
path_ctx.has_call_parens = true;
@@ -1149,7 +1149,8 @@ impl<'a> CompletionContext<'a> {
return Some(parent.and_then(ast::MacroExpr::cast).map(|it| {
let in_loop_body = is_in_loop_body(it.syntax());
let in_block_expr = is_in_block(it.syntax());
- PathKind::Expr { in_block_expr, in_loop_body }
+ let in_functional_update = is_in_func_update(it.syntax());
+ PathKind::Expr { in_block_expr, in_loop_body, in_functional_update }
}));
},
}