Eliminate magic numbers from expression precedence

This commit is contained in:
David Tolnay 2024-11-28 12:47:18 -08:00
parent 539c863eaf
commit 7ced18f329
No known key found for this signature in database
GPG key ID: F9BA143B95FF6D82
18 changed files with 162 additions and 138 deletions

View file

@ -10,7 +10,7 @@ use rustc_ast::ptr::P;
use rustc_ast::token::{self, Delimiter, Token, TokenKind};
use rustc_ast::util::case::Case;
use rustc_ast::util::classify;
use rustc_ast::util::parser::{AssocOp, Fixity, prec_let_scrutinee_needs_par};
use rustc_ast::util::parser::{AssocOp, ExprPrecedence, Fixity, prec_let_scrutinee_needs_par};
use rustc_ast::visit::{Visitor, walk_expr};
use rustc_ast::{
self as ast, AnonConst, Arm, AttrStyle, AttrVec, BinOp, BinOpKind, BlockCheckMode, CaptureBy,
@ -128,7 +128,7 @@ impl<'a> Parser<'a> {
/// followed by a subexpression (e.g. `1 + 2`).
pub(super) fn parse_expr_assoc_with(
&mut self,
min_prec: Bound<usize>,
min_prec: Bound<ExprPrecedence>,
attrs: AttrWrapper,
) -> PResult<'a, (P<Expr>, bool)> {
let lhs = if self.token.is_range_separator() {
@ -144,7 +144,7 @@ impl<'a> Parser<'a> {
/// was actually parsed.
pub(super) fn parse_expr_assoc_rest_with(
&mut self,
min_prec: Bound<usize>,
min_prec: Bound<ExprPrecedence>,
starts_stmt: bool,
mut lhs: P<Expr>,
) -> PResult<'a, (P<Expr>, bool)> {
@ -455,7 +455,7 @@ impl<'a> Parser<'a> {
/// The other two variants are handled in `parse_prefix_range_expr` below.
fn parse_expr_range(
&mut self,
prec: usize,
prec: ExprPrecedence,
lhs: P<Expr>,
op: AssocOp,
cur_op_span: Span,