Expand macros in blocks to expressions for now

Expanding to statements isn't handled properly yet and breaks things.
This commit is contained in:
Florian Diebold 2019-12-08 12:50:49 +01:00
parent 2223620313
commit 5e096def15
2 changed files with 6 additions and 5 deletions

View file

@ -437,9 +437,7 @@ where
None => self.alloc_expr(Expr::Missing, syntax_ptr), None => self.alloc_expr(Expr::Missing, syntax_ptr),
} }
} }
// FIXME expand to statements in statement position
// FIXME implement HIR for these:
ast::Expr::Label(_e) => self.alloc_expr(Expr::Missing, syntax_ptr),
ast::Expr::MacroCall(e) => match self.expander.enter_expand(self.db, e) { ast::Expr::MacroCall(e) => match self.expander.enter_expand(self.db, e) {
Some((mark, expansion)) => { Some((mark, expansion)) => {
let id = self.collect_expr(expansion); let id = self.collect_expr(expansion);
@ -448,6 +446,9 @@ where
} }
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),
} }
} }

View file

@ -183,8 +183,8 @@ fn to_fragment_kind(db: &dyn AstDatabase, macro_call_id: MacroCallId) -> Fragmen
// FIXME: Handle Pattern // FIXME: Handle Pattern
FragmentKind::Expr FragmentKind::Expr
} }
EXPR_STMT => FragmentKind::Statements, // FIXME: Expand to statements in appropriate positions; HIR lowering needs to handle that
BLOCK => FragmentKind::Statements, EXPR_STMT | BLOCK => FragmentKind::Expr,
ARG_LIST => FragmentKind::Expr, ARG_LIST => FragmentKind::Expr,
TRY_EXPR => FragmentKind::Expr, TRY_EXPR => FragmentKind::Expr,
TUPLE_EXPR => FragmentKind::Expr, TUPLE_EXPR => FragmentKind::Expr,