Skip to content

Commit 9fdd556

Browse files
committed
Fix clippy
1 parent 7a7496c commit 9fdd556

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

src/tools/clippy/clippy_lints/src/utils/author.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@ impl<'a, 'tcx> PrintVisitor<'a, 'tcx> {
322322
ConstArgKind::Struct(..) => chain!(self, "let ConstArgKind::Struct(..) = {const_arg}.kind"),
323323
ConstArgKind::TupleCall(..) => chain!(self, "let ConstArgKind::TupleCall(..) = {const_arg}.kind"),
324324
ConstArgKind::Tup(..) => chain!(self, "let ConstArgKind::Tup(..) = {const_arg}.kind"),
325+
ConstArgKind::Array(..) => chain!(self, "let ConstArgKind::Array(..) = {const_arg}.kind"),
325326
ConstArgKind::Infer(..) => chain!(self, "let ConstArgKind::Infer(..) = {const_arg}.kind"),
326327
ConstArgKind::Error(..) => chain!(self, "let ConstArgKind::Error(..) = {const_arg}.kind"),
327328
ConstArgKind::Literal(..) => chain!(self, "let ConstArgKind::Literal(..) = {const_arg}.kind")

src/tools/clippy/clippy_utils/src/consts.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1140,9 +1140,14 @@ pub fn const_item_rhs_to_expr<'tcx>(tcx: TyCtxt<'tcx>, ct_rhs: ConstItemRhs<'tcx
11401140
ConstItemRhs::Body(body_id) => Some(tcx.hir_body(body_id).value),
11411141
ConstItemRhs::TypeConst(const_arg) => match const_arg.kind {
11421142
ConstArgKind::Anon(anon) => Some(tcx.hir_body(anon.body).value),
1143-
ConstArgKind::Struct(..) | ConstArgKind::TupleCall(..) | ConstArgKind::Tup(..) | ConstArgKind::Path(_) | ConstArgKind::Error(..) | ConstArgKind::Infer(..) | ConstArgKind::Literal(..) => {
1144-
None
1145-
},
1143+
ConstArgKind::Struct(..)
1144+
| ConstArgKind::TupleCall(..)
1145+
| ConstArgKind::Tup(..)
1146+
| ConstArgKind::Path(_)
1147+
| ConstArgKind::Error(..)
1148+
| ConstArgKind::Infer(..)
1149+
| ConstArgKind::Literal(..)
1150+
| ConstArgKind::Array(..) => None,
11461151
},
11471152
}
11481153
}

src/tools/clippy/clippy_utils/src/hir_utils.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,12 @@ impl HirEqInterExpr<'_, '_, '_> {
691691
}
692692
(ConstArgKind::Literal(kind_l), ConstArgKind::Literal(kind_r)) => {
693693
kind_l == kind_r
694-
},
694+
}
695+
(ConstArgKind::Array(l_arr), ConstArgKind::Array(r_arr)) => {
696+
l_arr.elems.len() == r_arr.elems.len()
697+
&& l_arr.elems.iter().zip(r_arr.elems.iter())
698+
.all(|(l_elem, r_elem)| self.eq_const_arg(l_elem, r_elem))
699+
}
695700
// Use explicit match for now since ConstArg is undergoing flux.
696701
(
697702
ConstArgKind::Path(..)
@@ -701,6 +706,7 @@ impl HirEqInterExpr<'_, '_, '_> {
701706
| ConstArgKind::Infer(..)
702707
| ConstArgKind::Struct(..)
703708
| ConstArgKind::Literal(..)
709+
| ConstArgKind::Array(..)
704710
| ConstArgKind::Error(..),
705711
_,
706712
) => false,
@@ -1579,6 +1585,11 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
15791585
for arg in *args {
15801586
self.hash_const_arg(arg);
15811587
}
1588+
}
1589+
ConstArgKind::Array(array_expr) => {
1590+
for elem in array_expr.elems {
1591+
self.hash_const_arg(elem);
1592+
}
15821593
},
15831594
ConstArgKind::Infer(..) | ConstArgKind::Error(..) => {},
15841595
ConstArgKind::Literal(lit) => lit.hash(&mut self.s)

0 commit comments

Comments
 (0)