Skip to content

Commit a2b6b6b

Browse files
committed
Inline ExprPrecedence::order into Expr::precedence
1 parent 1ceaa90 commit a2b6b6b

File tree

6 files changed

+11
-11
lines changed

6 files changed

+11
-11
lines changed

clippy_lints/src/dereference.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -959,7 +959,7 @@ fn report<'tcx>(
959959
// expr_str (the suggestion) is never shown if is_final_ufcs is true, since it's
960960
// `expr.kind == ExprKind::Call`. Therefore, this is, afaik, always unnecessary.
961961
/*
962-
expr_str = if !expr_is_macro_call && is_final_ufcs && expr.precedence().order() < PREC_PREFIX {
962+
expr_str = if !expr_is_macro_call && is_final_ufcs && expr.precedence() < PREC_PREFIX {
963963
Cow::Owned(format!("({expr_str})"))
964964
} else {
965965
expr_str
@@ -999,7 +999,7 @@ fn report<'tcx>(
999999
Node::Expr(e) => match e.kind {
10001000
ExprKind::Call(callee, _) if callee.hir_id != data.first_expr.hir_id => (0, false),
10011001
ExprKind::Call(..) => (PREC_UNAMBIGUOUS, matches!(expr.kind, ExprKind::Field(..))),
1002-
_ => (e.precedence().order(), false),
1002+
_ => (e.precedence(), false),
10031003
},
10041004
_ => (0, false),
10051005
};
@@ -1012,7 +1012,7 @@ fn report<'tcx>(
10121012
);
10131013

10141014
let sugg = if !snip_is_macro
1015-
&& (calls_field || expr.precedence().order() < precedence)
1015+
&& (calls_field || expr.precedence() < precedence)
10161016
&& !has_enclosing_paren(&snip)
10171017
&& !is_in_tuple
10181018
{
@@ -1067,7 +1067,7 @@ fn report<'tcx>(
10671067
let (snip, snip_is_macro) =
10681068
snippet_with_context(cx, expr.span, data.first_expr.span.ctxt(), "..", &mut app);
10691069
let sugg =
1070-
if !snip_is_macro && expr.precedence().order() < precedence && !has_enclosing_paren(&snip) {
1070+
if !snip_is_macro && expr.precedence() < precedence && !has_enclosing_paren(&snip) {
10711071
format!("{prefix}({snip})")
10721072
} else {
10731073
format!("{prefix}{snip}")
@@ -1154,7 +1154,7 @@ impl<'tcx> Dereferencing<'tcx> {
11541154
},
11551155
Some(parent) if !parent.span.from_expansion() => {
11561156
// Double reference might be needed at this point.
1157-
if parent.precedence().order() == PREC_UNAMBIGUOUS {
1157+
if parent.precedence() == PREC_UNAMBIGUOUS {
11581158
// Parentheses would be needed here, don't lint.
11591159
*outer_pat = None;
11601160
} else {

clippy_lints/src/loops/single_element_loop.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ pub(super) fn check<'tcx>(
8484
if !prefix.is_empty()
8585
&& (
8686
// Precedence of internal expression is less than or equal to precedence of `&expr`.
87-
arg_expression.precedence().order() <= PREC_PREFIX || is_range_literal(arg_expression)
87+
arg_expression.precedence() <= PREC_PREFIX || is_range_literal(arg_expression)
8888
)
8989
{
9090
arg_snip = format!("({arg_snip})").into();

clippy_lints/src/matches/manual_utils.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ where
117117
// it's being passed by value.
118118
let scrutinee = peel_hir_expr_refs(scrutinee).0;
119119
let (scrutinee_str, _) = snippet_with_context(cx, scrutinee.span, expr_ctxt, "..", &mut app);
120-
let scrutinee_str = if scrutinee.span.eq_ctxt(expr.span) && scrutinee.precedence().order() < PREC_UNAMBIGUOUS {
120+
let scrutinee_str = if scrutinee.span.eq_ctxt(expr.span) && scrutinee.precedence() < PREC_UNAMBIGUOUS {
121121
format!("({scrutinee_str})")
122122
} else {
123123
scrutinee_str.into()

clippy_lints/src/neg_multiply.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ fn check_mul(cx: &LateContext<'_>, span: Span, lit: &Expr<'_>, exp: &Expr<'_>) {
5858
{
5959
let mut applicability = Applicability::MachineApplicable;
6060
let (snip, from_macro) = snippet_with_context(cx, exp.span, span.ctxt(), "..", &mut applicability);
61-
let suggestion = if !from_macro && exp.precedence().order() < PREC_PREFIX && !has_enclosing_paren(&snip) {
61+
let suggestion = if !from_macro && exp.precedence() < PREC_PREFIX && !has_enclosing_paren(&snip) {
6262
format!("-({snip})")
6363
} else {
6464
format!("-{snip}")

clippy_lints/src/redundant_slicing.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ impl<'tcx> LateLintPass<'tcx> for RedundantSlicing {
8585
let (expr_ty, expr_ref_count) = peel_middle_ty_refs(cx.typeck_results().expr_ty(expr));
8686
let (indexed_ty, indexed_ref_count) = peel_middle_ty_refs(cx.typeck_results().expr_ty(indexed));
8787
let parent_expr = get_parent_expr(cx, expr);
88-
let needs_parens_for_prefix = parent_expr.is_some_and(|parent| parent.precedence().order() > PREC_PREFIX);
88+
let needs_parens_for_prefix = parent_expr.is_some_and(|parent| parent.precedence() > PREC_PREFIX);
8989

9090
if expr_ty == indexed_ty {
9191
if expr_ref_count > indexed_ref_count {

clippy_lints/src/transmute/transmutes_expressible_as_ptr_casts.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use super::TRANSMUTES_EXPRESSIBLE_AS_PTR_CASTS;
22
use clippy_utils::diagnostics::span_lint_and_sugg;
33
use clippy_utils::sugg::Sugg;
4-
use rustc_ast::ExprPrecedence;
4+
use rustc_ast::util::parser::AssocOp;
55
use rustc_errors::Applicability;
66
use rustc_hir::{Expr, Node};
77
use rustc_hir_typeck::cast::check_cast;
@@ -44,7 +44,7 @@ pub(super) fn check<'tcx>(
4444
};
4545

4646
if let Node::Expr(parent) = cx.tcx.parent_hir_node(e.hir_id)
47-
&& parent.precedence().order() > ExprPrecedence::Cast.order()
47+
&& parent.precedence() > AssocOp::As.precedence() as i8
4848
{
4949
sugg = format!("({sugg})");
5050
}

0 commit comments

Comments
 (0)