aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_completion/src/completions/keyword.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ide_completion/src/completions/keyword.rs')
-rw-r--r--crates/ide_completion/src/completions/keyword.rs11
1 files changed, 6 insertions, 5 deletions
diff --git a/crates/ide_completion/src/completions/keyword.rs b/crates/ide_completion/src/completions/keyword.rs
index 1a7a484a4..0ca97a0e4 100644
--- a/crates/ide_completion/src/completions/keyword.rs
+++ b/crates/ide_completion/src/completions/keyword.rs
@@ -19,11 +19,12 @@ pub(crate) fn complete_use_tree_keyword(acc: &mut Completions, ctx: &CompletionC
19 }; 19 };
20 20
21 if ctx.use_item_syntax.is_some() { 21 if ctx.use_item_syntax.is_some() {
22 if ctx.path_qual.is_none() { 22 let qual = ctx.path_qual();
23 if qual.is_none() {
23 kw_completion("crate::").add_to(acc); 24 kw_completion("crate::").add_to(acc);
24 } 25 }
25 kw_completion("self").add_to(acc); 26 kw_completion("self").add_to(acc);
26 if iter::successors(ctx.path_qual.clone(), |p| p.qualifier()) 27 if iter::successors(qual.cloned(), |p| p.qualifier())
27 .all(|p| p.segment().and_then(|s| s.super_token()).is_some()) 28 .all(|p| p.segment().and_then(|s| s.super_token()).is_some())
28 { 29 {
29 kw_completion("super::").add_to(acc); 30 kw_completion("super::").add_to(acc);
@@ -128,7 +129,7 @@ pub(crate) fn complete_expr_keyword(acc: &mut Completions, ctx: &CompletionConte
128 } 129 }
129 130
130 if ctx.in_loop_body { 131 if ctx.in_loop_body {
131 if ctx.can_be_stmt { 132 if ctx.can_be_stmt() {
132 add_keyword("continue", "continue;"); 133 add_keyword("continue", "continue;");
133 add_keyword("break", "break;"); 134 add_keyword("break", "break;");
134 } else { 135 } else {
@@ -137,7 +138,7 @@ pub(crate) fn complete_expr_keyword(acc: &mut Completions, ctx: &CompletionConte
137 } 138 }
138 } 139 }
139 140
140 if !ctx.is_trivial_path { 141 if !ctx.is_trivial_path() {
141 return; 142 return;
142 } 143 }
143 let fn_def = match &ctx.function_def { 144 let fn_def = match &ctx.function_def {
@@ -147,7 +148,7 @@ pub(crate) fn complete_expr_keyword(acc: &mut Completions, ctx: &CompletionConte
147 148
148 add_keyword( 149 add_keyword(
149 "return", 150 "return",
150 match (ctx.can_be_stmt, fn_def.ret_type().is_some()) { 151 match (ctx.can_be_stmt(), fn_def.ret_type().is_some()) {
151 (true, true) => "return $0;", 152 (true, true) => "return $0;",
152 (true, false) => "return;", 153 (true, false) => "return;",
153 (false, true) => "return $0", 154 (false, true) => "return $0",