diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-06-07 18:47:23 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2021-06-07 18:47:23 +0100 |
commit | 7f16b4218875847f3265a5624f1328a4a5f2de77 (patch) | |
tree | 97245a63ccc290e94a8df37eef086d21bbe23e94 /crates/ide_completion/src/completions/unqualified_path.rs | |
parent | 2f376f74750d054a69e6f633647d5a7d65dd2e94 (diff) | |
parent | b29e8ed994c573273a8182efd9b74ec8c664a848 (diff) |
Merge #9170
9170: internal: Remove unnecessary `completion::macro_in_item_position` module r=Veykril a=Veykril
bors r+
Co-authored-by: Lukas Wirth <[email protected]>
Diffstat (limited to 'crates/ide_completion/src/completions/unqualified_path.rs')
-rw-r--r-- | crates/ide_completion/src/completions/unqualified_path.rs | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/crates/ide_completion/src/completions/unqualified_path.rs b/crates/ide_completion/src/completions/unqualified_path.rs index f321ed52b..8b22933e0 100644 --- a/crates/ide_completion/src/completions/unqualified_path.rs +++ b/crates/ide_completion/src/completions/unqualified_path.rs | |||
@@ -5,26 +5,25 @@ use hir::ScopeDef; | |||
5 | use crate::{CompletionContext, Completions}; | 5 | use crate::{CompletionContext, Completions}; |
6 | 6 | ||
7 | pub(crate) fn complete_unqualified_path(acc: &mut Completions, ctx: &CompletionContext) { | 7 | pub(crate) fn complete_unqualified_path(acc: &mut Completions, ctx: &CompletionContext) { |
8 | if !ctx.is_trivial_path() { | 8 | if ctx.is_path_disallowed() || !ctx.is_trivial_path() { |
9 | return; | ||
10 | } | ||
11 | if ctx.is_path_disallowed() || ctx.expects_item() { | ||
12 | return; | 9 | return; |
13 | } | 10 | } |
14 | 11 | ||
15 | if ctx.expects_assoc_item() { | 12 | if ctx.expects_item() || ctx.expects_assoc_item() { |
16 | ctx.scope.process_all_names(&mut |name, def| { | 13 | // only show macros in {Assoc}ItemList |
17 | if let ScopeDef::MacroDef(macro_def) = def { | 14 | ctx.scope.process_all_names(&mut |name, res| { |
18 | acc.add_macro(ctx, Some(name.clone()), macro_def); | 15 | if let hir::ScopeDef::MacroDef(mac) = res { |
16 | acc.add_macro(ctx, Some(name.clone()), mac); | ||
19 | } | 17 | } |
20 | if let ScopeDef::ModuleDef(hir::ModuleDef::Module(_)) = def { | 18 | if let hir::ScopeDef::ModuleDef(hir::ModuleDef::Module(_)) = res { |
21 | acc.add_resolution(ctx, name, &def); | 19 | acc.add_resolution(ctx, name, &res); |
22 | } | 20 | } |
23 | }); | 21 | }); |
24 | return; | 22 | return; |
25 | } | 23 | } |
26 | 24 | ||
27 | if ctx.expects_use_tree() { | 25 | if ctx.expects_use_tree() { |
26 | // only show modules in a fresh UseTree | ||
28 | cov_mark::hit!(only_completes_modules_in_import); | 27 | cov_mark::hit!(only_completes_modules_in_import); |
29 | ctx.scope.process_all_names(&mut |name, res| { | 28 | ctx.scope.process_all_names(&mut |name, res| { |
30 | if let ScopeDef::ModuleDef(hir::ModuleDef::Module(_)) = res { | 29 | if let ScopeDef::ModuleDef(hir::ModuleDef::Module(_)) = res { |
@@ -693,12 +692,11 @@ impl MyStruct { | |||
693 | "#, | 692 | "#, |
694 | expect![[r#" | 693 | expect![[r#" |
695 | md bar | 694 | md bar |
696 | ma foo! macro_rules! foo | 695 | ma foo!(…) macro_rules! foo |
697 | "#]], | 696 | "#]], |
698 | ) | 697 | ) |
699 | } | 698 | } |
700 | 699 | ||
701 | // FIXME: The completions here currently come from `macro_in_item_position`, but they shouldn't | ||
702 | #[test] | 700 | #[test] |
703 | fn completes_in_item_list() { | 701 | fn completes_in_item_list() { |
704 | check( | 702 | check( |