aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/expr.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-06-08 18:42:02 +0100
committerAleksey Kladov <[email protected]>2019-06-08 18:42:02 +0100
commitcaefa6982bc57195687de11137997f1d62d791fe (patch)
tree4cdbfe1ae67d0eae6ba85b19cf40126898f43ac5 /crates/ra_hir/src/expr.rs
parent780e1a365b10027c4bd4adcc939ab32da1d91492 (diff)
remove some hacks from nameresolution for macros
Diffstat (limited to 'crates/ra_hir/src/expr.rs')
-rw-r--r--crates/ra_hir/src/expr.rs26
1 files changed, 13 insertions, 13 deletions
diff --git a/crates/ra_hir/src/expr.rs b/crates/ra_hir/src/expr.rs
index 9d9769859..012f374ec 100644
--- a/crates/ra_hir/src/expr.rs
+++ b/crates/ra_hir/src/expr.rs
@@ -827,25 +827,25 @@ where
827 ast::ExprKind::IndexExpr(_e) => self.alloc_expr(Expr::Missing, syntax_ptr), 827 ast::ExprKind::IndexExpr(_e) => self.alloc_expr(Expr::Missing, syntax_ptr),
828 ast::ExprKind::RangeExpr(_e) => self.alloc_expr(Expr::Missing, syntax_ptr), 828 ast::ExprKind::RangeExpr(_e) => self.alloc_expr(Expr::Missing, syntax_ptr),
829 ast::ExprKind::MacroCall(e) => { 829 ast::ExprKind::MacroCall(e) => {
830 // very hacky.FIXME change to use the macro resolution
831 let path = e.path().and_then(Path::from_ast);
832
833 let ast_id = self 830 let ast_id = self
834 .db 831 .db
835 .ast_id_map(self.current_file_id) 832 .ast_id_map(self.current_file_id)
836 .ast_id(e) 833 .ast_id(e)
837 .with_file_id(self.current_file_id); 834 .with_file_id(self.current_file_id);
838 835
839 if let Some(def) = self.resolver.resolve_macro_call(self.db, path) { 836 if let Some(path) = e.path().and_then(Path::from_ast) {
840 let call_id = MacroCallLoc { def, ast_id }.id(self.db); 837 if let Some(def) = self.resolver.resolve_path_as_macro(self.db, &path) {
841 let file_id = call_id.as_file(MacroFileKind::Expr); 838 let call_id = MacroCallLoc { def: def.id, ast_id }.id(self.db);
842 if let Some(node) = self.db.parse_or_expand(file_id) { 839 let file_id = call_id.as_file(MacroFileKind::Expr);
843 if let Some(expr) = ast::Expr::cast(&*node) { 840 if let Some(node) = self.db.parse_or_expand(file_id) {
844 log::debug!("macro expansion {}", expr.syntax().debug_dump()); 841 if let Some(expr) = ast::Expr::cast(&*node) {
845 let old_file_id = std::mem::replace(&mut self.current_file_id, file_id); 842 log::debug!("macro expansion {}", expr.syntax().debug_dump());
846 let id = self.collect_expr(&expr); 843 let old_file_id =
847 self.current_file_id = old_file_id; 844 std::mem::replace(&mut self.current_file_id, file_id);
848 return id; 845 let id = self.collect_expr(&expr);
846 self.current_file_id = old_file_id;
847 return id;
848 }
849 } 849 }
850 } 850 }
851 } 851 }