From 4399eff2d06f9134ff37a4dfd47204de6ebebd92 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 9 Jul 2020 12:14:26 +0200 Subject: Re-enable IDE features for incomplete impl blocs --- crates/ra_hir_def/src/item_tree/lower.rs | 5 +++-- .../ra_ide/src/completion/complete_unqualified_path.rs | 17 +++++++++++++++++ crates/ra_ide/src/completion/completion_item.rs | 2 +- 3 files changed, 21 insertions(+), 3 deletions(-) (limited to 'crates') diff --git a/crates/ra_hir_def/src/item_tree/lower.rs b/crates/ra_hir_def/src/item_tree/lower.rs index 06743d7fc..eaa10d999 100644 --- a/crates/ra_hir_def/src/item_tree/lower.rs +++ b/crates/ra_hir_def/src/item_tree/lower.rs @@ -450,8 +450,9 @@ impl Ctx { // We cannot use `assoc_items()` here as that does not include macro calls. let items = impl_def - .item_list()? - .items() + .item_list() + .into_iter() + .flat_map(|it| it.items()) .filter_map(|item| { self.collect_inner_items(item.syntax()); let assoc = self.lower_assoc_item(&item)?; diff --git a/crates/ra_ide/src/completion/complete_unqualified_path.rs b/crates/ra_ide/src/completion/complete_unqualified_path.rs index 72ff82e66..18f4488b7 100644 --- a/crates/ra_ide/src/completion/complete_unqualified_path.rs +++ b/crates/ra_ide/src/completion/complete_unqualified_path.rs @@ -638,4 +638,21 @@ fn f() {} expect![[""]], ) } + + #[test] + fn completes_type_or_trait_in_impl_block() { + check( + r#" +trait MyTrait {} +struct MyStruct {} + +impl My<|> +"#, + expect![[r#" + st MyStruct + tt MyTrait + tp Self + "#]], + ) + } } diff --git a/crates/ra_ide/src/completion/completion_item.rs b/crates/ra_ide/src/completion/completion_item.rs index d7011c9cf..7bdda316c 100644 --- a/crates/ra_ide/src/completion/completion_item.rs +++ b/crates/ra_ide/src/completion/completion_item.rs @@ -58,7 +58,7 @@ pub struct CompletionItem { score: Option, } -// We use custom debug for CompletionItem to make `insta`'s diffs more readable. +// We use custom debug for CompletionItem to make snapshot tests more readable. impl fmt::Debug for CompletionItem { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let mut s = f.debug_struct("CompletionItem"); -- cgit v1.2.3