Remove MacCall special cases from Parser::parse_full_stmt
It is impossible for expr here to be a braced macro call. Expr comes from `parse_stmt_without_recovery`, in which macro calls are parsed by `parse_stmt_mac`. See this part: let kind = if (style == MacStmtStyle::Braces && self.token != token::Dot && self.token != token::Question) || self.token == token::Semi || self.token == token::Eof { StmtKind::MacCall(P(MacCallStmt { mac, style, attrs, tokens: None })) } else { // Since none of the above applied, this is an expression statement macro. let e = self.mk_expr(lo.to(hi), ExprKind::MacCall(mac)); let e = self.maybe_recover_from_bad_qpath(e)?; let e = self.parse_expr_dot_or_call_with(e, lo, attrs)?; let e = self.parse_expr_assoc_with( 0, LhsExpr::AlreadyParsed { expr: e, starts_statement: false }, )?; StmtKind::Expr(e) }; A braced macro call at the head of a statement is always either extended into ExprKind::Field / MethodCall / Await / Try / Binary, or else returned as StmtKind::MacCall. We can never get a StmtKind::Expr containing ExprKind::MacCall containing brace delimiter.
This commit is contained in:
parent
aedc1b6ad4
commit
53521faf06
@ -648,10 +648,8 @@ pub fn parse_full_stmt(
|
|||||||
match &mut stmt.kind {
|
match &mut stmt.kind {
|
||||||
// Expression without semicolon.
|
// Expression without semicolon.
|
||||||
StmtKind::Expr(expr)
|
StmtKind::Expr(expr)
|
||||||
if match expr.kind {
|
if classify::expr_requires_semi_to_be_stmt(expr)
|
||||||
ExprKind::MacCall(_) => true,
|
&& !expr.attrs.is_empty()
|
||||||
_ => classify::expr_requires_semi_to_be_stmt(expr),
|
|
||||||
} && !expr.attrs.is_empty()
|
|
||||||
&& ![token::Eof, token::Semi, token::CloseDelim(Delimiter::Brace)]
|
&& ![token::Eof, token::Semi, token::CloseDelim(Delimiter::Brace)]
|
||||||
.contains(&self.token.kind) =>
|
.contains(&self.token.kind) =>
|
||||||
{
|
{
|
||||||
@ -664,11 +662,7 @@ pub fn parse_full_stmt(
|
|||||||
|
|
||||||
// Expression without semicolon.
|
// Expression without semicolon.
|
||||||
StmtKind::Expr(expr)
|
StmtKind::Expr(expr)
|
||||||
if self.token != token::Eof
|
if self.token != token::Eof && classify::expr_requires_semi_to_be_stmt(expr) =>
|
||||||
&& match expr.kind {
|
|
||||||
ExprKind::MacCall(_) => true,
|
|
||||||
_ => classify::expr_requires_semi_to_be_stmt(expr),
|
|
||||||
} =>
|
|
||||||
{
|
{
|
||||||
// Just check for errors and recover; do not eat semicolon yet.
|
// Just check for errors and recover; do not eat semicolon yet.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user