Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide-completion/src/completions/expr.rs')
| -rw-r--r-- | crates/ide-completion/src/completions/expr.rs | 53 |
1 files changed, 17 insertions, 36 deletions
diff --git a/crates/ide-completion/src/completions/expr.rs b/crates/ide-completion/src/completions/expr.rs index 83ecb51aaa..6bc453a514 100644 --- a/crates/ide-completion/src/completions/expr.rs +++ b/crates/ide-completion/src/completions/expr.rs @@ -4,7 +4,7 @@ use hir::ScopeDef; use ide_db::FxHashSet; use crate::{ - context::{PathCompletionCtx, PathKind, Qualified}, + context::{ExprCtx, PathCompletionCtx, PathKind, Qualified}, CompletionContext, Completions, }; @@ -19,47 +19,28 @@ pub(crate) fn complete_expr_path( } let ( qualified, - in_block_expr, - in_loop_body, - is_func_update, - after_if_expr, - wants_mut_token, - in_condition, - ty, - incomplete_let, - impl_, - ) = match path_ctx { - &PathCompletionCtx { - kind: - PathKind::Expr { - in_block_expr, - in_loop_body, - after_if_expr, - in_condition, - incomplete_let, - ref ref_expr_parent, - ref is_func_update, - ref innermost_ret_ty, - ref impl_, - .. - }, - ref qualified, - .. - } => ( - qualified, + &ExprCtx { in_block_expr, in_loop_body, - is_func_update.is_some(), after_if_expr, - ref_expr_parent.as_ref().map(|it| it.mut_token().is_none()).unwrap_or(false), in_condition, - innermost_ret_ty, incomplete_let, - impl_, - ), + ref ref_expr_parent, + ref is_func_update, + ref innermost_ret_ty, + ref impl_, + .. + }, + ) = match path_ctx { + PathCompletionCtx { kind: PathKind::Expr { expr_ctx }, qualified, .. } => { + (qualified, expr_ctx) + } _ => return, }; + let wants_mut_token = + ref_expr_parent.as_ref().map(|it| it.mut_token().is_none()).unwrap_or(false); + let scope_def_applicable = |def| { use hir::{GenericParam::*, ModuleDef::*}; match def { @@ -230,7 +211,7 @@ pub(crate) fn complete_expr_path( } }); - if !is_func_update { + if is_func_update.is_none() { let mut add_keyword = |kw, snippet| acc.add_keyword_snippet_expr(ctx, kw, snippet, incomplete_let); @@ -270,7 +251,7 @@ pub(crate) fn complete_expr_path( } } - if let Some(ty) = ty { + if let Some(ty) = innermost_ret_ty { add_keyword( "return", match (in_block_expr, ty.is_unit()) { |