diff options
-rw-r--r-- | crates/ra_hir/src/code_model.rs | 6 | ||||
-rw-r--r-- | crates/ra_hir_def/src/lib.rs | 6 | ||||
-rw-r--r-- | crates/ra_hir_def/src/nameres.rs | 32 | ||||
-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 | ||||
-rw-r--r-- | crates/ra_hir_def/src/resolver.rs | 12 |
8 files changed, 54 insertions, 54 deletions
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs index 07c56843a..2442fb6a5 100644 --- a/crates/ra_hir/src/code_model.rs +++ b/crates/ra_hir/src/code_model.rs | |||
@@ -12,7 +12,7 @@ use hir_def::{ | |||
12 | nameres::per_ns::PerNs, | 12 | nameres::per_ns::PerNs, |
13 | resolver::{HasResolver, TypeNs}, | 13 | resolver::{HasResolver, TypeNs}, |
14 | type_ref::TypeRef, | 14 | type_ref::TypeRef, |
15 | ContainerId, CrateModuleId, HasModule, ImplId, LocalEnumVariantId, LocalImportId, | 15 | ContainerId, HasModule, ImplId, LocalEnumVariantId, LocalImportId, LocalModuleId, |
16 | LocalStructFieldId, Lookup, ModuleId, UnionId, | 16 | LocalStructFieldId, Lookup, ModuleId, UnionId, |
17 | }; | 17 | }; |
18 | use hir_expand::{ | 18 | use hir_expand::{ |
@@ -112,7 +112,7 @@ impl_froms!( | |||
112 | pub use hir_def::{attr::Attrs, ModuleSource}; | 112 | pub use hir_def::{attr::Attrs, ModuleSource}; |
113 | 113 | ||
114 | impl Module { | 114 | impl Module { |
115 | pub(crate) fn new(krate: Crate, crate_module_id: CrateModuleId) -> Module { | 115 | pub(crate) fn new(krate: Crate, crate_module_id: LocalModuleId) -> Module { |
116 | Module { id: ModuleId { krate: krate.crate_id, module_id: crate_module_id } } | 116 | Module { id: ModuleId { krate: krate.crate_id, module_id: crate_module_id } } |
117 | } | 117 | } |
118 | 118 | ||
@@ -222,7 +222,7 @@ impl Module { | |||
222 | def_map[self.id.module_id].impls.iter().copied().map(ImplBlock::from).collect() | 222 | def_map[self.id.module_id].impls.iter().copied().map(ImplBlock::from).collect() |
223 | } | 223 | } |
224 | 224 | ||
225 | fn with_module_id(self, module_id: CrateModuleId) -> Module { | 225 | fn with_module_id(self, module_id: LocalModuleId) -> Module { |
226 | Module::new(self.krate(), module_id) | 226 | Module::new(self.krate(), module_id) |
227 | } | 227 | } |
228 | } | 228 | } |
diff --git a/crates/ra_hir_def/src/lib.rs b/crates/ra_hir_def/src/lib.rs index b74038b50..2cfe68701 100644 --- a/crates/ra_hir_def/src/lib.rs +++ b/crates/ra_hir_def/src/lib.rs | |||
@@ -106,14 +106,14 @@ impl_arena_id!(LocalImportId); | |||
106 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | 106 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] |
107 | pub struct ModuleId { | 107 | pub struct ModuleId { |
108 | pub krate: CrateId, | 108 | pub krate: CrateId, |
109 | pub module_id: CrateModuleId, | 109 | pub module_id: LocalModuleId, |
110 | } | 110 | } |
111 | 111 | ||
112 | /// An ID of a module, **local** to a specific crate | 112 | /// An ID of a module, **local** to a specific crate |
113 | // FIXME: rename to `LocalModuleId`. | 113 | // FIXME: rename to `LocalModuleId`. |
114 | #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] | 114 | #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] |
115 | pub struct CrateModuleId(RawId); | 115 | pub struct LocalModuleId(RawId); |
116 | impl_arena_id!(CrateModuleId); | 116 | impl_arena_id!(LocalModuleId); |
117 | 117 | ||
118 | macro_rules! impl_intern_key { | 118 | macro_rules! impl_intern_key { |
119 | ($name:ident) => { | 119 | ($name:ident) => { |
diff --git a/crates/ra_hir_def/src/nameres.rs b/crates/ra_hir_def/src/nameres.rs index 0b3b60a37..d82356bbd 100644 --- a/crates/ra_hir_def/src/nameres.rs +++ b/crates/ra_hir_def/src/nameres.rs | |||
@@ -74,7 +74,7 @@ use crate::{ | |||
74 | db::DefDatabase, | 74 | db::DefDatabase, |
75 | nameres::{diagnostics::DefDiagnostic, path_resolution::ResolveMode, per_ns::PerNs}, | 75 | nameres::{diagnostics::DefDiagnostic, path_resolution::ResolveMode, per_ns::PerNs}, |
76 | path::Path, | 76 | path::Path, |
77 | AstId, CrateModuleId, FunctionId, ImplId, LocalImportId, ModuleDefId, ModuleId, TraitId, | 77 | AstId, FunctionId, ImplId, LocalImportId, LocalModuleId, ModuleDefId, ModuleId, TraitId, |
78 | }; | 78 | }; |
79 | 79 | ||
80 | /// Contains all top-level defs from a macro-expanded crate | 80 | /// Contains all top-level defs from a macro-expanded crate |
@@ -87,8 +87,8 @@ pub struct CrateDefMap { | |||
87 | /// a dependency (`std` or `core`). | 87 | /// a dependency (`std` or `core`). |
88 | prelude: Option<ModuleId>, | 88 | prelude: Option<ModuleId>, |
89 | extern_prelude: FxHashMap<Name, ModuleDefId>, | 89 | extern_prelude: FxHashMap<Name, ModuleDefId>, |
90 | root: CrateModuleId, | 90 | root: LocalModuleId, |
91 | modules: Arena<CrateModuleId, ModuleData>, | 91 | modules: Arena<LocalModuleId, ModuleData>, |
92 | 92 | ||
93 | /// Some macros are not well-behavior, which leads to infinite loop | 93 | /// Some macros are not well-behavior, which leads to infinite loop |
94 | /// e.g. macro_rules! foo { ($ty:ty) => { foo!($ty); } } | 94 | /// e.g. macro_rules! foo { ($ty:ty) => { foo!($ty); } } |
@@ -105,17 +105,17 @@ pub struct CrateDefMap { | |||
105 | diagnostics: Vec<DefDiagnostic>, | 105 | diagnostics: Vec<DefDiagnostic>, |
106 | } | 106 | } |
107 | 107 | ||
108 | impl std::ops::Index<CrateModuleId> for CrateDefMap { | 108 | impl std::ops::Index<LocalModuleId> for CrateDefMap { |
109 | type Output = ModuleData; | 109 | type Output = ModuleData; |
110 | fn index(&self, id: CrateModuleId) -> &ModuleData { | 110 | fn index(&self, id: LocalModuleId) -> &ModuleData { |
111 | &self.modules[id] | 111 | &self.modules[id] |
112 | } | 112 | } |
113 | } | 113 | } |
114 | 114 | ||
115 | #[derive(Default, Debug, PartialEq, Eq)] | 115 | #[derive(Default, Debug, PartialEq, Eq)] |
116 | pub struct ModuleData { | 116 | pub struct ModuleData { |
117 | pub parent: Option<CrateModuleId>, | 117 | pub parent: Option<LocalModuleId>, |
118 | pub children: FxHashMap<Name, CrateModuleId>, | 118 | pub children: FxHashMap<Name, LocalModuleId>, |
119 | pub scope: ModuleScope, | 119 | pub scope: ModuleScope, |
120 | 120 | ||
121 | // FIXME: these can't be both null, we need a three-state enum here. | 121 | // FIXME: these can't be both null, we need a three-state enum here. |
@@ -225,7 +225,7 @@ impl CrateDefMap { | |||
225 | let def_map = { | 225 | let def_map = { |
226 | let crate_graph = db.crate_graph(); | 226 | let crate_graph = db.crate_graph(); |
227 | let edition = crate_graph.edition(krate); | 227 | let edition = crate_graph.edition(krate); |
228 | let mut modules: Arena<CrateModuleId, ModuleData> = Arena::default(); | 228 | let mut modules: Arena<LocalModuleId, ModuleData> = Arena::default(); |
229 | let root = modules.alloc(ModuleData::default()); | 229 | let root = modules.alloc(ModuleData::default()); |
230 | CrateDefMap { | 230 | CrateDefMap { |
231 | krate, | 231 | krate, |
@@ -246,7 +246,7 @@ impl CrateDefMap { | |||
246 | self.krate | 246 | self.krate |
247 | } | 247 | } |
248 | 248 | ||
249 | pub fn root(&self) -> CrateModuleId { | 249 | pub fn root(&self) -> LocalModuleId { |
250 | self.root | 250 | self.root |
251 | } | 251 | } |
252 | 252 | ||
@@ -261,7 +261,7 @@ impl CrateDefMap { | |||
261 | pub fn add_diagnostics( | 261 | pub fn add_diagnostics( |
262 | &self, | 262 | &self, |
263 | db: &impl DefDatabase, | 263 | db: &impl DefDatabase, |
264 | module: CrateModuleId, | 264 | module: LocalModuleId, |
265 | sink: &mut DiagnosticSink, | 265 | sink: &mut DiagnosticSink, |
266 | ) { | 266 | ) { |
267 | self.diagnostics.iter().for_each(|it| it.add_to(db, module, sink)) | 267 | self.diagnostics.iter().for_each(|it| it.add_to(db, module, sink)) |
@@ -270,18 +270,18 @@ impl CrateDefMap { | |||
270 | pub fn resolve_path( | 270 | pub fn resolve_path( |
271 | &self, | 271 | &self, |
272 | db: &impl DefDatabase, | 272 | db: &impl DefDatabase, |
273 | original_module: CrateModuleId, | 273 | original_module: LocalModuleId, |
274 | path: &Path, | 274 | path: &Path, |
275 | ) -> (PerNs, Option<usize>) { | 275 | ) -> (PerNs, Option<usize>) { |
276 | let res = self.resolve_path_fp_with_macro(db, ResolveMode::Other, original_module, path); | 276 | let res = self.resolve_path_fp_with_macro(db, ResolveMode::Other, original_module, path); |
277 | (res.resolved_def, res.segment_index) | 277 | (res.resolved_def, res.segment_index) |
278 | } | 278 | } |
279 | 279 | ||
280 | pub fn modules(&self) -> impl Iterator<Item = CrateModuleId> + '_ { | 280 | pub fn modules(&self) -> impl Iterator<Item = LocalModuleId> + '_ { |
281 | self.modules.iter().map(|(id, _data)| id) | 281 | self.modules.iter().map(|(id, _data)| id) |
282 | } | 282 | } |
283 | 283 | ||
284 | pub fn modules_for_file(&self, file_id: FileId) -> impl Iterator<Item = CrateModuleId> + '_ { | 284 | pub fn modules_for_file(&self, file_id: FileId) -> impl Iterator<Item = LocalModuleId> + '_ { |
285 | self.modules | 285 | self.modules |
286 | .iter() | 286 | .iter() |
287 | .filter(move |(_id, data)| data.definition == Some(file_id)) | 287 | .filter(move |(_id, data)| data.definition == Some(file_id)) |
@@ -317,12 +317,12 @@ mod diagnostics { | |||
317 | use ra_db::RelativePathBuf; | 317 | use ra_db::RelativePathBuf; |
318 | use ra_syntax::{ast, AstPtr}; | 318 | use ra_syntax::{ast, AstPtr}; |
319 | 319 | ||
320 | use crate::{db::DefDatabase, diagnostics::UnresolvedModule, nameres::CrateModuleId, AstId}; | 320 | use crate::{db::DefDatabase, diagnostics::UnresolvedModule, nameres::LocalModuleId, AstId}; |
321 | 321 | ||
322 | #[derive(Debug, PartialEq, Eq)] | 322 | #[derive(Debug, PartialEq, Eq)] |
323 | pub(super) enum DefDiagnostic { | 323 | pub(super) enum DefDiagnostic { |
324 | UnresolvedModule { | 324 | UnresolvedModule { |
325 | module: CrateModuleId, | 325 | module: LocalModuleId, |
326 | declaration: AstId<ast::Module>, | 326 | declaration: AstId<ast::Module>, |
327 | candidate: RelativePathBuf, | 327 | candidate: RelativePathBuf, |
328 | }, | 328 | }, |
@@ -332,7 +332,7 @@ mod diagnostics { | |||
332 | pub(super) fn add_to( | 332 | pub(super) fn add_to( |
333 | &self, | 333 | &self, |
334 | db: &impl DefDatabase, | 334 | db: &impl DefDatabase, |
335 | target_module: CrateModuleId, | 335 | target_module: LocalModuleId, |
336 | sink: &mut DiagnosticSink, | 336 | sink: &mut DiagnosticSink, |
337 | ) { | 337 | ) { |
338 | match self { | 338 | match self { |
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 { |
diff --git a/crates/ra_hir_def/src/resolver.rs b/crates/ra_hir_def/src/resolver.rs index 48a836a20..e64face7e 100644 --- a/crates/ra_hir_def/src/resolver.rs +++ b/crates/ra_hir_def/src/resolver.rs | |||
@@ -16,9 +16,9 @@ use crate::{ | |||
16 | generics::GenericParams, | 16 | generics::GenericParams, |
17 | nameres::{per_ns::PerNs, CrateDefMap}, | 17 | nameres::{per_ns::PerNs, CrateDefMap}, |
18 | path::{Path, PathKind}, | 18 | path::{Path, PathKind}, |
19 | AdtId, AstItemDef, ConstId, ContainerId, CrateModuleId, DefWithBodyId, EnumId, EnumVariantId, | 19 | AdtId, AstItemDef, ConstId, ContainerId, DefWithBodyId, EnumId, EnumVariantId, FunctionId, |
20 | FunctionId, GenericDefId, ImplId, Lookup, ModuleDefId, ModuleId, StaticId, StructId, TraitId, | 20 | GenericDefId, ImplId, LocalModuleId, Lookup, ModuleDefId, ModuleId, StaticId, StructId, |
21 | TypeAliasId, | 21 | TraitId, TypeAliasId, |
22 | }; | 22 | }; |
23 | 23 | ||
24 | #[derive(Debug, Clone, Default)] | 24 | #[derive(Debug, Clone, Default)] |
@@ -30,7 +30,7 @@ pub struct Resolver { | |||
30 | #[derive(Debug, Clone)] | 30 | #[derive(Debug, Clone)] |
31 | pub(crate) struct ModuleItemMap { | 31 | pub(crate) struct ModuleItemMap { |
32 | crate_def_map: Arc<CrateDefMap>, | 32 | crate_def_map: Arc<CrateDefMap>, |
33 | module_id: CrateModuleId, | 33 | module_id: LocalModuleId, |
34 | } | 34 | } |
35 | 35 | ||
36 | #[derive(Debug, Clone)] | 36 | #[derive(Debug, Clone)] |
@@ -330,7 +330,7 @@ impl Resolver { | |||
330 | traits | 330 | traits |
331 | } | 331 | } |
332 | 332 | ||
333 | fn module(&self) -> Option<(&CrateDefMap, CrateModuleId)> { | 333 | fn module(&self) -> Option<(&CrateDefMap, LocalModuleId)> { |
334 | self.scopes.iter().rev().find_map(|scope| match scope { | 334 | self.scopes.iter().rev().find_map(|scope| match scope { |
335 | Scope::ModuleScope(m) => Some((&*m.crate_def_map, m.module_id)), | 335 | Scope::ModuleScope(m) => Some((&*m.crate_def_map, m.module_id)), |
336 | 336 | ||
@@ -466,7 +466,7 @@ impl Resolver { | |||
466 | fn push_module_scope( | 466 | fn push_module_scope( |
467 | self, | 467 | self, |
468 | crate_def_map: Arc<CrateDefMap>, | 468 | crate_def_map: Arc<CrateDefMap>, |
469 | module_id: CrateModuleId, | 469 | module_id: LocalModuleId, |
470 | ) -> Resolver { | 470 | ) -> Resolver { |
471 | self.push_scope(Scope::ModuleScope(ModuleItemMap { crate_def_map, module_id })) | 471 | self.push_scope(Scope::ModuleScope(ModuleItemMap { crate_def_map, module_id })) |
472 | } | 472 | } |