Skip to content

Commit 330358a

Browse files
committed
Further Clippy fixes for Tup/Literal ConstArgKind
1 parent d283798 commit 330358a

2 files changed

Lines changed: 6 additions & 18 deletions

File tree

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,6 +1142,7 @@ pub fn const_item_rhs_to_expr<'tcx>(tcx: TyCtxt<'tcx>, ct_rhs: ConstItemRhs<'tcx
11421142
ConstArgKind::Anon(anon) => Some(tcx.hir_body(anon.body).value),
11431143
ConstArgKind::Struct(..)
11441144
| ConstArgKind::Tup(..)
1145+
| ConstArgKind::Literal(..)
11451146
| ConstArgKind::TupleCall(..)
11461147
| ConstArgKind::Path(_)
11471148
| ConstArgKind::Error(..)

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

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -666,8 +666,9 @@ impl HirEqInterExpr<'_, '_, '_> {
666666
}
667667

668668
match (&left.kind, &right.kind) {
669-
(ConstArgKind::Tup(l_t), ConstArgKind::Tup(r_t)) =>
670-
l_t.len() == r_t.len() && l_t.iter().zip(*r_t).all(|(l_c, r_c)| self.eq_const_arg(*l_c, *r_c)),
669+
(ConstArgKind::Tup(l_t), ConstArgKind::Tup(r_t)) => {
670+
l_t.len() == r_t.len() && l_t.iter().zip(*r_t).all(|(l_c, r_c)| self.eq_const_arg(*l_c, *r_c))
671+
},
671672
(ConstArgKind::Path(l_p), ConstArgKind::Path(r_p)) => self.eq_qpath(l_p, r_p),
672673
(ConstArgKind::Anon(l_an), ConstArgKind::Anon(r_an)) => self.eq_body(l_an.body, r_an.body),
673674
(ConstArgKind::Infer(..), ConstArgKind::Infer(..)) => true,
@@ -684,23 +685,14 @@ impl HirEqInterExpr<'_, '_, '_> {
684685
.iter()
685686
.zip(*args_b)
686687
.all(|(arg_a, arg_b)| self.eq_const_arg(arg_a, arg_b))
687-
}
688-
(ConstArgKind::Tup(args_a), ConstArgKind::Tup(args_b)) => {
689-
args_a
690-
.iter()
691-
.zip(*args_b)
692-
.all(|(arg_a, arg_b)| self.eq_const_arg(arg_a, arg_b))
693-
},
694-
(ConstArgKind::Literal(kind_l), ConstArgKind::Literal(kind_r)) => {
695-
kind_l == kind_r
696688
},
689+
(ConstArgKind::Literal(kind_l), ConstArgKind::Literal(kind_r)) => kind_l == kind_r,
697690
// Use explicit match for now since ConstArg is undergoing flux.
698691
(
699692
ConstArgKind::Path(..)
700693
| ConstArgKind::Tup(..)
701694
| ConstArgKind::Anon(..)
702695
| ConstArgKind::TupleCall(..)
703-
| ConstArgKind::Tup(..)
704696
| ConstArgKind::Infer(..)
705697
| ConstArgKind::Struct(..)
706698
| ConstArgKind::Literal(..)
@@ -1583,13 +1575,8 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
15831575
self.hash_const_arg(arg);
15841576
}
15851577
},
1586-
ConstArgKind::Tup(args) => {
1587-
for arg in *args {
1588-
self.hash_const_arg(arg);
1589-
}
1590-
},
15911578
ConstArgKind::Infer(..) | ConstArgKind::Error(..) => {},
1592-
ConstArgKind::Literal(lit) => lit.hash(&mut self.s)
1579+
ConstArgKind::Literal(lit) => lit.hash(&mut self.s),
15931580
}
15941581
}
15951582

0 commit comments

Comments
 (0)