1
Fork 0

Eliminate precedence arithmetic from rustc_parse

This commit is contained in:
David Tolnay 2024-11-28 14:03:16 -08:00
parent ca8f47439e
commit 539c863eaf
No known key found for this signature in database
GPG key ID: F9BA143B95FF6D82
3 changed files with 26 additions and 17 deletions

View file

@ -1,5 +1,6 @@
use std::borrow::Cow;
use std::mem;
use std::ops::Bound;
use ast::Label;
use rustc_ast as ast;
@ -207,7 +208,7 @@ impl<'a> Parser<'a> {
// Perform this outside of the `collect_tokens` closure, since our
// outer attributes do not apply to this part of the expression.
let (expr, _) = self.with_res(Restrictions::STMT_EXPR, |this| {
this.parse_expr_assoc_rest_with(0, true, expr)
this.parse_expr_assoc_rest_with(Bound::Unbounded, true, expr)
})?;
Ok(self.mk_stmt(lo.to(self.prev_token.span), StmtKind::Expr(expr)))
} else {
@ -240,7 +241,7 @@ impl<'a> Parser<'a> {
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(attrs, e, lo)?;
let (e, _) = self.parse_expr_assoc_rest_with(0, false, e)?;
let (e, _) = self.parse_expr_assoc_rest_with(Bound::Unbounded, false, e)?;
StmtKind::Expr(e)
};
Ok(self.mk_stmt(lo.to(hi), kind))