diff options
Diffstat (limited to 'crates/ra_hir_def/src/nameres')
-rw-r--r-- | crates/ra_hir_def/src/nameres/collector.rs | 40 | ||||
-rw-r--r-- | crates/ra_hir_def/src/nameres/path_resolution.rs | 6 | ||||
-rw-r--r-- | crates/ra_hir_def/src/nameres/tests.rs | 4 | ||||
-rw-r--r-- | crates/ra_hir_def/src/nameres/tests/mod_resolution.rs | 2 |
4 files changed, 26 insertions, 26 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 | ||
27 | pub(super) fn collect_defs(db: &impl DefDatabase, mut def_map: CrateDefMap) -> CrateDefMap { | 27 | pub(super) fn collect_defs(db: &impl DefDatabase, mut def_map: CrateDefMap) -> CrateDefMap { |
@@ -94,10 +94,10 @@ impl MacroStackMonitor { | |||
94 | struct DefCollector<'a, DB> { | 94 | struct 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 |
523 | struct ModCollector<'a, D> { | 523 | struct 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, |
diff --git a/crates/ra_hir_def/src/nameres/path_resolution.rs b/crates/ra_hir_def/src/nameres/path_resolution.rs index 102009ac7..93b441f96 100644 --- a/crates/ra_hir_def/src/nameres/path_resolution.rs +++ b/crates/ra_hir_def/src/nameres/path_resolution.rs | |||
@@ -18,7 +18,7 @@ use crate::{ | |||
18 | db::DefDatabase, | 18 | db::DefDatabase, |
19 | nameres::{per_ns::PerNs, CrateDefMap}, | 19 | nameres::{per_ns::PerNs, CrateDefMap}, |
20 | path::{Path, PathKind}, | 20 | path::{Path, PathKind}, |
21 | AdtId, CrateModuleId, EnumVariantId, ModuleDefId, ModuleId, | 21 | AdtId, EnumVariantId, LocalModuleId, ModuleDefId, ModuleId, |
22 | }; | 22 | }; |
23 | 23 | ||
24 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] | 24 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] |
@@ -65,7 +65,7 @@ impl CrateDefMap { | |||
65 | &self, | 65 | &self, |
66 | db: &impl DefDatabase, | 66 | db: &impl DefDatabase, |
67 | mode: ResolveMode, | 67 | mode: ResolveMode, |
68 | original_module: CrateModuleId, | 68 | original_module: LocalModuleId, |
69 | path: &Path, | 69 | path: &Path, |
70 | ) -> ResolvePathResult { | 70 | ) -> ResolvePathResult { |
71 | let mut segments = path.segments.iter().enumerate(); | 71 | let mut segments = path.segments.iter().enumerate(); |
@@ -217,7 +217,7 @@ impl CrateDefMap { | |||
217 | fn resolve_name_in_module( | 217 | fn resolve_name_in_module( |
218 | &self, | 218 | &self, |
219 | db: &impl DefDatabase, | 219 | db: &impl DefDatabase, |
220 | module: CrateModuleId, | 220 | module: LocalModuleId, |
221 | name: &Name, | 221 | name: &Name, |
222 | ) -> PerNs { | 222 | ) -> PerNs { |
223 | // Resolve in: | 223 | // Resolve in: |
diff --git a/crates/ra_hir_def/src/nameres/tests.rs b/crates/ra_hir_def/src/nameres/tests.rs index b5053ba20..f0b86af7c 100644 --- a/crates/ra_hir_def/src/nameres/tests.rs +++ b/crates/ra_hir_def/src/nameres/tests.rs | |||
@@ -10,7 +10,7 @@ use insta::assert_snapshot; | |||
10 | use ra_db::{fixture::WithFixture, SourceDatabase}; | 10 | use ra_db::{fixture::WithFixture, SourceDatabase}; |
11 | use test_utils::covers; | 11 | use test_utils::covers; |
12 | 12 | ||
13 | use crate::{db::DefDatabase, nameres::*, test_db::TestDB, CrateModuleId}; | 13 | use crate::{db::DefDatabase, nameres::*, test_db::TestDB, LocalModuleId}; |
14 | 14 | ||
15 | fn def_map(fixtute: &str) -> String { | 15 | fn def_map(fixtute: &str) -> String { |
16 | let dm = compute_crate_def_map(fixtute); | 16 | let dm = compute_crate_def_map(fixtute); |
@@ -28,7 +28,7 @@ fn render_crate_def_map(map: &CrateDefMap) -> String { | |||
28 | go(&mut buf, map, "\ncrate", map.root()); | 28 | go(&mut buf, map, "\ncrate", map.root()); |
29 | return buf.trim().to_string(); | 29 | return buf.trim().to_string(); |
30 | 30 | ||
31 | fn go(buf: &mut String, map: &CrateDefMap, path: &str, module: CrateModuleId) { | 31 | fn go(buf: &mut String, map: &CrateDefMap, path: &str, module: LocalModuleId) { |
32 | *buf += path; | 32 | *buf += path; |
33 | *buf += "\n"; | 33 | *buf += "\n"; |
34 | 34 | ||
diff --git a/crates/ra_hir_def/src/nameres/tests/mod_resolution.rs b/crates/ra_hir_def/src/nameres/tests/mod_resolution.rs index eb7b85c07..e11530062 100644 --- a/crates/ra_hir_def/src/nameres/tests/mod_resolution.rs +++ b/crates/ra_hir_def/src/nameres/tests/mod_resolution.rs | |||
@@ -665,7 +665,7 @@ fn unresolved_module_diagnostics() { | |||
665 | @r###" | 665 | @r###" |
666 | [ | 666 | [ |
667 | UnresolvedModule { | 667 | UnresolvedModule { |
668 | module: CrateModuleId( | 668 | module: LocalModuleId( |
669 | 0, | 669 | 0, |
670 | ), | 670 | ), |
671 | declaration: AstId { | 671 | declaration: AstId { |