diff options
Diffstat (limited to 'crates/ra_hir_def/src/nameres/collector.rs')
-rw-r--r-- | crates/ra_hir_def/src/nameres/collector.rs | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/crates/ra_hir_def/src/nameres/collector.rs b/crates/ra_hir_def/src/nameres/collector.rs index d27c3e197..4f1fd4801 100644 --- a/crates/ra_hir_def/src/nameres/collector.rs +++ b/crates/ra_hir_def/src/nameres/collector.rs | |||
@@ -18,7 +18,6 @@ use test_utils::tested_by; | |||
18 | use crate::{ | 18 | use crate::{ |
19 | attr::Attrs, | 19 | attr::Attrs, |
20 | db::DefDatabase, | 20 | db::DefDatabase, |
21 | item_scope::Resolution, | ||
22 | nameres::{ | 21 | nameres::{ |
23 | diagnostics::DefDiagnostic, mod_resolution::ModDir, path_resolution::ReachedFixedPoint, | 22 | diagnostics::DefDiagnostic, mod_resolution::ModDir, path_resolution::ReachedFixedPoint, |
24 | raw, BuiltinShadowMode, CrateDefMap, ModuleData, ModuleOrigin, ResolveMode, | 23 | raw, BuiltinShadowMode, CrateDefMap, ModuleData, ModuleOrigin, ResolveMode, |
@@ -215,7 +214,7 @@ where | |||
215 | // In Rust, `#[macro_export]` macros are unconditionally visible at the | 214 | // In Rust, `#[macro_export]` macros are unconditionally visible at the |
216 | // crate root, even if the parent modules is **not** visible. | 215 | // crate root, even if the parent modules is **not** visible. |
217 | if export { | 216 | if export { |
218 | self.update(self.def_map.root, &[(name, Resolution { def: PerNs::macros(macro_) })]); | 217 | self.update(self.def_map.root, &[(name, PerNs::macros(macro_))]); |
219 | } | 218 | } |
220 | } | 219 | } |
221 | 220 | ||
@@ -397,8 +396,7 @@ where | |||
397 | .map(|(local_id, variant_data)| { | 396 | .map(|(local_id, variant_data)| { |
398 | let name = variant_data.name.clone(); | 397 | let name = variant_data.name.clone(); |
399 | let variant = EnumVariantId { parent: e, local_id }; | 398 | let variant = EnumVariantId { parent: e, local_id }; |
400 | let res = | 399 | let res = PerNs::both(variant.into(), variant.into()); |
401 | Resolution { def: PerNs::both(variant.into(), variant.into()) }; | ||
402 | (name, res) | 400 | (name, res) |
403 | }) | 401 | }) |
404 | .collect::<Vec<_>>(); | 402 | .collect::<Vec<_>>(); |
@@ -424,22 +422,21 @@ where | |||
424 | } | 422 | } |
425 | } | 423 | } |
426 | 424 | ||
427 | let resolution = Resolution { def }; | 425 | self.update(module_id, &[(name, def)]); |
428 | self.update(module_id, &[(name, resolution)]); | ||
429 | } | 426 | } |
430 | None => tested_by!(bogus_paths), | 427 | None => tested_by!(bogus_paths), |
431 | } | 428 | } |
432 | } | 429 | } |
433 | } | 430 | } |
434 | 431 | ||
435 | fn update(&mut self, module_id: LocalModuleId, resolutions: &[(Name, Resolution)]) { | 432 | fn update(&mut self, module_id: LocalModuleId, resolutions: &[(Name, PerNs)]) { |
436 | self.update_recursive(module_id, resolutions, 0) | 433 | self.update_recursive(module_id, resolutions, 0) |
437 | } | 434 | } |
438 | 435 | ||
439 | fn update_recursive( | 436 | fn update_recursive( |
440 | &mut self, | 437 | &mut self, |
441 | module_id: LocalModuleId, | 438 | module_id: LocalModuleId, |
442 | resolutions: &[(Name, Resolution)], | 439 | resolutions: &[(Name, PerNs)], |
443 | depth: usize, | 440 | depth: usize, |
444 | ) { | 441 | ) { |
445 | if depth > 100 { | 442 | if depth > 100 { |
@@ -705,8 +702,7 @@ where | |||
705 | let module = ModuleId { krate: self.def_collector.def_map.krate, local_id: res }; | 702 | let module = ModuleId { krate: self.def_collector.def_map.krate, local_id: res }; |
706 | let def: ModuleDefId = module.into(); | 703 | let def: ModuleDefId = module.into(); |
707 | self.def_collector.def_map.modules[self.module_id].scope.define_def(def); | 704 | self.def_collector.def_map.modules[self.module_id].scope.define_def(def); |
708 | let resolution = Resolution { def: def.into() }; | 705 | self.def_collector.update(self.module_id, &[(name, def.into())]); |
709 | self.def_collector.update(self.module_id, &[(name, resolution)]); | ||
710 | res | 706 | res |
711 | } | 707 | } |
712 | 708 | ||
@@ -765,8 +761,7 @@ where | |||
765 | .into(), | 761 | .into(), |
766 | }; | 762 | }; |
767 | self.def_collector.def_map.modules[self.module_id].scope.define_def(def); | 763 | self.def_collector.def_map.modules[self.module_id].scope.define_def(def); |
768 | let resolution = Resolution { def: def.into() }; | 764 | self.def_collector.update(self.module_id, &[(name, def.into())]) |
769 | self.def_collector.update(self.module_id, &[(name, resolution)]) | ||
770 | } | 765 | } |
771 | 766 | ||
772 | fn collect_derives(&mut self, attrs: &Attrs, def: &raw::DefData) { | 767 | fn collect_derives(&mut self, attrs: &Attrs, def: &raw::DefData) { |