2238: Slightly better naming r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
bors[bot] 2019-11-14 08:34:26 +00:00 committed by GitHub
commit 267f194c28
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 10 deletions

View file

@ -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;

View file

@ -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);