aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/ra_hir/src/expr/lower.rs2
-rw-r--r--crates/ra_hir/src/impl_block.rs2
-rw-r--r--crates/ra_hir/src/nameres/collector.rs4
-rw-r--r--crates/ra_hir_expand/src/lib.rs18
4 files changed, 8 insertions, 18 deletions
diff --git a/crates/ra_hir/src/expr/lower.rs b/crates/ra_hir/src/expr/lower.rs
index 24733b3de..b3a9a2e6b 100644
--- a/crates/ra_hir/src/expr/lower.rs
+++ b/crates/ra_hir/src/expr/lower.rs
@@ -465,7 +465,7 @@ where
465 465
466 if let Some(path) = e.path().and_then(|path| self.parse_path(path)) { 466 if let Some(path) = e.path().and_then(|path| self.parse_path(path)) {
467 if let Some(def) = self.resolver.resolve_path_as_macro(self.db, &path) { 467 if let Some(def) = self.resolver.resolve_path_as_macro(self.db, &path) {
468 let call_id = MacroCallLoc { def: def.id, ast_id }.id(self.db); 468 let call_id = self.db.intern_macro(MacroCallLoc { def: def.id, ast_id });
469 let file_id = call_id.as_file(MacroFileKind::Expr); 469 let file_id = call_id.as_file(MacroFileKind::Expr);
470 if let Some(node) = self.db.parse_or_expand(file_id) { 470 if let Some(node) = self.db.parse_or_expand(file_id) {
471 if let Some(expr) = ast::Expr::cast(node) { 471 if let Some(expr) = ast::Expr::cast(node) {
diff --git a/crates/ra_hir/src/impl_block.rs b/crates/ra_hir/src/impl_block.rs
index 9c739f3f1..1a5223680 100644
--- a/crates/ra_hir/src/impl_block.rs
+++ b/crates/ra_hir/src/impl_block.rs
@@ -263,7 +263,7 @@ impl ModuleImplBlocks {
263 { 263 {
264 if let Some(def) = self.module.resolver(db).resolve_path_as_macro(db, &path) 264 if let Some(def) = self.module.resolver(db).resolve_path_as_macro(db, &path)
265 { 265 {
266 let call_id = MacroCallLoc { def: def.id, ast_id }.id(db); 266 let call_id = db.intern_macro(MacroCallLoc { def: def.id, ast_id });
267 let file_id = call_id.as_file(MacroFileKind::Items); 267 let file_id = call_id.as_file(MacroFileKind::Items);
268 if let Some(item_list) = 268 if let Some(item_list) =
269 db.parse_or_expand(file_id).and_then(ast::MacroItems::cast) 269 db.parse_or_expand(file_id).and_then(ast::MacroItems::cast)
diff --git a/crates/ra_hir/src/nameres/collector.rs b/crates/ra_hir/src/nameres/collector.rs
index 885ea57a1..dc591e8d3 100644
--- a/crates/ra_hir/src/nameres/collector.rs
+++ b/crates/ra_hir/src/nameres/collector.rs
@@ -448,7 +448,7 @@ where
448 ); 448 );
449 449
450 if let Some(def) = resolved_res.resolved_def.get_macros() { 450 if let Some(def) = resolved_res.resolved_def.get_macros() {
451 let call_id = MacroCallLoc { def: def.id, ast_id: *ast_id }.id(self.db); 451 let call_id = self.db.intern_macro(MacroCallLoc { def: def.id, ast_id: *ast_id });
452 resolved.push((*module_id, call_id, def.id)); 452 resolved.push((*module_id, call_id, def.id));
453 res = ReachedFixedPoint::No; 453 res = ReachedFixedPoint::No;
454 return false; 454 return false;
@@ -690,7 +690,7 @@ where
690 self.def_collector.def_map[self.module_id].scope.get_legacy_macro(&name) 690 self.def_collector.def_map[self.module_id].scope.get_legacy_macro(&name)
691 }) { 691 }) {
692 let def = macro_def.id; 692 let def = macro_def.id;
693 let macro_call_id = MacroCallLoc { def, ast_id }.id(self.def_collector.db); 693 let macro_call_id = self.def_collector.db.intern_macro(MacroCallLoc { def, ast_id });
694 694
695 self.def_collector.collect_macro_expansion(self.module_id, macro_call_id, def); 695 self.def_collector.collect_macro_expansion(self.module_id, macro_call_id, def);
696 return; 696 return;
diff --git a/crates/ra_hir_expand/src/lib.rs b/crates/ra_hir_expand/src/lib.rs
index a31b9fa4c..9100bd15c 100644
--- a/crates/ra_hir_expand/src/lib.rs
+++ b/crates/ra_hir_expand/src/lib.rs
@@ -1,8 +1,8 @@
1//! `ra_hir_def` contains initial "phases" of the compiler. Roughly, everything 1//! `ra_hir_expand` deals with macro expansion.
2//! before types.
3//! 2//!
4//! Note that we are in the process of moving parts of `ra_hir` into 3//! Specifically, it implements a concept of `MacroFile` -- a file whose syntax
5//! `ra_hir_def`, so this crates doesn't contain a lot at the moment. 4//! tree originates not from the text of some `FileId`, but from some macro
5//! expansion.
6 6
7pub mod db; 7pub mod db;
8pub mod ast_id_map; 8pub mod ast_id_map;
@@ -116,22 +116,12 @@ pub struct MacroCallLoc {
116} 116}
117 117
118impl MacroCallId { 118impl MacroCallId {
119 pub fn loc(self, db: &impl AstDatabase) -> MacroCallLoc {
120 db.lookup_intern_macro(self)
121 }
122
123 pub fn as_file(self, kind: MacroFileKind) -> HirFileId { 119 pub fn as_file(self, kind: MacroFileKind) -> HirFileId {
124 let macro_file = MacroFile { macro_call_id: self, macro_file_kind: kind }; 120 let macro_file = MacroFile { macro_call_id: self, macro_file_kind: kind };
125 macro_file.into() 121 macro_file.into()
126 } 122 }
127} 123}
128 124
129impl MacroCallLoc {
130 pub fn id(self, db: &impl AstDatabase) -> MacroCallId {
131 db.intern_macro(self)
132 }
133}
134
135/// `AstId` points to an AST node in any file. 125/// `AstId` points to an AST node in any file.
136/// 126///
137/// It is stable across reparses, and can be used as salsa key/value. 127/// It is stable across reparses, and can be used as salsa key/value.