diff options
Diffstat (limited to 'crates/ra_hir_def/src/nameres')
-rw-r--r-- | crates/ra_hir_def/src/nameres/collector.rs | 15 | ||||
-rw-r--r-- | crates/ra_hir_def/src/nameres/path_resolution.rs | 16 |
2 files changed, 15 insertions, 16 deletions
diff --git a/crates/ra_hir_def/src/nameres/collector.rs b/crates/ra_hir_def/src/nameres/collector.rs index ea3abfdae..603b49738 100644 --- a/crates/ra_hir_def/src/nameres/collector.rs +++ b/crates/ra_hir_def/src/nameres/collector.rs | |||
@@ -37,7 +37,7 @@ pub(super) fn collect_defs(db: &impl DefDatabase, mut def_map: CrateDefMap) -> C | |||
37 | log::debug!("crate dep {:?} -> {:?}", dep.name, dep.crate_id); | 37 | log::debug!("crate dep {:?} -> {:?}", dep.name, dep.crate_id); |
38 | def_map.extern_prelude.insert( | 38 | def_map.extern_prelude.insert( |
39 | dep.as_name(), | 39 | dep.as_name(), |
40 | ModuleId { krate: dep.crate_id, module_id: dep_def_map.root }.into(), | 40 | ModuleId { krate: dep.crate_id, local_id: dep_def_map.root }.into(), |
41 | ); | 41 | ); |
42 | 42 | ||
43 | // look for the prelude | 43 | // look for the prelude |
@@ -323,7 +323,7 @@ where | |||
323 | tested_by!(glob_across_crates); | 323 | tested_by!(glob_across_crates); |
324 | // glob import from other crate => we can just import everything once | 324 | // glob import from other crate => we can just import everything once |
325 | let item_map = self.db.crate_def_map(m.krate); | 325 | let item_map = self.db.crate_def_map(m.krate); |
326 | let scope = &item_map[m.module_id].scope; | 326 | let scope = &item_map[m.local_id].scope; |
327 | 327 | ||
328 | // Module scoped macros is included | 328 | // Module scoped macros is included |
329 | let items = scope | 329 | let items = scope |
@@ -337,7 +337,7 @@ where | |||
337 | // glob import from same crate => we do an initial | 337 | // glob import from same crate => we do an initial |
338 | // import, and then need to propagate any further | 338 | // import, and then need to propagate any further |
339 | // additions | 339 | // additions |
340 | let scope = &self.def_map[m.module_id].scope; | 340 | let scope = &self.def_map[m.local_id].scope; |
341 | 341 | ||
342 | // Module scoped macros is included | 342 | // Module scoped macros is included |
343 | let items = scope | 343 | let items = scope |
@@ -349,7 +349,7 @@ where | |||
349 | self.update(module_id, Some(import_id), &items); | 349 | self.update(module_id, Some(import_id), &items); |
350 | // record the glob import in case we add further items | 350 | // record the glob import in case we add further items |
351 | self.glob_imports | 351 | self.glob_imports |
352 | .entry(m.module_id) | 352 | .entry(m.local_id) |
353 | .or_default() | 353 | .or_default() |
354 | .push((module_id, import_id)); | 354 | .push((module_id, import_id)); |
355 | } | 355 | } |
@@ -590,7 +590,7 @@ where | |||
590 | raw::RawItemKind::Impl(imp) => { | 590 | raw::RawItemKind::Impl(imp) => { |
591 | let module = ModuleId { | 591 | let module = ModuleId { |
592 | krate: self.def_collector.def_map.krate, | 592 | krate: self.def_collector.def_map.krate, |
593 | module_id: self.module_id, | 593 | local_id: self.module_id, |
594 | }; | 594 | }; |
595 | let ctx = LocationCtx::new(self.def_collector.db, module, self.file_id); | 595 | let ctx = LocationCtx::new(self.def_collector.db, module, self.file_id); |
596 | let imp_id = ImplId::from_ast_id(ctx, self.raw_items[imp].ast_id); | 596 | let imp_id = ImplId::from_ast_id(ctx, self.raw_items[imp].ast_id); |
@@ -673,7 +673,7 @@ where | |||
673 | modules[self.module_id].children.insert(name.clone(), res); | 673 | modules[self.module_id].children.insert(name.clone(), res); |
674 | let resolution = Resolution { | 674 | let resolution = Resolution { |
675 | def: PerNs::types( | 675 | def: PerNs::types( |
676 | ModuleId { krate: self.def_collector.def_map.krate, module_id: res }.into(), | 676 | ModuleId { krate: self.def_collector.def_map.krate, local_id: res }.into(), |
677 | ), | 677 | ), |
678 | import: None, | 678 | import: None, |
679 | }; | 679 | }; |
@@ -682,8 +682,7 @@ where | |||
682 | } | 682 | } |
683 | 683 | ||
684 | fn define_def(&mut self, def: &raw::DefData) { | 684 | fn define_def(&mut self, def: &raw::DefData) { |
685 | let module = | 685 | let module = ModuleId { krate: self.def_collector.def_map.krate, local_id: self.module_id }; |
686 | ModuleId { krate: self.def_collector.def_map.krate, module_id: self.module_id }; | ||
687 | let ctx = LocationCtx::new(self.def_collector.db, module, self.file_id); | 686 | let ctx = LocationCtx::new(self.def_collector.db, module, self.file_id); |
688 | 687 | ||
689 | let name = def.name.clone(); | 688 | let name = def.name.clone(); |
diff --git a/crates/ra_hir_def/src/nameres/path_resolution.rs b/crates/ra_hir_def/src/nameres/path_resolution.rs index 9455f22bb..b72c55bd1 100644 --- a/crates/ra_hir_def/src/nameres/path_resolution.rs +++ b/crates/ra_hir_def/src/nameres/path_resolution.rs | |||
@@ -74,19 +74,19 @@ impl CrateDefMap { | |||
74 | PathKind::DollarCrate(krate) => { | 74 | PathKind::DollarCrate(krate) => { |
75 | if krate == self.krate { | 75 | if krate == self.krate { |
76 | tested_by!(macro_dollar_crate_self); | 76 | tested_by!(macro_dollar_crate_self); |
77 | PerNs::types(ModuleId { krate: self.krate, module_id: self.root }.into()) | 77 | PerNs::types(ModuleId { krate: self.krate, local_id: self.root }.into()) |
78 | } else { | 78 | } else { |
79 | let def_map = db.crate_def_map(krate); | 79 | let def_map = db.crate_def_map(krate); |
80 | let module = ModuleId { krate, module_id: def_map.root }; | 80 | let module = ModuleId { krate, local_id: def_map.root }; |
81 | tested_by!(macro_dollar_crate_other); | 81 | tested_by!(macro_dollar_crate_other); |
82 | PerNs::types(module.into()) | 82 | PerNs::types(module.into()) |
83 | } | 83 | } |
84 | } | 84 | } |
85 | PathKind::Crate => { | 85 | PathKind::Crate => { |
86 | PerNs::types(ModuleId { krate: self.krate, module_id: self.root }.into()) | 86 | PerNs::types(ModuleId { krate: self.krate, local_id: self.root }.into()) |
87 | } | 87 | } |
88 | PathKind::Self_ => { | 88 | PathKind::Self_ => { |
89 | PerNs::types(ModuleId { krate: self.krate, module_id: original_module }.into()) | 89 | PerNs::types(ModuleId { krate: self.krate, local_id: original_module }.into()) |
90 | } | 90 | } |
91 | // plain import or absolute path in 2015: crate-relative with | 91 | // plain import or absolute path in 2015: crate-relative with |
92 | // fallback to extern prelude (with the simplification in | 92 | // fallback to extern prelude (with the simplification in |
@@ -113,7 +113,7 @@ impl CrateDefMap { | |||
113 | } | 113 | } |
114 | PathKind::Super => { | 114 | PathKind::Super => { |
115 | if let Some(p) = self.modules[original_module].parent { | 115 | if let Some(p) = self.modules[original_module].parent { |
116 | PerNs::types(ModuleId { krate: self.krate, module_id: p }.into()) | 116 | PerNs::types(ModuleId { krate: self.krate, local_id: p }.into()) |
117 | } else { | 117 | } else { |
118 | log::debug!("super path in root module"); | 118 | log::debug!("super path in root module"); |
119 | return ResolvePathResult::empty(ReachedFixedPoint::Yes); | 119 | return ResolvePathResult::empty(ReachedFixedPoint::Yes); |
@@ -160,7 +160,7 @@ impl CrateDefMap { | |||
160 | Path { segments: path.segments[i..].to_vec(), kind: PathKind::Self_ }; | 160 | Path { segments: path.segments[i..].to_vec(), kind: PathKind::Self_ }; |
161 | log::debug!("resolving {:?} in other crate", path); | 161 | log::debug!("resolving {:?} in other crate", path); |
162 | let defp_map = db.crate_def_map(module.krate); | 162 | let defp_map = db.crate_def_map(module.krate); |
163 | let (def, s) = defp_map.resolve_path(db, module.module_id, &path); | 163 | let (def, s) = defp_map.resolve_path(db, module.local_id, &path); |
164 | return ResolvePathResult::with( | 164 | return ResolvePathResult::with( |
165 | def, | 165 | def, |
166 | ReachedFixedPoint::Yes, | 166 | ReachedFixedPoint::Yes, |
@@ -169,7 +169,7 @@ impl CrateDefMap { | |||
169 | } | 169 | } |
170 | 170 | ||
171 | // Since it is a qualified path here, it should not contains legacy macros | 171 | // Since it is a qualified path here, it should not contains legacy macros |
172 | match self[module.module_id].scope.get(&segment.name) { | 172 | match self[module.local_id].scope.get(&segment.name) { |
173 | Some(res) => res.def, | 173 | Some(res) => res.def, |
174 | _ => { | 174 | _ => { |
175 | log::debug!("path segment {:?} not found", segment.name); | 175 | log::debug!("path segment {:?} not found", segment.name); |
@@ -254,7 +254,7 @@ impl CrateDefMap { | |||
254 | keep = db.crate_def_map(prelude.krate); | 254 | keep = db.crate_def_map(prelude.krate); |
255 | &keep | 255 | &keep |
256 | }; | 256 | }; |
257 | def_map[prelude.module_id].scope.get(name).map_or_else(PerNs::none, |res| res.def) | 257 | def_map[prelude.local_id].scope.get(name).map_or_else(PerNs::none, |res| res.def) |
258 | } else { | 258 | } else { |
259 | PerNs::none() | 259 | PerNs::none() |
260 | } | 260 | } |