diff options
Diffstat (limited to 'crates/ra_hir/src/resolve.rs')
-rw-r--r-- | crates/ra_hir/src/resolve.rs | 12 |
1 files changed, 9 insertions, 3 deletions
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 { |