aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_hir/src/expr.rs11
-rw-r--r--crates/ra_hir/src/ids.rs4
2 files changed, 8 insertions, 7 deletions
diff --git a/crates/ra_hir/src/expr.rs b/crates/ra_hir/src/expr.rs
index 288f85b01..9618236e5 100644
--- a/crates/ra_hir/src/expr.rs
+++ b/crates/ra_hir/src/expr.rs
@@ -830,14 +830,11 @@ where
830 830
831 if let Some(def) = self.resolver.resolve_macro_call(path) { 831 if let Some(def) = self.resolver.resolve_macro_call(path) {
832 let call_id = MacroCallLoc { def, ast_id }.id(self.db); 832 let call_id = MacroCallLoc { def, ast_id }.id(self.db);
833 if let Some(tt) = self.db.macro_expand(call_id).ok() { 833 let file_id = call_id.as_file(MacroFileKind::Expr);
834 if let Some(expr) = mbe::token_tree_to_expr(&tt).ok() { 834 if let Some(node) = self.db.parse_or_expand(file_id) {
835 if let Some(expr) = ast::Expr::cast(&*node) {
835 log::debug!("macro expansion {}", expr.syntax().debug_dump()); 836 log::debug!("macro expansion {}", expr.syntax().debug_dump());
836 let old_file_id = std::mem::replace( 837 let old_file_id = std::mem::replace(&mut self.current_file_id, file_id);
837 &mut self.current_file_id,
838 //BUG
839 call_id.as_file(MacroFileKind::Items),
840 );
841 let id = self.collect_expr(&expr); 838 let id = self.collect_expr(&expr);
842 self.current_file_id = old_file_id; 839 self.current_file_id = old_file_id;
843 return id; 840 return id;
diff --git a/crates/ra_hir/src/ids.rs b/crates/ra_hir/src/ids.rs
index 659b21f72..f901a7432 100644
--- a/crates/ra_hir/src/ids.rs
+++ b/crates/ra_hir/src/ids.rs
@@ -81,6 +81,9 @@ impl HirFileId {
81 MacroFileKind::Items => { 81 MacroFileKind::Items => {
82 Some(mbe::token_tree_to_ast_item_list(&tt).syntax().to_owned()) 82 Some(mbe::token_tree_to_ast_item_list(&tt).syntax().to_owned())
83 } 83 }
84 MacroFileKind::Expr => {
85 mbe::token_tree_to_expr(&tt).ok().map(|it| it.syntax().to_owned())
86 }
84 } 87 }
85 } 88 }
86 } 89 }
@@ -102,6 +105,7 @@ struct MacroFile {
102#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] 105#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
103pub(crate) enum MacroFileKind { 106pub(crate) enum MacroFileKind {
104 Items, 107 Items,
108 Expr,
105} 109}
106 110
107impl From<FileId> for HirFileId { 111impl From<FileId> for HirFileId {