Complete while let

This commit is contained in:
Lukas Wirth 2021-03-03 21:59:41 +01:00
parent 1914b7723f
commit 02e9440e23
2 changed files with 11 additions and 9 deletions

View file

@ -91,6 +91,7 @@ pub(crate) fn complete_expr_keyword(acc: &mut Completions, ctx: &CompletionConte
if ctx.is_expr {
add_keyword(ctx, acc, "match", "match $0 {}");
add_keyword(ctx, acc, "while", "while $0 {}");
add_keyword(ctx, acc, "while let", "while let $1 = $0 {}");
add_keyword(ctx, acc, "loop", "loop {$0}");
add_keyword(ctx, acc, "if", "if $0 {}");
add_keyword(ctx, acc, "if let", "if let $1 = $0 {}");
@ -269,6 +270,7 @@ mod tests {
kw trait
kw match
kw while
kw while let
kw loop
kw if
kw if let
@ -296,6 +298,7 @@ mod tests {
kw trait
kw match
kw while
kw while let
kw loop
kw if
kw if let
@ -323,6 +326,7 @@ mod tests {
kw trait
kw match
kw while
kw while let
kw loop
kw if
kw if let
@ -357,6 +361,7 @@ fn quux() -> i32 {
expect![[r#"
kw match
kw while
kw while let
kw loop
kw if
kw if let
@ -406,6 +411,7 @@ fn quux() -> i32 {
kw trait
kw match
kw while
kw while let
kw loop
kw if
kw if let
@ -565,6 +571,7 @@ pub mod future {
expect![[r#"
kw match
kw while
kw while let
kw loop
kw if
kw if let
@ -624,6 +631,7 @@ fn foo() {
expect![[r#"
kw match
kw while
kw while let
kw loop
kw if
kw if let

View file

@ -81,9 +81,7 @@ pub(crate) fn complete_qualified_path(acc: &mut Completions, ctx: &CompletionCon
return None;
}
match item {
hir::AssocItem::Function(func) => {
acc.add_function(ctx, func, None);
}
hir::AssocItem::Function(func) => acc.add_function(ctx, func, None),
hir::AssocItem::Const(ct) => acc.add_const(ctx, ct),
hir::AssocItem::TypeAlias(ty) => acc.add_type_alias(ctx, ty),
}
@ -110,9 +108,7 @@ pub(crate) fn complete_qualified_path(acc: &mut Completions, ctx: &CompletionCon
continue;
}
match item {
hir::AssocItem::Function(func) => {
acc.add_function(ctx, func, None);
}
hir::AssocItem::Function(func) => acc.add_function(ctx, func, None),
hir::AssocItem::Const(ct) => acc.add_const(ctx, ct),
hir::AssocItem::TypeAlias(ty) => acc.add_type_alias(ctx, ty),
}
@ -143,9 +139,7 @@ pub(crate) fn complete_qualified_path(acc: &mut Completions, ctx: &CompletionCon
// them.
if seen.insert(item) {
match item {
hir::AssocItem::Function(func) => {
acc.add_function(ctx, func, None);
}
hir::AssocItem::Function(func) => acc.add_function(ctx, func, None),
hir::AssocItem::Const(ct) => acc.add_const(ctx, ct),
hir::AssocItem::TypeAlias(ty) => acc.add_type_alias(ctx, ty),
}