diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-01-14 10:00:46 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2021-01-14 10:00:46 +0000 |
commit | 184f4cbf5df909146b05aaa3b7f2f0b27ac36590 (patch) | |
tree | c9d803d2fefdc31278338fc67f6df8d1bf747a12 /crates/hir_def/src/visibility.rs | |
parent | 39167b97d8a62adadecc9b67caac65ec556768cf (diff) | |
parent | cca0dfa79ed968d41464eb7beb7aaa970e2d429f (diff) |
Merge #7110
7110: Deduplicate macros when offering completion r=matklad a=AdnoC
Closes https://github.com/rust-analyzer/rust-analyzer/issues/7081
When iterating over the names within the `hir_def::resolver::Scope` for a module, track what macros are in the `hir_def::item_scope::ItemScope::legacy_macros` collection for the module. When iterating over names from the prelude, do not proccess the name if it had been in the `legacy_macros` collection.
This is implemented with a `FxHashSet` in the `Scope::process_names` function that is populated when iterating over `legacy_macros` and checked when iterating over the prelude.
Alternative implementation could instead query the `legacy_macros` `FxHashMap` directly when processing names in the prelude.
Also, I'd like to add a test for this, but I'm not sure where it could be added.
Co-authored-by: AdnoC <[email protected]>
Diffstat (limited to 'crates/hir_def/src/visibility.rs')
-rw-r--r-- | crates/hir_def/src/visibility.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/crates/hir_def/src/visibility.rs b/crates/hir_def/src/visibility.rs index e6e0853a3..f3bc9d680 100644 --- a/crates/hir_def/src/visibility.rs +++ b/crates/hir_def/src/visibility.rs | |||
@@ -85,7 +85,7 @@ impl RawVisibility { | |||
85 | } | 85 | } |
86 | 86 | ||
87 | /// Visibility of an item, with the path resolved. | 87 | /// Visibility of an item, with the path resolved. |
88 | #[derive(Debug, Copy, Clone, PartialEq, Eq)] | 88 | #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] |
89 | pub enum Visibility { | 89 | pub enum Visibility { |
90 | /// Visibility is restricted to a certain module. | 90 | /// Visibility is restricted to a certain module. |
91 | Module(ModuleId), | 91 | Module(ModuleId), |