Skip to content

Commit

Permalink
Add associated const for the lowest precedence level
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Jul 7, 2024
1 parent 9ab3fba commit 9b76de7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1216,7 +1216,7 @@ pub(crate) mod parsing {
expr.replace_attrs(attrs);

let allow_struct = AllowStruct(true);
return parse_expr(input, expr, allow_struct, Precedence::Any);
return parse_expr(input, expr, allow_struct, Precedence::MIN);
}

if input.peek(Token![.]) && !input.peek(Token![..]) || input.peek(Token![?]) {
Expand All @@ -1226,7 +1226,7 @@ pub(crate) mod parsing {
expr.replace_attrs(attrs);

let allow_struct = AllowStruct(true);
return parse_expr(input, expr, allow_struct, Precedence::Any);
return parse_expr(input, expr, allow_struct, Precedence::MIN);
}

attrs.extend(expr.replace_attrs(Vec::new()));
Expand Down Expand Up @@ -1413,7 +1413,7 @@ pub(crate) mod parsing {
} else if input.peek(Token![as]) {
Precedence::Cast
} else {
Precedence::Any
Precedence::MIN
}
}

Expand All @@ -1432,7 +1432,7 @@ pub(crate) mod parsing {
lhs,
#[cfg(feature = "full")]
allow_struct,
Precedence::Any,
Precedence::MIN,
)
}

Expand Down Expand Up @@ -3354,7 +3354,7 @@ pub(crate) mod printing {
outer_attrs_to_tokens(&e.attrs, tokens);

let call_precedence = if let Expr::Field(_) = &*e.func {
Precedence::Any
Precedence::MIN
} else {
Precedence::Unambiguous
};
Expand Down
2 changes: 2 additions & 0 deletions src/precedence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ pub(crate) enum Precedence {
}

impl Precedence {
pub(crate) const MIN: Self = Precedence::Any;

pub(crate) fn of_binop(op: &BinOp) -> Self {
match op {
BinOp::Add(_) | BinOp::Sub(_) => Precedence::Sum,
Expand Down

0 comments on commit 9b76de7

Please sign in to comment.