diff options
Diffstat (limited to 'crates/ra_hir_def/src/nameres/collector.rs')
-rw-r--r-- | crates/ra_hir_def/src/nameres/collector.rs | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/crates/ra_hir_def/src/nameres/collector.rs b/crates/ra_hir_def/src/nameres/collector.rs index 45199fa11..2b194f488 100644 --- a/crates/ra_hir_def/src/nameres/collector.rs +++ b/crates/ra_hir_def/src/nameres/collector.rs | |||
@@ -26,8 +26,7 @@ use crate::{ | |||
26 | path::{ModPath, PathKind}, | 26 | path::{ModPath, PathKind}, |
27 | per_ns::PerNs, | 27 | per_ns::PerNs, |
28 | AdtId, AstId, ConstLoc, ContainerId, EnumLoc, EnumVariantId, FunctionLoc, ImplLoc, Intern, | 28 | AdtId, AstId, ConstLoc, ContainerId, EnumLoc, EnumVariantId, FunctionLoc, ImplLoc, Intern, |
29 | LocalImportId, LocalModuleId, ModuleDefId, ModuleId, StaticLoc, StructLoc, TraitLoc, | 29 | LocalModuleId, ModuleDefId, ModuleId, StaticLoc, StructLoc, TraitLoc, TypeAliasLoc, UnionLoc, |
30 | TypeAliasLoc, UnionLoc, | ||
31 | }; | 30 | }; |
32 | 31 | ||
33 | pub(super) fn collect_defs(db: &impl DefDatabase, mut def_map: CrateDefMap) -> CrateDefMap { | 32 | pub(super) fn collect_defs(db: &impl DefDatabase, mut def_map: CrateDefMap) -> CrateDefMap { |
@@ -93,7 +92,7 @@ impl PartialResolvedImport { | |||
93 | #[derive(Clone, Debug, Eq, PartialEq)] | 92 | #[derive(Clone, Debug, Eq, PartialEq)] |
94 | struct ImportDirective { | 93 | struct ImportDirective { |
95 | module_id: LocalModuleId, | 94 | module_id: LocalModuleId, |
96 | import_id: LocalImportId, | 95 | import_id: raw::Import, |
97 | import: raw::ImportData, | 96 | import: raw::ImportData, |
98 | status: PartialResolvedImport, | 97 | status: PartialResolvedImport, |
99 | } | 98 | } |
@@ -110,7 +109,7 @@ struct MacroDirective { | |||
110 | struct DefCollector<'a, DB> { | 109 | struct DefCollector<'a, DB> { |
111 | db: &'a DB, | 110 | db: &'a DB, |
112 | def_map: CrateDefMap, | 111 | def_map: CrateDefMap, |
113 | glob_imports: FxHashMap<LocalModuleId, Vec<(LocalModuleId, LocalImportId)>>, | 112 | glob_imports: FxHashMap<LocalModuleId, Vec<(LocalModuleId, raw::Import)>>, |
114 | unresolved_imports: Vec<ImportDirective>, | 113 | unresolved_imports: Vec<ImportDirective>, |
115 | resolved_imports: Vec<ImportDirective>, | 114 | resolved_imports: Vec<ImportDirective>, |
116 | unexpanded_macros: Vec<MacroDirective>, | 115 | unexpanded_macros: Vec<MacroDirective>, |
@@ -219,7 +218,7 @@ where | |||
219 | self.update( | 218 | self.update( |
220 | self.def_map.root, | 219 | self.def_map.root, |
221 | None, | 220 | None, |
222 | &[(name, Resolution { def: PerNs::macros(macro_), import: None })], | 221 | &[(name, Resolution { def: PerNs::macros(macro_), import: false })], |
223 | ); | 222 | ); |
224 | } | 223 | } |
225 | } | 224 | } |
@@ -404,7 +403,7 @@ where | |||
404 | let variant = EnumVariantId { parent: e, local_id }; | 403 | let variant = EnumVariantId { parent: e, local_id }; |
405 | let res = Resolution { | 404 | let res = Resolution { |
406 | def: PerNs::both(variant.into(), variant.into()), | 405 | def: PerNs::both(variant.into(), variant.into()), |
407 | import: Some(import_id), | 406 | import: true, |
408 | }; | 407 | }; |
409 | (name, res) | 408 | (name, res) |
410 | }) | 409 | }) |
@@ -431,7 +430,7 @@ where | |||
431 | } | 430 | } |
432 | } | 431 | } |
433 | 432 | ||
434 | let resolution = Resolution { def, import: Some(import_id) }; | 433 | let resolution = Resolution { def, import: true }; |
435 | self.update(module_id, Some(import_id), &[(name, resolution)]); | 434 | self.update(module_id, Some(import_id), &[(name, resolution)]); |
436 | } | 435 | } |
437 | None => tested_by!(bogus_paths), | 436 | None => tested_by!(bogus_paths), |
@@ -442,7 +441,7 @@ where | |||
442 | fn update( | 441 | fn update( |
443 | &mut self, | 442 | &mut self, |
444 | module_id: LocalModuleId, | 443 | module_id: LocalModuleId, |
445 | import: Option<LocalImportId>, | 444 | import: Option<raw::Import>, |
446 | resolutions: &[(Name, Resolution)], | 445 | resolutions: &[(Name, Resolution)], |
447 | ) { | 446 | ) { |
448 | self.update_recursive(module_id, import, resolutions, 0) | 447 | self.update_recursive(module_id, import, resolutions, 0) |
@@ -451,7 +450,7 @@ where | |||
451 | fn update_recursive( | 450 | fn update_recursive( |
452 | &mut self, | 451 | &mut self, |
453 | module_id: LocalModuleId, | 452 | module_id: LocalModuleId, |
454 | import: Option<LocalImportId>, | 453 | import: Option<raw::Import>, |
455 | resolutions: &[(Name, Resolution)], | 454 | resolutions: &[(Name, Resolution)], |
456 | depth: usize, | 455 | depth: usize, |
457 | ) { | 456 | ) { |
@@ -462,7 +461,7 @@ where | |||
462 | let scope = &mut self.def_map.modules[module_id].scope; | 461 | let scope = &mut self.def_map.modules[module_id].scope; |
463 | let mut changed = false; | 462 | let mut changed = false; |
464 | for (name, res) in resolutions { | 463 | for (name, res) in resolutions { |
465 | changed |= scope.push_res(name.clone(), res, import); | 464 | changed |= scope.push_res(name.clone(), res, import.is_some()); |
466 | } | 465 | } |
467 | 466 | ||
468 | if !changed { | 467 | if !changed { |
@@ -719,7 +718,7 @@ where | |||
719 | def: PerNs::types( | 718 | def: PerNs::types( |
720 | ModuleId { krate: self.def_collector.def_map.krate, local_id: res }.into(), | 719 | ModuleId { krate: self.def_collector.def_map.krate, local_id: res }.into(), |
721 | ), | 720 | ), |
722 | import: None, | 721 | import: false, |
723 | }; | 722 | }; |
724 | self.def_collector.update(self.module_id, None, &[(name, resolution)]); | 723 | self.def_collector.update(self.module_id, None, &[(name, resolution)]); |
725 | res | 724 | res |
@@ -791,7 +790,7 @@ where | |||
791 | PerNs::types(def.into()) | 790 | PerNs::types(def.into()) |
792 | } | 791 | } |
793 | }; | 792 | }; |
794 | let resolution = Resolution { def, import: None }; | 793 | let resolution = Resolution { def, import: false }; |
795 | self.def_collector.update(self.module_id, None, &[(name, resolution)]) | 794 | self.def_collector.update(self.module_id, None, &[(name, resolution)]) |
796 | } | 795 | } |
797 | 796 | ||