aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/hir_def/src/per_ns.rs2
-rw-r--r--crates/hir_def/src/resolver.rs9
-rw-r--r--crates/hir_def/src/visibility.rs2
3 files changed, 9 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
8use crate::{item_scope::ItemInNs, visibility::Visibility, ModuleDefId}; 8use crate::{item_scope::ItemInNs, visibility::Visibility, ModuleDefId};
9 9
10#[derive(Debug, Copy, Clone, PartialEq, Eq)] 10#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
11pub struct PerNs { 11pub 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 f8cc5e075..cc66dcf31 100644
--- a/crates/hir_def/src/resolver.rs
+++ b/crates/hir_def/src/resolver.rs
@@ -483,6 +483,7 @@ pub enum ScopeDef {
483 483
484impl Scope { 484impl Scope {
485 fn process_names(&self, db: &dyn DefDatabase, f: &mut dyn FnMut(Name, ScopeDef)) { 485 fn process_names(&self, db: &dyn DefDatabase, f: &mut dyn FnMut(Name, ScopeDef)) {
486 let mut seen = FxHashSet::default();
486 match self { 487 match self {
487 Scope::ModuleScope(m) => { 488 Scope::ModuleScope(m) => {
488 // FIXME: should we provide `self` here? 489 // FIXME: should we provide `self` here?
@@ -496,7 +497,9 @@ impl Scope {
496 f(name.clone(), ScopeDef::PerNs(def)); 497 f(name.clone(), ScopeDef::PerNs(def));
497 }); 498 });
498 m.crate_def_map[m.module_id].scope.legacy_macros().for_each(|(name, macro_)| { 499 m.crate_def_map[m.module_id].scope.legacy_macros().for_each(|(name, macro_)| {
499 f(name.clone(), ScopeDef::PerNs(PerNs::macros(macro_, Visibility::Public))); 500 let scope = PerNs::macros(macro_, Visibility::Public);
501 seen.insert((name.clone(), scope));
502 f(name.clone(), ScopeDef::PerNs(scope));
500 }); 503 });
501 m.crate_def_map.extern_prelude.iter().for_each(|(name, &def)| { 504 m.crate_def_map.extern_prelude.iter().for_each(|(name, &def)| {
502 f(name.clone(), ScopeDef::PerNs(PerNs::types(def, Visibility::Public))); 505 f(name.clone(), ScopeDef::PerNs(PerNs::types(def, Visibility::Public)));
@@ -507,7 +510,9 @@ impl Scope {
507 if let Some(prelude) = m.crate_def_map.prelude { 510 if let Some(prelude) = m.crate_def_map.prelude {
508 let prelude_def_map = db.crate_def_map(prelude.krate); 511 let prelude_def_map = db.crate_def_map(prelude.krate);
509 prelude_def_map[prelude.local_id].scope.entries().for_each(|(name, def)| { 512 prelude_def_map[prelude.local_id].scope.entries().for_each(|(name, def)| {
510 f(name.clone(), ScopeDef::PerNs(def)); 513 if !seen.contains(&(name.clone(), def)) {
514 f(name.clone(), ScopeDef::PerNs(def));
515 }
511 }); 516 });
512 } 517 }
513 } 518 }
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)]
89pub enum Visibility { 89pub enum Visibility {
90 /// Visibility is restricted to a certain module. 90 /// Visibility is restricted to a certain module.
91 Module(ModuleId), 91 Module(ModuleId),