diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/hir_def/src/per_ns.rs | 2 | ||||
-rw-r--r-- | crates/hir_def/src/resolver.rs | 10 | ||||
-rw-r--r-- | crates/hir_def/src/visibility.rs | 2 |
3 files changed, 10 insertions, 4 deletions
diff --git a/crates/hir_def/src/per_ns.rs b/crates/hir_def/src/per_ns.rs index 74665c588..a594afce6 100644 --- a/crates/hir_def/src/per_ns.rs +++ b/crates/hir_def/src/per_ns.rs | |||
@@ -7,7 +7,7 @@ use hir_expand::MacroDefId; | |||
7 | 7 | ||
8 | use crate::{item_scope::ItemInNs, visibility::Visibility, ModuleDefId}; | 8 | use crate::{item_scope::ItemInNs, visibility::Visibility, ModuleDefId}; |
9 | 9 | ||
10 | #[derive(Debug, Copy, Clone, PartialEq, Eq)] | 10 | #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] |
11 | pub struct PerNs { | 11 | pub struct PerNs { |
12 | pub types: Option<(ModuleDefId, Visibility)>, | 12 | pub types: Option<(ModuleDefId, Visibility)>, |
13 | pub values: Option<(ModuleDefId, Visibility)>, | 13 | pub values: Option<(ModuleDefId, Visibility)>, |
diff --git a/crates/hir_def/src/resolver.rs b/crates/hir_def/src/resolver.rs index e4152a0be..61059c349 100644 --- a/crates/hir_def/src/resolver.rs +++ b/crates/hir_def/src/resolver.rs | |||
@@ -490,6 +490,7 @@ pub enum ScopeDef { | |||
490 | 490 | ||
491 | impl Scope { | 491 | impl Scope { |
492 | fn process_names(&self, db: &dyn DefDatabase, f: &mut dyn FnMut(Name, ScopeDef)) { | 492 | fn process_names(&self, db: &dyn DefDatabase, f: &mut dyn FnMut(Name, ScopeDef)) { |
493 | let mut seen = FxHashSet::default(); | ||
493 | match self { | 494 | match self { |
494 | Scope::ModuleScope(m) => { | 495 | Scope::ModuleScope(m) => { |
495 | // FIXME: should we provide `self` here? | 496 | // FIXME: should we provide `self` here? |
@@ -503,7 +504,9 @@ impl Scope { | |||
503 | f(name.clone(), ScopeDef::PerNs(def)); | 504 | f(name.clone(), ScopeDef::PerNs(def)); |
504 | }); | 505 | }); |
505 | m.crate_def_map[m.module_id].scope.legacy_macros().for_each(|(name, macro_)| { | 506 | m.crate_def_map[m.module_id].scope.legacy_macros().for_each(|(name, macro_)| { |
506 | f(name.clone(), ScopeDef::PerNs(PerNs::macros(macro_, Visibility::Public))); | 507 | let scope = PerNs::macros(macro_, Visibility::Public); |
508 | seen.insert((name.clone(), scope)); | ||
509 | f(name.clone(), ScopeDef::PerNs(scope)); | ||
507 | }); | 510 | }); |
508 | m.crate_def_map.extern_prelude.iter().for_each(|(name, &def)| { | 511 | m.crate_def_map.extern_prelude.iter().for_each(|(name, &def)| { |
509 | f(name.clone(), ScopeDef::PerNs(PerNs::types(def, Visibility::Public))); | 512 | f(name.clone(), ScopeDef::PerNs(PerNs::types(def, Visibility::Public))); |
@@ -514,7 +517,10 @@ impl Scope { | |||
514 | if let Some(prelude) = m.crate_def_map.prelude { | 517 | if let Some(prelude) = m.crate_def_map.prelude { |
515 | let prelude_def_map = db.crate_def_map(prelude.krate); | 518 | let prelude_def_map = db.crate_def_map(prelude.krate); |
516 | prelude_def_map[prelude.local_id].scope.entries().for_each(|(name, def)| { | 519 | prelude_def_map[prelude.local_id].scope.entries().for_each(|(name, def)| { |
517 | f(name.clone(), ScopeDef::PerNs(def)); | 520 | let seen_tuple = (name.clone(), def); |
521 | if !seen.contains(&seen_tuple) { | ||
522 | f(seen_tuple.0, ScopeDef::PerNs(def)); | ||
523 | } | ||
518 | }); | 524 | }); |
519 | } | 525 | } |
520 | } | 526 | } |
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), |