diff options
| author | bors <bors@rust-lang.org> | 2022-04-14 16:40:15 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-04-14 16:40:15 +0000 |
| commit | 7ce3ca5aabb906ac06c5132ef5b333a7c3af1b98 (patch) | |
| tree | 06622e78e26688e2ac7aa05142ea026015744db9 | |
| parent | ae68b68d39db1754502fe13e5a11225c9189a3d4 (diff) | |
| parent | 1fd232cd696cfb2c25cb8ecb14cb5641563edda7 (diff) | |
| download | rust-7ce3ca5aabb906ac06c5132ef5b333a7c3af1b98.tar.gz rust-7ce3ca5aabb906ac06c5132ef5b333a7c3af1b98.zip | |
Auto merge of #11993 - jonas-schievink:adt-completions-in-block, r=jonas-schievink
fix: enable ADT keyword completions in block expressions fixes https://github.com/rust-lang/rust-analyzer/issues/11576
| -rw-r--r-- | crates/ide_completion/src/completions/keyword.rs | 2 | ||||
| -rw-r--r-- | crates/ide_completion/src/tests/expression.rs | 12 |
2 files changed, 13 insertions, 1 deletions
diff --git a/crates/ide_completion/src/completions/keyword.rs b/crates/ide_completion/src/completions/keyword.rs index ac782352fcb..51405e35232 100644 --- a/crates/ide_completion/src/completions/keyword.rs +++ b/crates/ide_completion/src/completions/keyword.rs @@ -86,7 +86,7 @@ pub(crate) fn complete_expr_keyword(acc: &mut Completions, ctx: &CompletionConte add_keyword("mod", "mod $0"); } - if expects_item { + if expects_item || has_block_expr_parent { add_keyword("enum", "enum $1 {\n $0\n}"); add_keyword("struct", "struct $0"); add_keyword("union", "union $1 {\n $0\n}"); diff --git a/crates/ide_completion/src/tests/expression.rs b/crates/ide_completion/src/tests/expression.rs index de283c705d0..f1950235d46 100644 --- a/crates/ide_completion/src/tests/expression.rs +++ b/crates/ide_completion/src/tests/expression.rs @@ -137,6 +137,9 @@ impl Unit { kw trait kw static kw mod + kw enum + kw struct + kw union kw match kw while kw while let @@ -227,6 +230,9 @@ fn complete_in_block() { kw trait kw static kw mod + kw enum + kw struct + kw union kw match kw while kw while let @@ -269,6 +275,9 @@ fn complete_after_if_expr() { kw trait kw static kw mod + kw enum + kw struct + kw union kw match kw while kw while let @@ -339,6 +348,9 @@ fn completes_in_loop_ctx() { kw trait kw static kw mod + kw enum + kw struct + kw union kw match kw while kw while let |
