1
Fork 0

Accept m!{ .. }.method() and m!{ .. }? statements.

This commit is contained in:
Mara Bos 2021-09-06 18:12:55 +02:00
parent fbdff7fae9
commit 3caf0bcdeb

View file

@ -155,17 +155,20 @@ impl<'a> Parser<'a> {
let mac = MacCall { path, args, prior_type_ascription: self.last_type_ascription }; let mac = MacCall { path, args, prior_type_ascription: self.last_type_ascription };
let kind = if delim == token::Brace || self.token == token::Semi || self.token == token::Eof let kind =
{ if (delim == token::Brace && self.token != token::Dot && self.token != token::Question)
StmtKind::MacCall(P(MacCallStmt { mac, style, attrs, tokens: None })) || self.token == token::Semi
} else { || self.token == token::Eof
// Since none of the above applied, this is an expression statement macro. {
let e = self.mk_expr(lo.to(hi), ExprKind::MacCall(mac), AttrVec::new()); StmtKind::MacCall(P(MacCallStmt { mac, style, attrs, tokens: None }))
let e = self.maybe_recover_from_bad_qpath(e, true)?; } else {
let e = self.parse_dot_or_call_expr_with(e, lo, attrs.into())?; // Since none of the above applied, this is an expression statement macro.
let e = self.parse_assoc_expr_with(0, LhsExpr::AlreadyParsed(e))?; let e = self.mk_expr(lo.to(hi), ExprKind::MacCall(mac), AttrVec::new());
StmtKind::Expr(e) let e = self.maybe_recover_from_bad_qpath(e, true)?;
}; let e = self.parse_dot_or_call_expr_with(e, lo, attrs.into())?;
let e = self.parse_assoc_expr_with(0, LhsExpr::AlreadyParsed(e))?;
StmtKind::Expr(e)
};
Ok(self.mk_stmt(lo.to(hi), kind)) Ok(self.mk_stmt(lo.to(hi), kind))
} }