aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_completion/src/completions/unqualified_path.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ide_completion/src/completions/unqualified_path.rs')
-rw-r--r--crates/ide_completion/src/completions/unqualified_path.rs27
1 files changed, 26 insertions, 1 deletions
diff --git a/crates/ide_completion/src/completions/unqualified_path.rs b/crates/ide_completion/src/completions/unqualified_path.rs
index 046a393ae..cbac88240 100644
--- a/crates/ide_completion/src/completions/unqualified_path.rs
+++ b/crates/ide_completion/src/completions/unqualified_path.rs
@@ -12,6 +12,14 @@ pub(crate) fn complete_unqualified_path(acc: &mut Completions, ctx: &CompletionC
12 if ctx.is_path_disallowed() { 12 if ctx.is_path_disallowed() {
13 return; 13 return;
14 } 14 }
15 if ctx.expects_item() || ctx.expects_assoc_item() {
16 ctx.scope.process_all_names(&mut |name, def| {
17 if let ScopeDef::MacroDef(macro_def) = def {
18 acc.add_macro(ctx, Some(name.to_string()), macro_def);
19 }
20 });
21 return;
22 }
15 23
16 if let Some(hir::Adt::Enum(e)) = 24 if let Some(hir::Adt::Enum(e)) =
17 ctx.expected_type.as_ref().and_then(|ty| ty.strip_references().as_adt()) 25 ctx.expected_type.as_ref().and_then(|ty| ty.strip_references().as_adt())
@@ -647,7 +655,7 @@ fn f() {}
647 } 655 }
648 656
649 #[test] 657 #[test]
650 fn completes_type_or_trait_in_impl_block() { 658 fn completes_target_type_or_trait_in_impl_block() {
651 check( 659 check(
652 r#" 660 r#"
653trait MyTrait {} 661trait MyTrait {}
@@ -662,4 +670,21 @@ impl My$0
662 "#]], 670 "#]],
663 ) 671 )
664 } 672 }
673
674 #[test]
675 fn only_completes_macros_in_assoc_item_list() {
676 check(
677 r#"
678struct MyStruct {}
679macro_rules! foo {}
680
681impl MyStruct {
682 $0
683}
684"#,
685 expect![[r#"
686 ma foo! macro_rules! foo
687 "#]],
688 )
689 }
665} 690}