From e94a62d8001b1c12b317174ae887c5d619294254 Mon Sep 17 00:00:00 2001 From: khyperia <953151+khyperia@users.noreply.github.com> Date: Fri, 6 Feb 2026 14:04:55 +0100 Subject: [PATCH] mGCA: Support directly represented negated literals --- clippy_lints/src/utils/author.rs | 2 +- clippy_utils/src/consts.rs | 2 +- clippy_utils/src/hir_utils.rs | 18 +++++++++++++++--- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/clippy_lints/src/utils/author.rs b/clippy_lints/src/utils/author.rs index e6fadc783621..d5191794b6b0 100644 --- a/clippy_lints/src/utils/author.rs +++ b/clippy_lints/src/utils/author.rs @@ -325,7 +325,7 @@ fn const_arg(&self, const_arg: &Binding<&ConstArg<'_>>) { ConstArgKind::Infer(..) => chain!(self, "let ConstArgKind::Infer(..) = {const_arg}.kind"), ConstArgKind::Error(..) => chain!(self, "let ConstArgKind::Error(..) = {const_arg}.kind"), ConstArgKind::Tup(..) => chain!(self, "let ConstArgKind::Tup(..) = {const_arg}.kind"), - ConstArgKind::Literal(..) => chain!(self, "let ConstArgKind::Literal(..) = {const_arg}.kind"), + ConstArgKind::Literal { .. } => chain!(self, "let ConstArgKind::Literal {{ .. }} = {const_arg}.kind"), } } diff --git a/clippy_utils/src/consts.rs b/clippy_utils/src/consts.rs index e2ada37d53b3..8177a5806d78 100644 --- a/clippy_utils/src/consts.rs +++ b/clippy_utils/src/consts.rs @@ -1142,7 +1142,7 @@ pub fn const_item_rhs_to_expr<'tcx>(tcx: TyCtxt<'tcx>, ct_rhs: ConstItemRhs<'tcx ConstArgKind::Anon(anon) => Some(tcx.hir_body(anon.body).value), ConstArgKind::Struct(..) | ConstArgKind::Tup(..) - | ConstArgKind::Literal(..) + | ConstArgKind::Literal { .. } | ConstArgKind::TupleCall(..) | ConstArgKind::Array(..) | ConstArgKind::Path(_) diff --git a/clippy_utils/src/hir_utils.rs b/clippy_utils/src/hir_utils.rs index b9f104a79a27..abc6885bef2d 100644 --- a/clippy_utils/src/hir_utils.rs +++ b/clippy_utils/src/hir_utils.rs @@ -686,7 +686,16 @@ fn eq_const_arg(&mut self, left: &ConstArg<'_>, right: &ConstArg<'_>) -> bool { .zip(*args_b) .all(|(arg_a, arg_b)| self.eq_const_arg(arg_a, arg_b)) }, - (ConstArgKind::Literal(kind_l), ConstArgKind::Literal(kind_r)) => kind_l == kind_r, + ( + ConstArgKind::Literal { + lit: kind_l, + negated: negated_l, + }, + ConstArgKind::Literal { + lit: kind_r, + negated: negated_r, + }, + ) => kind_l == kind_r && negated_l == negated_r, (ConstArgKind::Array(l_arr), ConstArgKind::Array(r_arr)) => { l_arr.elems.len() == r_arr.elems.len() && l_arr @@ -703,7 +712,7 @@ fn eq_const_arg(&mut self, left: &ConstArg<'_>, right: &ConstArg<'_>) -> bool { | ConstArgKind::TupleCall(..) | ConstArgKind::Infer(..) | ConstArgKind::Struct(..) - | ConstArgKind::Literal(..) + | ConstArgKind::Literal { .. } | ConstArgKind::Array(..) | ConstArgKind::Error(..), _, @@ -1599,7 +1608,10 @@ fn hash_const_arg(&mut self, const_arg: &ConstArg<'_>) { } }, ConstArgKind::Infer(..) | ConstArgKind::Error(..) => {}, - ConstArgKind::Literal(lit) => lit.hash(&mut self.s), + ConstArgKind::Literal { lit, negated } => { + lit.hash(&mut self.s); + negated.hash(&mut self.s); + }, } }