aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/nameres.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-03-26 10:09:39 +0000
committerAleksey Kladov <[email protected]>2019-03-26 10:20:54 +0000
commit5270bca5f72fa65f0515be776e06d3d6a4d1efca (patch)
treefa1b8b8ac66713ba29b676e1c2fdd4c4357f24ff /crates/ra_hir/src/nameres.rs
parentdc94f3612583c5e960b334761ad0c18d328840ea (diff)
store macro def inside macro id
This solves the problem of "macro expansion can't call into name resolution, because name resolution calls back into macro expansion" Because we store macro def as a part of call id, macro expansion just knows the def!
Diffstat (limited to 'crates/ra_hir/src/nameres.rs')
-rw-r--r--crates/ra_hir/src/nameres.rs11
1 files changed, 2 insertions, 9 deletions
diff --git a/crates/ra_hir/src/nameres.rs b/crates/ra_hir/src/nameres.rs
index c34aa4b50..93c11f271 100644
--- a/crates/ra_hir/src/nameres.rs
+++ b/crates/ra_hir/src/nameres.rs
@@ -63,7 +63,7 @@ use test_utils::tested_by;
63use crate::{ 63use crate::{
64 ModuleDef, Name, Crate, Module, 64 ModuleDef, Name, Crate, Module,
65 DefDatabase, Path, PathKind, HirFileId, Trait, 65 DefDatabase, Path, PathKind, HirFileId, Trait,
66 ids::{SourceItemId, SourceFileItemId, MacroCallId}, 66 ids::{SourceItemId, SourceFileItemId, MacroCallId, MacroDefId},
67 diagnostics::DiagnosticSink, 67 diagnostics::DiagnosticSink,
68 nameres::diagnostics::DefDiagnostic, 68 nameres::diagnostics::DefDiagnostic,
69}; 69};
@@ -85,7 +85,7 @@ pub struct CrateDefMap {
85 root: CrateModuleId, 85 root: CrateModuleId,
86 modules: Arena<CrateModuleId, ModuleData>, 86 modules: Arena<CrateModuleId, ModuleData>,
87 macros: Arena<CrateMacroId, mbe::MacroRules>, 87 macros: Arena<CrateMacroId, mbe::MacroRules>,
88 public_macros: FxHashMap<Name, CrateMacroId>, 88 public_macros: FxHashMap<Name, MacroDefId>,
89 macro_resolutions: FxHashMap<MacroCallId, (Crate, CrateMacroId)>, 89 macro_resolutions: FxHashMap<MacroCallId, (Crate, CrateMacroId)>,
90 diagnostics: Vec<DefDiagnostic>, 90 diagnostics: Vec<DefDiagnostic>,
91} 91}
@@ -238,13 +238,6 @@ impl CrateDefMap {
238 self.diagnostics.iter().for_each(|it| it.add_to(db, module, sink)) 238 self.diagnostics.iter().for_each(|it| it.add_to(db, module, sink))
239 } 239 }
240 240
241 pub(crate) fn resolve_macro(
242 &self,
243 macro_call_id: MacroCallId,
244 ) -> Option<(Crate, CrateMacroId)> {
245 self.macro_resolutions.get(&macro_call_id).map(|&it| it)
246 }
247
248 pub(crate) fn find_module_by_source( 241 pub(crate) fn find_module_by_source(
249 &self, 242 &self,
250 file_id: HirFileId, 243 file_id: HirFileId,