From 4efd345b09ca6e06fc0580d91a6c13f30b6b7f23 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 14 Nov 2019 11:33:18 +0300 Subject: [PATCH] Slightly better naming --- crates/ra_hir_def/src/body.rs | 15 ++++++--------- 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 75bba31c21..bff17fd62a 100644 --- a/crates/ra_hir_def/src/body.rs +++ b/crates/ra_hir_def/src/body.rs @@ -33,7 +33,7 @@ impl Expander { Expander { crate_def_map, current_file_id, hygiene, module } } - fn expand( + fn enter_expand( &mut self, db: &impl DefDatabase2, macro_call: ast::MacroCall, @@ -50,7 +50,11 @@ impl Expander { if let Some(node) = db.parse_or_expand(file_id) { if let Some(expr) = ast::Expr::cast(node) { log::debug!("macro expansion {:#?}", expr.syntax()); - let mark = self.enter(db, file_id); + + let mark = Mark { file_id: self.current_file_id }; + self.hygiene = Hygiene::new(db, file_id); + self.current_file_id = file_id; + return Some((mark, expr)); } } @@ -62,13 +66,6 @@ impl Expander { None } - fn enter(&mut self, db: &impl DefDatabase2, file_id: HirFileId) -> Mark { - let mark = Mark { file_id: self.current_file_id }; - self.hygiene = Hygiene::new(db, file_id); - self.current_file_id = file_id; - mark - } - fn exit(&mut self, db: &impl DefDatabase2, mark: Mark) { self.hygiene = Hygiene::new(db, mark.file_id); 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 f6d79ddf05..a5bb60e857 100644 --- a/crates/ra_hir_def/src/body/lower.rs +++ b/crates/ra_hir_def/src/body/lower.rs @@ -430,7 +430,7 @@ where // FIXME implement HIR for these: ast::Expr::Label(_e) => self.alloc_expr(Expr::Missing, syntax_ptr), ast::Expr::RangeExpr(_e) => self.alloc_expr(Expr::Missing, syntax_ptr), - ast::Expr::MacroCall(e) => match self.expander.expand(self.db, e) { + 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);