diff options
Diffstat (limited to 'crates/ra_hir/src')
-rw-r--r-- | crates/ra_hir/src/nameres.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir/src/resolve.rs | 12 |
2 files changed, 10 insertions, 4 deletions
diff --git a/crates/ra_hir/src/nameres.rs b/crates/ra_hir/src/nameres.rs index cd7b41cff..e35b4b129 100644 --- a/crates/ra_hir/src/nameres.rs +++ b/crates/ra_hir/src/nameres.rs | |||
@@ -40,7 +40,7 @@ pub struct ItemMap { | |||
40 | /// The prelude module for this crate. This either comes from an import | 40 | /// The prelude module for this crate. This either comes from an import |
41 | /// marked with the `prelude_import` attribute, or (in the normal case) from | 41 | /// marked with the `prelude_import` attribute, or (in the normal case) from |
42 | /// a dependency (`std` or `core`). | 42 | /// a dependency (`std` or `core`). |
43 | prelude: Option<Module>, | 43 | pub(crate) prelude: Option<Module>, |
44 | pub(crate) extern_prelude: FxHashMap<Name, ModuleDef>, | 44 | pub(crate) extern_prelude: FxHashMap<Name, ModuleDef>, |
45 | per_module: ArenaMap<ModuleId, ModuleScope>, | 45 | per_module: ArenaMap<ModuleId, ModuleScope>, |
46 | } | 46 | } |
diff --git a/crates/ra_hir/src/resolve.rs b/crates/ra_hir/src/resolve.rs index fde4d6580..91a531801 100644 --- a/crates/ra_hir/src/resolve.rs +++ b/crates/ra_hir/src/resolve.rs | |||
@@ -82,10 +82,10 @@ impl Resolver { | |||
82 | } | 82 | } |
83 | } | 83 | } |
84 | 84 | ||
85 | pub fn all_names(&self) -> FxHashMap<Name, PerNs<Resolution>> { | 85 | pub fn all_names(&self, db: &impl HirDatabase) -> FxHashMap<Name, PerNs<Resolution>> { |
86 | let mut names = FxHashMap::default(); | 86 | let mut names = FxHashMap::default(); |
87 | for scope in self.scopes.iter().rev() { | 87 | for scope in self.scopes.iter().rev() { |
88 | scope.collect_names(&mut |name, res| { | 88 | scope.collect_names(db, &mut |name, res| { |
89 | let current: &mut PerNs<Resolution> = names.entry(name).or_default(); | 89 | let current: &mut PerNs<Resolution> = names.entry(name).or_default(); |
90 | if current.types.is_none() { | 90 | if current.types.is_none() { |
91 | current.types = res.types; | 91 | current.types = res.types; |
@@ -174,7 +174,7 @@ impl Scope { | |||
174 | } | 174 | } |
175 | } | 175 | } |
176 | 176 | ||
177 | fn collect_names(&self, f: &mut dyn FnMut(Name, PerNs<Resolution>)) { | 177 | fn collect_names(&self, db: &impl HirDatabase, f: &mut dyn FnMut(Name, PerNs<Resolution>)) { |
178 | match self { | 178 | match self { |
179 | Scope::ModuleScope(m) => { | 179 | Scope::ModuleScope(m) => { |
180 | // TODO: should we provide `self` here? | 180 | // TODO: should we provide `self` here? |
@@ -190,6 +190,12 @@ impl Scope { | |||
190 | m.item_map.extern_prelude.iter().for_each(|(name, def)| { | 190 | m.item_map.extern_prelude.iter().for_each(|(name, def)| { |
191 | f(name.clone(), PerNs::types(Resolution::Def(*def))); | 191 | f(name.clone(), PerNs::types(Resolution::Def(*def))); |
192 | }); | 192 | }); |
193 | if let Some(prelude) = m.item_map.prelude { | ||
194 | let prelude_item_map = db.item_map(prelude.krate); | ||
195 | prelude_item_map[prelude.module_id].entries().for_each(|(name, res)| { | ||
196 | f(name.clone(), res.def.map(Resolution::Def)); | ||
197 | }); | ||
198 | } | ||
193 | } | 199 | } |
194 | Scope::GenericParams(gp) => { | 200 | Scope::GenericParams(gp) => { |
195 | for param in &gp.params { | 201 | for param in &gp.params { |