Skip to content

Commit 880343c

Browse files
committed
update clippy
1 parent 1245131 commit 880343c

File tree

6 files changed

+18
-19
lines changed

6 files changed

+18
-19
lines changed

src/tools/clippy/clippy_lints/src/functions/must_use.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ fn is_mutable_ty<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>, span: Span, tys: &m
193193
|| KNOWN_WRAPPER_TYS.iter().any(|path| match_def_path(cx, adt.did, path))
194194
&& substs.types().any(|ty| is_mutable_ty(cx, ty, span, tys))
195195
},
196-
ty::Tuple(substs) => substs.types().any(|ty| is_mutable_ty(cx, ty, span, tys)),
196+
ty::Tuple(substs) => substs.iter().any(|ty| is_mutable_ty(cx, ty, span, tys)),
197197
ty::Array(ty, _) | ty::Slice(ty) => is_mutable_ty(cx, ty, span, tys),
198198
ty::RawPtr(ty::TypeAndMut { ty, mutbl }) | ty::Ref(_, ty, mutbl) => {
199199
mutbl == hir::Mutability::Mut || is_mutable_ty(cx, ty, span, tys)

src/tools/clippy/clippy_lints/src/matches/redundant_pattern_match.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ fn type_needs_ordered_drop_inner<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>, see
5858
// This type doesn't implement drop, so no side effects here.
5959
// Check if any component type has any.
6060
match ty.kind() {
61-
ty::Tuple(_) => ty.tuple_fields().any(|ty| type_needs_ordered_drop_inner(cx, ty, seen)),
62-
ty::Array(ty, _) => type_needs_ordered_drop_inner(cx, *ty, seen),
61+
ty::Tuple(fields) => fields.iter().any(|ty| type_needs_ordered_drop_inner(cx, ty, seen)),
62+
&ty::Array(ty, _) => type_needs_ordered_drop_inner(cx, ty, seen),
6363
ty::Adt(adt, subs) => adt
6464
.all_fields()
6565
.map(|f| f.ty(cx.tcx, subs))

src/tools/clippy/clippy_lints/src/mut_key.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ fn is_interior_mutable_type<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>, span: Sp
142142
size.try_eval_usize(cx.tcx, cx.param_env).map_or(true, |u| u != 0)
143143
&& is_interior_mutable_type(cx, inner_ty, span)
144144
},
145-
Tuple(..) => ty.tuple_fields().any(|ty| is_interior_mutable_type(cx, ty, span)),
145+
Tuple(fields) => fields.iter().any(|ty| is_interior_mutable_type(cx, ty, span)),
146146
Adt(def, substs) => {
147147
// Special case for collections in `std` who's impl of `Hash` or `Ord` delegates to
148148
// that of their type parameters. Note: we don't include `HashSet` and `HashMap`

src/tools/clippy/clippy_lints/src/non_send_fields_in_send_ty.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,8 @@ fn ty_allowed_with_raw_pointer_heuristic<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'t
202202

203203
// The type is known to be `!Send` and `!Copy`
204204
match ty.kind() {
205-
ty::Tuple(_) => ty
206-
.tuple_fields()
205+
ty::Tuple(fields) => fields
206+
.iter()
207207
.all(|ty| ty_allowed_with_raw_pointer_heuristic(cx, ty, send_trait)),
208208
ty::Array(ty, _) | ty::Slice(ty) => ty_allowed_with_raw_pointer_heuristic(cx, *ty, send_trait),
209209
ty::Adt(_, substs) => {

src/tools/clippy/clippy_lints/src/transmute/transmute_undefined_repr.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use super::TRANSMUTE_UNDEFINED_REPR;
22
use clippy_utils::diagnostics::span_lint_and_then;
33
use rustc_hir::Expr;
44
use rustc_lint::LateContext;
5-
use rustc_middle::ty::subst::{GenericArg, Subst};
5+
use rustc_middle::ty::subst::Subst;
66
use rustc_middle::ty::{self, Ty, TypeAndMut};
77
use rustc_span::Span;
88

@@ -246,11 +246,10 @@ fn reduce_ty<'tcx>(cx: &LateContext<'tcx>, mut ty: Ty<'tcx>) -> ReducedTy<'tcx>
246246
continue;
247247
},
248248
ty::Tuple(args) => {
249-
let mut iter = args.iter().map(GenericArg::expect_ty);
250-
let Some(sized_ty) = iter.find(|ty| !is_zero_sized_ty(cx, *ty)) else {
249+
let Some(sized_ty) = args.iter().find(|&ty| !is_zero_sized_ty(cx, ty)) else {
251250
return ReducedTy::OrderedFields(ty);
252251
};
253-
if iter.all(|ty| is_zero_sized_ty(cx, ty)) {
252+
if args.iter().all(|ty| is_zero_sized_ty(cx, ty)) {
254253
ty = sized_ty;
255254
continue;
256255
}

src/tools/clippy/clippy_utils/src/ty.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ pub fn is_must_use_ty<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> bool {
169169
// because we don't want to lint functions returning empty arrays
170170
is_must_use_ty(cx, *ty)
171171
},
172-
ty::Tuple(substs) => substs.types().any(|ty| is_must_use_ty(cx, ty)),
172+
ty::Tuple(substs) => substs.iter().any(|ty| is_must_use_ty(cx, ty)),
173173
ty::Opaque(ref def_id, _) => {
174174
for (predicate, _) in cx.tcx.explicit_item_bounds(*def_id) {
175175
if let ty::PredicateKind::Trait(trait_predicate) = predicate.kind().skip_binder() {
@@ -249,11 +249,11 @@ pub fn is_non_aggregate_primitive_type(ty: Ty<'_>) -> bool {
249249
/// Returns `true` if the given type is a primitive (a `bool` or `char`, any integer or
250250
/// floating-point number type, a `str`, or an array, slice, or tuple of those types).
251251
pub fn is_recursively_primitive_type(ty: Ty<'_>) -> bool {
252-
match ty.kind() {
252+
match *ty.kind() {
253253
ty::Bool | ty::Char | ty::Int(_) | ty::Uint(_) | ty::Float(_) | ty::Str => true,
254254
ty::Ref(_, inner, _) if *inner.kind() == ty::Str => true,
255-
ty::Array(inner_type, _) | ty::Slice(inner_type) => is_recursively_primitive_type(*inner_type),
256-
ty::Tuple(inner_types) => inner_types.types().all(is_recursively_primitive_type),
255+
ty::Array(inner_type, _) | ty::Slice(inner_type) => is_recursively_primitive_type(inner_type),
256+
ty::Tuple(inner_types) => inner_types.iter().all(is_recursively_primitive_type),
257257
_ => false,
258258
}
259259
}
@@ -393,9 +393,9 @@ pub fn same_type_and_consts<'tcx>(a: Ty<'tcx>, b: Ty<'tcx>) -> bool {
393393

394394
/// Checks if a given type looks safe to be uninitialized.
395395
pub fn is_uninit_value_valid_for_ty(cx: &LateContext<'_>, ty: Ty<'_>) -> bool {
396-
match ty.kind() {
397-
ty::Array(component, _) => is_uninit_value_valid_for_ty(cx, *component),
398-
ty::Tuple(types) => types.types().all(|ty| is_uninit_value_valid_for_ty(cx, ty)),
396+
match *ty.kind() {
397+
ty::Array(component, _) => is_uninit_value_valid_for_ty(cx, component),
398+
ty::Tuple(types) => types.iter().all(|ty| is_uninit_value_valid_for_ty(cx, ty)),
399399
ty::Adt(adt, _) => cx.tcx.lang_items().maybe_uninit() == Some(adt.did),
400400
_ => false,
401401
}
@@ -426,8 +426,8 @@ impl<'tcx> ExprFnSig<'tcx> {
426426
pub fn input(self, i: usize) -> Binder<'tcx, Ty<'tcx>> {
427427
match self {
428428
Self::Sig(sig) => sig.input(i),
429-
Self::Closure(sig) => sig.input(0).map_bound(|ty| ty.tuple_element_ty(i).unwrap()),
430-
Self::Trait(inputs, _) => inputs.map_bound(|ty| ty.tuple_element_ty(i).unwrap()),
429+
Self::Closure(sig) => sig.input(0).map_bound(|ty| ty.tuple_fields()[i]),
430+
Self::Trait(inputs, _) => inputs.map_bound(|ty| ty.tuple_fields()[i]),
431431
}
432432
}
433433

0 commit comments

Comments
 (0)