Skip to content

Commit 3caf0bc

Browse files
committed
Accept m!{ .. }.method() and m!{ .. }? statements.
1 parent fbdff7f commit 3caf0bc

File tree

1 file changed

+14
-11
lines changed
  • compiler/rustc_parse/src/parser

1 file changed

+14
-11
lines changed

compiler/rustc_parse/src/parser/stmt.rs

+14-11
Original file line numberDiff line numberDiff line change
@@ -155,17 +155,20 @@ impl<'a> Parser<'a> {
155155

156156
let mac = MacCall { path, args, prior_type_ascription: self.last_type_ascription };
157157

158-
let kind = if delim == token::Brace || self.token == token::Semi || self.token == token::Eof
159-
{
160-
StmtKind::MacCall(P(MacCallStmt { mac, style, attrs, tokens: None }))
161-
} else {
162-
// Since none of the above applied, this is an expression statement macro.
163-
let e = self.mk_expr(lo.to(hi), ExprKind::MacCall(mac), AttrVec::new());
164-
let e = self.maybe_recover_from_bad_qpath(e, true)?;
165-
let e = self.parse_dot_or_call_expr_with(e, lo, attrs.into())?;
166-
let e = self.parse_assoc_expr_with(0, LhsExpr::AlreadyParsed(e))?;
167-
StmtKind::Expr(e)
168-
};
158+
let kind =
159+
if (delim == token::Brace && self.token != token::Dot && self.token != token::Question)
160+
|| self.token == token::Semi
161+
|| self.token == token::Eof
162+
{
163+
StmtKind::MacCall(P(MacCallStmt { mac, style, attrs, tokens: None }))
164+
} else {
165+
// Since none of the above applied, this is an expression statement macro.
166+
let e = self.mk_expr(lo.to(hi), ExprKind::MacCall(mac), AttrVec::new());
167+
let e = self.maybe_recover_from_bad_qpath(e, true)?;
168+
let e = self.parse_dot_or_call_expr_with(e, lo, attrs.into())?;
169+
let e = self.parse_assoc_expr_with(0, LhsExpr::AlreadyParsed(e))?;
170+
StmtKind::Expr(e)
171+
};
169172
Ok(self.mk_stmt(lo.to(hi), kind))
170173
}
171174

0 commit comments

Comments
 (0)