aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/nameres
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-10-30 09:27:54 +0000
committerAleksey Kladov <[email protected]>2019-10-30 09:27:54 +0000
commita136cc0653d2b4133fb6387009cfdbaf3e2cf275 (patch)
treec7693867220abfefd90acb9965d91c6fe0023d38 /crates/ra_hir/src/nameres
parent56bc874f1d14922686b26afc8793b7e57a652990 (diff)
introduce ra_hir_def
Diffstat (limited to 'crates/ra_hir/src/nameres')
-rw-r--r--crates/ra_hir/src/nameres/collector.rs23
1 files changed, 11 insertions, 12 deletions
diff --git a/crates/ra_hir/src/nameres/collector.rs b/crates/ra_hir/src/nameres/collector.rs
index dc591e8d3..dd5f9d4ba 100644
--- a/crates/ra_hir/src/nameres/collector.rs
+++ b/crates/ra_hir/src/nameres/collector.rs
@@ -212,7 +212,7 @@ where
212 212
213 if let Some(ModuleDef::Module(m)) = res.take_types() { 213 if let Some(ModuleDef::Module(m)) = res.take_types() {
214 tested_by!(macro_rules_from_other_crates_are_visible_with_macro_use); 214 tested_by!(macro_rules_from_other_crates_are_visible_with_macro_use);
215 self.import_all_macros_exported(current_module_id, m.krate); 215 self.import_all_macros_exported(current_module_id, m.krate());
216 } 216 }
217 } 217 }
218 218
@@ -289,11 +289,11 @@ where
289 if import.is_prelude { 289 if import.is_prelude {
290 tested_by!(std_prelude); 290 tested_by!(std_prelude);
291 self.def_map.prelude = Some(m); 291 self.def_map.prelude = Some(m);
292 } else if m.krate != self.def_map.krate { 292 } else if m.krate() != self.def_map.krate {
293 tested_by!(glob_across_crates); 293 tested_by!(glob_across_crates);
294 // glob import from other crate => we can just import everything once 294 // glob import from other crate => we can just import everything once
295 let item_map = self.db.crate_def_map(m.krate); 295 let item_map = self.db.crate_def_map(m.krate());
296 let scope = &item_map[m.module_id].scope; 296 let scope = &item_map[m.id.module_id].scope;
297 297
298 // Module scoped macros is included 298 // Module scoped macros is included
299 let items = scope 299 let items = scope
@@ -307,7 +307,7 @@ where
307 // glob import from same crate => we do an initial 307 // glob import from same crate => we do an initial
308 // import, and then need to propagate any further 308 // import, and then need to propagate any further
309 // additions 309 // additions
310 let scope = &self.def_map[m.module_id].scope; 310 let scope = &self.def_map[m.id.module_id].scope;
311 311
312 // Module scoped macros is included 312 // Module scoped macros is included
313 let items = scope 313 let items = scope
@@ -319,7 +319,7 @@ where
319 self.update(module_id, Some(import_id), &items); 319 self.update(module_id, Some(import_id), &items);
320 // record the glob import in case we add further items 320 // record the glob import in case we add further items
321 self.glob_imports 321 self.glob_imports
322 .entry(m.module_id) 322 .entry(m.id.module_id)
323 .or_default() 323 .or_default()
324 .push((module_id, import_id)); 324 .push((module_id, import_id));
325 } 325 }
@@ -523,9 +523,10 @@ where
523 523
524 // Prelude module is always considered to be `#[macro_use]`. 524 // Prelude module is always considered to be `#[macro_use]`.
525 if let Some(prelude_module) = self.def_collector.def_map.prelude { 525 if let Some(prelude_module) = self.def_collector.def_map.prelude {
526 if prelude_module.krate != self.def_collector.def_map.krate { 526 if prelude_module.krate() != self.def_collector.def_map.krate {
527 tested_by!(prelude_is_macro_use); 527 tested_by!(prelude_is_macro_use);
528 self.def_collector.import_all_macros_exported(self.module_id, prelude_module.krate); 528 self.def_collector
529 .import_all_macros_exported(self.module_id, prelude_module.krate());
529 } 530 }
530 } 531 }
531 532
@@ -631,9 +632,7 @@ where
631 modules[res].scope.legacy_macros = modules[self.module_id].scope.legacy_macros.clone(); 632 modules[res].scope.legacy_macros = modules[self.module_id].scope.legacy_macros.clone();
632 modules[self.module_id].children.insert(name.clone(), res); 633 modules[self.module_id].children.insert(name.clone(), res);
633 let resolution = Resolution { 634 let resolution = Resolution {
634 def: PerNs::types( 635 def: PerNs::types(Module::new(self.def_collector.def_map.krate, res).into()),
635 Module { krate: self.def_collector.def_map.krate, module_id: res }.into(),
636 ),
637 import: None, 636 import: None,
638 }; 637 };
639 self.def_collector.update(self.module_id, None, &[(name, resolution)]); 638 self.def_collector.update(self.module_id, None, &[(name, resolution)]);
@@ -641,7 +640,7 @@ where
641 } 640 }
642 641
643 fn define_def(&mut self, def: &raw::DefData) { 642 fn define_def(&mut self, def: &raw::DefData) {
644 let module = Module { krate: self.def_collector.def_map.krate, module_id: self.module_id }; 643 let module = Module::new(self.def_collector.def_map.krate, self.module_id);
645 let ctx = LocationCtx::new(self.def_collector.db, module, self.file_id); 644 let ctx = LocationCtx::new(self.def_collector.db, module, self.file_id);
646 645
647 macro_rules! def { 646 macro_rules! def {