diff options
Diffstat (limited to 'crates/ra_hir_def/src/body/lower.rs')
-rw-r--r-- | crates/ra_hir_def/src/body/lower.rs | 32 |
1 files changed, 7 insertions, 25 deletions
diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs index 29c1ec2a1..c45500195 100644 --- a/crates/ra_hir_def/src/body/lower.rs +++ b/crates/ra_hir_def/src/body/lower.rs | |||
@@ -3,7 +3,6 @@ | |||
3 | use hir_expand::{ | 3 | use hir_expand::{ |
4 | either::Either, | 4 | either::Either, |
5 | name::{self, AsName, Name}, | 5 | name::{self, AsName, Name}, |
6 | AstId, MacroCallLoc, MacroFileKind, | ||
7 | }; | 6 | }; |
8 | use ra_arena::Arena; | 7 | use ra_arena::Arena; |
9 | use ra_syntax::{ | 8 | use ra_syntax::{ |
@@ -433,31 +432,14 @@ where | |||
433 | // FIXME implement HIR for these: | 432 | // FIXME implement HIR for these: |
434 | ast::Expr::Label(_e) => self.alloc_expr(Expr::Missing, syntax_ptr), | 433 | ast::Expr::Label(_e) => self.alloc_expr(Expr::Missing, syntax_ptr), |
435 | ast::Expr::RangeExpr(_e) => self.alloc_expr(Expr::Missing, syntax_ptr), | 434 | ast::Expr::RangeExpr(_e) => self.alloc_expr(Expr::Missing, syntax_ptr), |
436 | ast::Expr::MacroCall(e) => { | 435 | ast::Expr::MacroCall(e) => match self.expander.expand(self.db, e) { |
437 | let ast_id = AstId::new( | 436 | Some((mark, expansion)) => { |
438 | self.expander.current_file_id, | 437 | let id = self.collect_expr(expansion); |
439 | self.db.ast_id_map(self.expander.current_file_id).ast_id(&e), | 438 | self.expander.exit(self.db, mark); |
440 | ); | 439 | id |
441 | |||
442 | if let Some(path) = e.path().and_then(|path| self.expander.parse_path(path)) { | ||
443 | if let Some(def) = self.expander.resolve_path_as_macro(self.db, &path) { | ||
444 | let call_id = self.db.intern_macro(MacroCallLoc { def, ast_id }); | ||
445 | let file_id = call_id.as_file(MacroFileKind::Expr); | ||
446 | if let Some(node) = self.db.parse_or_expand(file_id) { | ||
447 | if let Some(expr) = ast::Expr::cast(node) { | ||
448 | log::debug!("macro expansion {:#?}", expr.syntax()); | ||
449 | let mark = self.expander.enter(self.db, file_id); | ||
450 | let id = self.collect_expr(expr); | ||
451 | self.expander.exit(self.db, mark); | ||
452 | return id; | ||
453 | } | ||
454 | } | ||
455 | } | ||
456 | } | 440 | } |
457 | // FIXME: Instead of just dropping the error from expansion | 441 | None => self.alloc_expr(Expr::Missing, syntax_ptr), |
458 | // report it | 442 | }, |
459 | self.alloc_expr(Expr::Missing, syntax_ptr) | ||
460 | } | ||
461 | } | 443 | } |
462 | } | 444 | } |
463 | 445 | ||