aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def/src/nameres/collector.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir_def/src/nameres/collector.rs')
-rw-r--r--crates/ra_hir_def/src/nameres/collector.rs40
1 files changed, 20 insertions, 20 deletions
diff --git a/crates/ra_hir_def/src/nameres/collector.rs b/crates/ra_hir_def/src/nameres/collector.rs
index 4a671b8f3..5f7697f63 100644
--- a/crates/ra_hir_def/src/nameres/collector.rs
+++ b/crates/ra_hir_def/src/nameres/collector.rs
@@ -19,9 +19,9 @@ use crate::{
19 per_ns::PerNs, raw, CrateDefMap, ModuleData, Resolution, ResolveMode, 19 per_ns::PerNs, raw, CrateDefMap, ModuleData, Resolution, ResolveMode,
20 }, 20 },
21 path::{Path, PathKind}, 21 path::{Path, PathKind},
22 AdtId, AstId, AstItemDef, ConstLoc, ContainerId, CrateModuleId, EnumId, EnumVariantId, 22 AdtId, AstId, AstItemDef, ConstLoc, ContainerId, EnumId, EnumVariantId, FunctionLoc, ImplId,
23 FunctionLoc, ImplId, Intern, LocalImportId, LocationCtx, ModuleDefId, ModuleId, StaticId, 23 Intern, LocalImportId, LocalModuleId, LocationCtx, ModuleDefId, ModuleId, StaticId, StructId,
24 StructId, StructOrUnionId, TraitId, TypeAliasLoc, UnionId, 24 StructOrUnionId, TraitId, TypeAliasLoc, UnionId,
25}; 25};
26 26
27pub(super) fn collect_defs(db: &impl DefDatabase, mut def_map: CrateDefMap) -> CrateDefMap { 27pub(super) fn collect_defs(db: &impl DefDatabase, mut def_map: CrateDefMap) -> CrateDefMap {
@@ -94,10 +94,10 @@ impl MacroStackMonitor {
94struct DefCollector<'a, DB> { 94struct DefCollector<'a, DB> {
95 db: &'a DB, 95 db: &'a DB,
96 def_map: CrateDefMap, 96 def_map: CrateDefMap,
97 glob_imports: FxHashMap<CrateModuleId, Vec<(CrateModuleId, LocalImportId)>>, 97 glob_imports: FxHashMap<LocalModuleId, Vec<(LocalModuleId, LocalImportId)>>,
98 unresolved_imports: Vec<(CrateModuleId, LocalImportId, raw::ImportData)>, 98 unresolved_imports: Vec<(LocalModuleId, LocalImportId, raw::ImportData)>,
99 unexpanded_macros: Vec<(CrateModuleId, AstId<ast::MacroCall>, Path)>, 99 unexpanded_macros: Vec<(LocalModuleId, AstId<ast::MacroCall>, Path)>,
100 mod_dirs: FxHashMap<CrateModuleId, ModDir>, 100 mod_dirs: FxHashMap<LocalModuleId, ModDir>,
101 101
102 /// Some macro use `$tt:tt which mean we have to handle the macro perfectly 102 /// Some macro use `$tt:tt which mean we have to handle the macro perfectly
103 /// To prevent stack overflow, we add a deep counter here for prevent that. 103 /// To prevent stack overflow, we add a deep counter here for prevent that.
@@ -173,7 +173,7 @@ where
173 /// ``` 173 /// ```
174 fn define_macro( 174 fn define_macro(
175 &mut self, 175 &mut self,
176 module_id: CrateModuleId, 176 module_id: LocalModuleId,
177 name: Name, 177 name: Name,
178 macro_: MacroDefId, 178 macro_: MacroDefId,
179 export: bool, 179 export: bool,
@@ -200,7 +200,7 @@ where
200 /// the definition of current module. 200 /// the definition of current module.
201 /// And also, `macro_use` on a module will import all legacy macros visable inside to 201 /// And also, `macro_use` on a module will import all legacy macros visable inside to
202 /// current legacy scope, with possible shadowing. 202 /// current legacy scope, with possible shadowing.
203 fn define_legacy_macro(&mut self, module_id: CrateModuleId, name: Name, macro_: MacroDefId) { 203 fn define_legacy_macro(&mut self, module_id: LocalModuleId, name: Name, macro_: MacroDefId) {
204 // Always shadowing 204 // Always shadowing
205 self.def_map.modules[module_id].scope.legacy_macros.insert(name, macro_); 205 self.def_map.modules[module_id].scope.legacy_macros.insert(name, macro_);
206 } 206 }
@@ -208,7 +208,7 @@ where
208 /// Import macros from `#[macro_use] extern crate`. 208 /// Import macros from `#[macro_use] extern crate`.
209 fn import_macros_from_extern_crate( 209 fn import_macros_from_extern_crate(
210 &mut self, 210 &mut self,
211 current_module_id: CrateModuleId, 211 current_module_id: LocalModuleId,
212 import: &raw::ImportData, 212 import: &raw::ImportData,
213 ) { 213 ) {
214 log::debug!( 214 log::debug!(
@@ -235,7 +235,7 @@ where
235 /// Exported macros are just all macros in the root module scope. 235 /// Exported macros are just all macros in the root module scope.
236 /// Note that it contains not only all `#[macro_export]` macros, but also all aliases 236 /// Note that it contains not only all `#[macro_export]` macros, but also all aliases
237 /// created by `use` in the root module, ignoring the visibility of `use`. 237 /// created by `use` in the root module, ignoring the visibility of `use`.
238 fn import_all_macros_exported(&mut self, current_module_id: CrateModuleId, krate: CrateId) { 238 fn import_all_macros_exported(&mut self, current_module_id: LocalModuleId, krate: CrateId) {
239 let def_map = self.db.crate_def_map(krate); 239 let def_map = self.db.crate_def_map(krate);
240 for (name, def) in def_map[def_map.root].scope.macros() { 240 for (name, def) in def_map[def_map.root].scope.macros() {
241 // `macro_use` only bring things into legacy scope. 241 // `macro_use` only bring things into legacy scope.
@@ -265,7 +265,7 @@ where
265 265
266 fn resolve_import( 266 fn resolve_import(
267 &self, 267 &self,
268 module_id: CrateModuleId, 268 module_id: LocalModuleId,
269 import: &raw::ImportData, 269 import: &raw::ImportData,
270 ) -> (PerNs, ReachedFixedPoint) { 270 ) -> (PerNs, ReachedFixedPoint) {
271 log::debug!("resolving import: {:?} ({:?})", import, self.def_map.edition); 271 log::debug!("resolving import: {:?} ({:?})", import, self.def_map.edition);
@@ -291,7 +291,7 @@ where
291 291
292 fn record_resolved_import( 292 fn record_resolved_import(
293 &mut self, 293 &mut self,
294 module_id: CrateModuleId, 294 module_id: LocalModuleId,
295 def: PerNs, 295 def: PerNs,
296 import_id: LocalImportId, 296 import_id: LocalImportId,
297 import: &raw::ImportData, 297 import: &raw::ImportData,
@@ -387,7 +387,7 @@ where
387 387
388 fn update( 388 fn update(
389 &mut self, 389 &mut self,
390 module_id: CrateModuleId, 390 module_id: LocalModuleId,
391 import: Option<LocalImportId>, 391 import: Option<LocalImportId>,
392 resolutions: &[(Name, Resolution)], 392 resolutions: &[(Name, Resolution)],
393 ) { 393 ) {
@@ -396,7 +396,7 @@ where
396 396
397 fn update_recursive( 397 fn update_recursive(
398 &mut self, 398 &mut self,
399 module_id: CrateModuleId, 399 module_id: LocalModuleId,
400 import: Option<LocalImportId>, 400 import: Option<LocalImportId>,
401 resolutions: &[(Name, Resolution)], 401 resolutions: &[(Name, Resolution)],
402 depth: usize, 402 depth: usize,
@@ -484,7 +484,7 @@ where
484 484
485 fn collect_macro_expansion( 485 fn collect_macro_expansion(
486 &mut self, 486 &mut self,
487 module_id: CrateModuleId, 487 module_id: LocalModuleId,
488 macro_call_id: MacroCallId, 488 macro_call_id: MacroCallId,
489 macro_def_id: MacroDefId, 489 macro_def_id: MacroDefId,
490 ) { 490 ) {
@@ -522,7 +522,7 @@ where
522/// Walks a single module, populating defs, imports and macros 522/// Walks a single module, populating defs, imports and macros
523struct ModCollector<'a, D> { 523struct ModCollector<'a, D> {
524 def_collector: D, 524 def_collector: D,
525 module_id: CrateModuleId, 525 module_id: LocalModuleId,
526 file_id: HirFileId, 526 file_id: HirFileId,
527 raw_items: &'a raw::RawItems, 527 raw_items: &'a raw::RawItems,
528 mod_dir: ModDir, 528 mod_dir: ModDir,
@@ -647,7 +647,7 @@ where
647 name: Name, 647 name: Name,
648 declaration: AstId<ast::Module>, 648 declaration: AstId<ast::Module>,
649 definition: Option<FileId>, 649 definition: Option<FileId>,
650 ) -> CrateModuleId { 650 ) -> LocalModuleId {
651 let modules = &mut self.def_collector.def_map.modules; 651 let modules = &mut self.def_collector.def_map.modules;
652 let res = modules.alloc(ModuleData::default()); 652 let res = modules.alloc(ModuleData::default());
653 modules[res].parent = Some(self.module_id); 653 modules[res].parent = Some(self.module_id);
@@ -772,7 +772,7 @@ where
772 self.def_collector.unexpanded_macros.push((self.module_id, ast_id, path)); 772 self.def_collector.unexpanded_macros.push((self.module_id, ast_id, path));
773 } 773 }
774 774
775 fn import_all_legacy_macros(&mut self, module_id: CrateModuleId) { 775 fn import_all_legacy_macros(&mut self, module_id: LocalModuleId) {
776 let macros = self.def_collector.def_map[module_id].scope.legacy_macros.clone(); 776 let macros = self.def_collector.def_map[module_id].scope.legacy_macros.clone();
777 for (name, macro_) in macros { 777 for (name, macro_) in macros {
778 self.def_collector.define_legacy_macro(self.module_id, name.clone(), macro_); 778 self.def_collector.define_legacy_macro(self.module_id, name.clone(), macro_);
@@ -827,7 +827,7 @@ mod tests {
827 827
828 let def_map = { 828 let def_map = {
829 let edition = db.crate_graph().edition(krate); 829 let edition = db.crate_graph().edition(krate);
830 let mut modules: Arena<CrateModuleId, ModuleData> = Arena::default(); 830 let mut modules: Arena<LocalModuleId, ModuleData> = Arena::default();
831 let root = modules.alloc(ModuleData::default()); 831 let root = modules.alloc(ModuleData::default());
832 CrateDefMap { 832 CrateDefMap {
833 krate, 833 krate,