diff options
Diffstat (limited to 'crates/ra_hir/src/expr.rs')
-rw-r--r-- | crates/ra_hir/src/expr.rs | 33 |
1 files changed, 14 insertions, 19 deletions
diff --git a/crates/ra_hir/src/expr.rs b/crates/ra_hir/src/expr.rs index cdadf3ba6..f9b3f5443 100644 --- a/crates/ra_hir/src/expr.rs +++ b/crates/ra_hir/src/expr.rs | |||
@@ -826,21 +826,20 @@ where | |||
826 | .with_file_id(self.current_file_id); | 826 | .with_file_id(self.current_file_id); |
827 | 827 | ||
828 | if let Some(call_id) = self.resolver.resolve_macro_call(self.db, path, ast_id) { | 828 | if let Some(call_id) = self.resolver.resolve_macro_call(self.db, path, ast_id) { |
829 | if let Some(expr) = expand_macro_to_expr(self.db, call_id, e.token_tree()) { | 829 | if let Some(arg) = self.db.macro_arg(call_id) { |
830 | log::debug!("macro expansion {}", expr.syntax().debug_dump()); | 830 | if let Some(expr) = expand_macro_to_expr(self.db, call_id, &arg) { |
831 | let old_file_id = | 831 | log::debug!("macro expansion {}", expr.syntax().debug_dump()); |
832 | std::mem::replace(&mut self.current_file_id, call_id.into()); | 832 | let old_file_id = |
833 | let id = self.collect_expr(&expr); | 833 | std::mem::replace(&mut self.current_file_id, call_id.into()); |
834 | self.current_file_id = old_file_id; | 834 | let id = self.collect_expr(&expr); |
835 | id | 835 | self.current_file_id = old_file_id; |
836 | } else { | 836 | return id; |
837 | // FIXME: Instead of just dropping the error from expansion | 837 | } |
838 | // report it | ||
839 | self.alloc_expr(Expr::Missing, syntax_ptr) | ||
840 | } | 838 | } |
841 | } else { | ||
842 | self.alloc_expr(Expr::Missing, syntax_ptr) | ||
843 | } | 839 | } |
840 | // FIXME: Instead of just dropping the error from expansion | ||
841 | // report it | ||
842 | self.alloc_expr(Expr::Missing, syntax_ptr) | ||
844 | } | 843 | } |
845 | } | 844 | } |
846 | } | 845 | } |
@@ -1002,14 +1001,10 @@ where | |||
1002 | fn expand_macro_to_expr( | 1001 | fn expand_macro_to_expr( |
1003 | db: &impl HirDatabase, | 1002 | db: &impl HirDatabase, |
1004 | macro_call: MacroCallId, | 1003 | macro_call: MacroCallId, |
1005 | args: Option<&ast::TokenTree>, | 1004 | arg: &tt::Subtree, |
1006 | ) -> Option<TreeArc<ast::Expr>> { | 1005 | ) -> Option<TreeArc<ast::Expr>> { |
1007 | let rules = db.macro_def(macro_call.loc(db).def)?; | 1006 | let rules = db.macro_def(macro_call.loc(db).def)?; |
1008 | 1007 | let expanded = rules.expand(&arg).ok()?; | |
1009 | let args = mbe::ast_to_token_tree(args?)?.0; | ||
1010 | |||
1011 | let expanded = rules.expand(&args).ok()?; | ||
1012 | |||
1013 | mbe::token_tree_to_expr(&expanded).ok() | 1008 | mbe::token_tree_to_expr(&expanded).ok() |
1014 | } | 1009 | } |
1015 | 1010 | ||