diff options
-rw-r--r-- | crates/ra_hir_def/src/body.rs | 15 | ||||
-rw-r--r-- | crates/ra_hir_def/src/body/lower.rs | 2 |
2 files changed, 7 insertions, 10 deletions
diff --git a/crates/ra_hir_def/src/body.rs b/crates/ra_hir_def/src/body.rs index 75bba31c2..bff17fd62 100644 --- a/crates/ra_hir_def/src/body.rs +++ b/crates/ra_hir_def/src/body.rs | |||
@@ -33,7 +33,7 @@ impl Expander { | |||
33 | Expander { crate_def_map, current_file_id, hygiene, module } | 33 | Expander { crate_def_map, current_file_id, hygiene, module } |
34 | } | 34 | } |
35 | 35 | ||
36 | fn expand( | 36 | fn enter_expand( |
37 | &mut self, | 37 | &mut self, |
38 | db: &impl DefDatabase2, | 38 | db: &impl DefDatabase2, |
39 | macro_call: ast::MacroCall, | 39 | macro_call: ast::MacroCall, |
@@ -50,7 +50,11 @@ impl Expander { | |||
50 | if let Some(node) = db.parse_or_expand(file_id) { | 50 | if let Some(node) = db.parse_or_expand(file_id) { |
51 | if let Some(expr) = ast::Expr::cast(node) { | 51 | if let Some(expr) = ast::Expr::cast(node) { |
52 | log::debug!("macro expansion {:#?}", expr.syntax()); | 52 | log::debug!("macro expansion {:#?}", expr.syntax()); |
53 | let mark = self.enter(db, file_id); | 53 | |
54 | let mark = Mark { file_id: self.current_file_id }; | ||
55 | self.hygiene = Hygiene::new(db, file_id); | ||
56 | self.current_file_id = file_id; | ||
57 | |||
54 | return Some((mark, expr)); | 58 | return Some((mark, expr)); |
55 | } | 59 | } |
56 | } | 60 | } |
@@ -62,13 +66,6 @@ impl Expander { | |||
62 | None | 66 | None |
63 | } | 67 | } |
64 | 68 | ||
65 | fn enter(&mut self, db: &impl DefDatabase2, file_id: HirFileId) -> Mark { | ||
66 | let mark = Mark { file_id: self.current_file_id }; | ||
67 | self.hygiene = Hygiene::new(db, file_id); | ||
68 | self.current_file_id = file_id; | ||
69 | mark | ||
70 | } | ||
71 | |||
72 | fn exit(&mut self, db: &impl DefDatabase2, mark: Mark) { | 69 | fn exit(&mut self, db: &impl DefDatabase2, mark: Mark) { |
73 | self.hygiene = Hygiene::new(db, mark.file_id); | 70 | self.hygiene = Hygiene::new(db, mark.file_id); |
74 | self.current_file_id = mark.file_id; | 71 | self.current_file_id = mark.file_id; |
diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs index f6d79ddf0..a5bb60e85 100644 --- a/crates/ra_hir_def/src/body/lower.rs +++ b/crates/ra_hir_def/src/body/lower.rs | |||
@@ -430,7 +430,7 @@ where | |||
430 | // FIXME implement HIR for these: | 430 | // FIXME implement HIR for these: |
431 | ast::Expr::Label(_e) => self.alloc_expr(Expr::Missing, syntax_ptr), | 431 | ast::Expr::Label(_e) => self.alloc_expr(Expr::Missing, syntax_ptr), |
432 | ast::Expr::RangeExpr(_e) => self.alloc_expr(Expr::Missing, syntax_ptr), | 432 | ast::Expr::RangeExpr(_e) => self.alloc_expr(Expr::Missing, syntax_ptr), |
433 | ast::Expr::MacroCall(e) => match self.expander.expand(self.db, e) { | 433 | ast::Expr::MacroCall(e) => match self.expander.enter_expand(self.db, e) { |
434 | Some((mark, expansion)) => { | 434 | Some((mark, expansion)) => { |
435 | let id = self.collect_expr(expansion); | 435 | let id = self.collect_expr(expansion); |
436 | self.expander.exit(self.db, mark); | 436 | self.expander.exit(self.db, mark); |