diff options
| author | bors <bors@rust-lang.org> | 2022-07-29 15:41:36 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-07-29 15:41:36 +0000 |
| commit | fb5e49631bac0584348c052e939bd3fcf1cc967c (patch) | |
| tree | cf73e16c9cbc0df2bf5e7b24bddb9d6ad983dacf | |
| parent | ec3586eab943d7c6c83d211f629a691fc8c14603 (diff) | |
| parent | 902fd6ddcdd4e3ad03c7a9099f0b3b1d7e6a95e8 (diff) | |
| download | rust-fb5e49631bac0584348c052e939bd3fcf1cc967c.tar.gz rust-fb5e49631bac0584348c052e939bd3fcf1cc967c.zip | |
Auto merge of #12906 - cynecx:fix-completions, r=Veykril
fix: complete path of existing record expr
| -rw-r--r-- | crates/ide-completion/src/context/analysis.rs | 2 | ||||
| -rw-r--r-- | crates/ide-completion/src/tests/expression.rs | 19 | ||||
| -rw-r--r-- | crates/parser/src/grammar/paths.rs | 2 |
3 files changed, 22 insertions, 1 deletions
diff --git a/crates/ide-completion/src/context/analysis.rs b/crates/ide-completion/src/context/analysis.rs index 76fc74c01d2..22ec7cead49 100644 --- a/crates/ide-completion/src/context/analysis.rs +++ b/crates/ide-completion/src/context/analysis.rs @@ -939,10 +939,12 @@ impl<'a> CompletionContext<'a> { ast::Meta(meta) => make_path_kind_attr(meta)?, ast::Visibility(it) => PathKind::Vis { has_in_token: it.in_token().is_some() }, ast::UseTree(_) => PathKind::Use, + ast::RecordExpr(it) => make_path_kind_expr(it.into()), _ => return None, } } }, + ast::RecordExpr(it) => make_path_kind_expr(it.into()), _ => return None, } }; diff --git a/crates/ide-completion/src/tests/expression.rs b/crates/ide-completion/src/tests/expression.rs index ce7a543d9f3..925081ebf66 100644 --- a/crates/ide-completion/src/tests/expression.rs +++ b/crates/ide-completion/src/tests/expression.rs @@ -651,3 +651,22 @@ fn main() { "]], ); } + +#[test] +fn complete_record_expr_path() { + check( + r#" +struct Zulu; +impl Zulu { + fn test() -> Self { } +} +fn boi(val: Zulu) { } +fn main() { + boi(Zulu:: $0 {}); +} +"#, + expect![[r#" + fn test() fn() -> Zulu + "#]], + ); +} diff --git a/crates/parser/src/grammar/paths.rs b/crates/parser/src/grammar/paths.rs index f9efcef92a6..8de5d33a193 100644 --- a/crates/parser/src/grammar/paths.rs +++ b/crates/parser/src/grammar/paths.rs @@ -54,7 +54,7 @@ fn path_for_qualifier( mut qual: CompletedMarker, ) -> CompletedMarker { loop { - let use_tree = matches!(p.nth(2), T![*] | T!['{']); + let use_tree = mode == Mode::Use && matches!(p.nth(2), T![*] | T!['{']); if p.at(T![::]) && !use_tree { let path = qual.precede(p); p.bump(T![::]); |
