From 12cc2ed5572e4df8cfbdaef79ed3c865fda0764c Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Mon, 23 Dec 2019 21:47:11 +0800 Subject: Use pre-stored macro file --- crates/ra_hir_def/src/body/lower.rs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'crates/ra_hir_def/src/body') diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs index 5323af097..57c77304c 100644 --- a/crates/ra_hir_def/src/body/lower.rs +++ b/crates/ra_hir_def/src/body/lower.rs @@ -446,14 +446,20 @@ where } } // FIXME expand to statements in statement position - ast::Expr::MacroCall(e) => match self.expander.enter_expand(self.db, e) { - Some((mark, expansion)) => { - let id = self.collect_expr(expansion); - self.expander.exit(self.db, mark); - id + ast::Expr::MacroCall(e) => { + let macro_call = self.expander.to_source(AstPtr::new(&e)); + match self.expander.enter_expand(self.db, e.clone()) { + Some((mark, expansion)) => { + self.source_map + .expansions + .insert(macro_call, self.expander.current_file_id); + let id = self.collect_expr(expansion); + self.expander.exit(self.db, mark); + id + } + None => self.alloc_expr(Expr::Missing, syntax_ptr), } - None => self.alloc_expr(Expr::Missing, syntax_ptr), - }, + } // FIXME implement HIR for these: ast::Expr::Label(_e) => self.alloc_expr(Expr::Missing, syntax_ptr), -- cgit v1.2.3