mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
Make Clippy compile with ConstArgKind::Tup()
This commit is contained in:
committed by
Philipp Krones
parent
d9c168546f
commit
a3690a2d25
@@ -1,4 +1,3 @@
|
||||
use rustc_ast::AttrItemKind;
|
||||
use clippy_config::Conf;
|
||||
use clippy_utils::diagnostics::span_lint_and_then;
|
||||
use clippy_utils::macros::root_macro_call_first_node;
|
||||
|
||||
@@ -323,6 +323,7 @@ fn const_arg(&self, const_arg: &Binding<&ConstArg<'_>>) {
|
||||
ConstArgKind::TupleCall(..) => chain!(self, "let ConstArgKind::TupleCall(..) = {const_arg}.kind"),
|
||||
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")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1141,6 +1141,7 @@ pub fn const_item_rhs_to_expr<'tcx>(tcx: TyCtxt<'tcx>, ct_rhs: ConstItemRhs<'tcx
|
||||
ConstItemRhs::TypeConst(const_arg) => match const_arg.kind {
|
||||
ConstArgKind::Anon(anon) => Some(tcx.hir_body(anon.body).value),
|
||||
ConstArgKind::Struct(..)
|
||||
| ConstArgKind::Tup(..)
|
||||
| ConstArgKind::TupleCall(..)
|
||||
| ConstArgKind::Path(_)
|
||||
| ConstArgKind::Error(..)
|
||||
|
||||
@@ -666,6 +666,8 @@ fn eq_const_arg(&mut self, left: &ConstArg<'_>, right: &ConstArg<'_>) -> bool {
|
||||
}
|
||||
|
||||
match (&left.kind, &right.kind) {
|
||||
(ConstArgKind::Tup(l_t), ConstArgKind::Tup(r_t)) =>
|
||||
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)),
|
||||
(ConstArgKind::Path(l_p), ConstArgKind::Path(r_p)) => self.eq_qpath(l_p, r_p),
|
||||
(ConstArgKind::Anon(l_an), ConstArgKind::Anon(r_an)) => self.eq_body(l_an.body, r_an.body),
|
||||
(ConstArgKind::Infer(..), ConstArgKind::Infer(..)) => true,
|
||||
@@ -695,6 +697,7 @@ fn eq_const_arg(&mut self, left: &ConstArg<'_>, right: &ConstArg<'_>) -> bool {
|
||||
// Use explicit match for now since ConstArg is undergoing flux.
|
||||
(
|
||||
ConstArgKind::Path(..)
|
||||
| ConstArgKind::Tup(..)
|
||||
| ConstArgKind::Anon(..)
|
||||
| ConstArgKind::TupleCall(..)
|
||||
| ConstArgKind::Tup(..)
|
||||
@@ -1561,6 +1564,11 @@ pub fn hash_body(&mut self, body_id: BodyId) {
|
||||
|
||||
fn hash_const_arg(&mut self, const_arg: &ConstArg<'_>) {
|
||||
match &const_arg.kind {
|
||||
ConstArgKind::Tup(tup) => {
|
||||
for arg in *tup {
|
||||
self.hash_const_arg(*arg);
|
||||
}
|
||||
},
|
||||
ConstArgKind::Path(path) => self.hash_qpath(path),
|
||||
ConstArgKind::Anon(anon) => self.hash_body(anon.body),
|
||||
ConstArgKind::Struct(path, inits) => {
|
||||
|
||||
Reference in New Issue
Block a user