Skip to content

Commit 327967c

Browse files
Rename unpack to kind
1 parent ce0adf0 commit 327967c

22 files changed

+32
-32
lines changed

clippy_lints/src/arc_with_non_send_sync.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ impl<'tcx> LateLintPass<'tcx> for ArcWithNonSendSync {
5050
&& let arg_ty = cx.typeck_results().expr_ty(arg)
5151
// make sure that the type is not and does not contain any type parameters
5252
&& arg_ty.walk().all(|arg| {
53-
!matches!(arg.unpack(), GenericArgKind::Type(ty) if matches!(ty.kind(), ty::Param(_)))
53+
!matches!(arg.kind(), GenericArgKind::Type(ty) if matches!(ty.kind(), ty::Param(_)))
5454
})
5555
&& let Some(send) = cx.tcx.get_diagnostic_item(sym::Send)
5656
&& let Some(sync) = cx.tcx.lang_items().sync_trait()

clippy_lints/src/derive.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ fn check_copy_clone<'tcx>(cx: &LateContext<'tcx>, item: &Item<'_>, trait_ref: &h
345345
if ty_adt.repr().packed()
346346
&& ty_subs
347347
.iter()
348-
.any(|arg| matches!(arg.unpack(), GenericArgKind::Type(_) | GenericArgKind::Const(_)))
348+
.any(|arg| matches!(arg.kind(), GenericArgKind::Type(_) | GenericArgKind::Const(_)))
349349
{
350350
return;
351351
}

clippy_lints/src/eta_reduction.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ fn has_late_bound_to_non_late_bound_regions(from_sig: FnSig<'_>, to_sig: FnSig<'
306306
return true;
307307
}
308308
for (from_arg, to_arg) in to_subs.iter().zip(from_subs) {
309-
match (from_arg.unpack(), to_arg.unpack()) {
309+
match (from_arg.kind(), to_arg.kind()) {
310310
(GenericArgKind::Lifetime(from_region), GenericArgKind::Lifetime(to_region)) => {
311311
if check_region(from_region, to_region) {
312312
return true;
@@ -354,5 +354,5 @@ fn has_late_bound_to_non_late_bound_regions(from_sig: FnSig<'_>, to_sig: FnSig<'
354354

355355
fn ty_has_static(ty: Ty<'_>) -> bool {
356356
ty.walk()
357-
.any(|arg| matches!(arg.unpack(), GenericArgKind::Lifetime(re) if re.is_static()))
357+
.any(|arg| matches!(arg.kind(), GenericArgKind::Lifetime(re) if re.is_static()))
358358
}

clippy_lints/src/functions/ref_option.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ fn check_ty<'a>(cx: &LateContext<'a>, param: &rustc_hir::Ty<'a>, param_ty: Ty<'a
1717
&& is_type_diagnostic_item(cx, *opt_ty, sym::Option)
1818
&& let ty::Adt(_, opt_gen_args) = opt_ty.kind()
1919
&& let [gen_arg] = opt_gen_args.as_slice()
20-
&& let GenericArgKind::Type(gen_ty) = gen_arg.unpack()
20+
&& let GenericArgKind::Type(gen_ty) = gen_arg.kind()
2121
&& !gen_ty.is_ref()
2222
// Need to gen the original spans, so first parsing mid, and hir parsing afterward
2323
&& let hir::TyKind::Ref(lifetime, hir::MutTy { ty, .. }) = param.kind

clippy_lints/src/let_underscore.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ impl<'tcx> LateLintPass<'tcx> for LetUnderscore {
137137
&& !local.span.in_external_macro(cx.tcx.sess.source_map())
138138
{
139139
let init_ty = cx.typeck_results().expr_ty(init);
140-
let contains_sync_guard = init_ty.walk().any(|inner| match inner.unpack() {
140+
let contains_sync_guard = init_ty.walk().any(|inner| match inner.kind() {
141141
GenericArgKind::Type(inner_ty) => inner_ty
142142
.ty_adt_def()
143143
.is_some_and(|adt| paths::PARKING_LOT_GUARDS.iter().any(|path| path.matches(cx, adt.did()))),

clippy_lints/src/matches/manual_unwrap_or.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ fn handle(
109109
&& implements_trait(cx, expr_type, default_trait_id, &[])
110110
// We check if the initial condition implements Default.
111111
&& let Some(condition_ty) = cx.typeck_results().expr_ty(condition).walk().nth(1)
112-
&& let GenericArgKind::Type(condition_ty) = condition_ty.unpack()
112+
&& let GenericArgKind::Type(condition_ty) = condition_ty.kind()
113113
&& implements_trait(cx, condition_ty, default_trait_id, &[])
114114
&& is_default_equivalent(cx, peel_blocks(body_none))
115115
{

clippy_lints/src/matches/redundant_pattern_match.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ fn find_match_true<'tcx>(
108108
fn try_get_generic_ty(ty: Ty<'_>, index: usize) -> Option<Ty<'_>> {
109109
if let ty::Adt(_, subs) = ty.kind()
110110
&& let Some(sub) = subs.get(index)
111-
&& let GenericArgKind::Type(sub_ty) = sub.unpack()
111+
&& let GenericArgKind::Type(sub_ty) = sub.kind()
112112
{
113113
Some(sub_ty)
114114
} else {

clippy_lints/src/matches/significant_drop_in_scrutinee.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,12 +208,12 @@ impl<'a, 'tcx> SigDropChecker<'a, 'tcx> {
208208
// (to avoid false positive on `Ref<'a, MutexGuard<Foo>>`)
209209
|| (args
210210
.iter()
211-
.all(|arg| !matches!(arg.unpack(), GenericArgKind::Lifetime(_)))
211+
.all(|arg| !matches!(arg.kind(), GenericArgKind::Lifetime(_)))
212212
// some generic parameter has significant drop
213213
// (to avoid false negative on `Box<MutexGuard<Foo>>`)
214214
&& args
215215
.iter()
216-
.filter_map(|arg| match arg.unpack() {
216+
.filter_map(|arg| match arg.kind() {
217217
GenericArgKind::Type(ty) => Some(ty),
218218
_ => None,
219219
})

clippy_lints/src/methods/needless_collect.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ fn get_captured_ids(cx: &LateContext<'_>, ty: Ty<'_>) -> HirIdSet {
508508
match ty.kind() {
509509
ty::Adt(_, generics) => {
510510
for generic in *generics {
511-
if let GenericArgKind::Type(ty) = generic.unpack() {
511+
if let GenericArgKind::Type(ty) = generic.kind() {
512512
get_captured_ids_recursive(cx, ty, set);
513513
}
514514
}

clippy_lints/src/methods/unnecessary_sort_by.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ fn detect_lint(cx: &LateContext<'_>, expr: &Expr<'_>, recv: &Expr<'_>, arg: &Exp
188188

189189
fn expr_borrows(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
190190
let ty = cx.typeck_results().expr_ty(expr);
191-
matches!(ty.kind(), ty::Ref(..)) || ty.walk().any(|arg| matches!(arg.unpack(), GenericArgKind::Lifetime(_)))
191+
matches!(ty.kind(), ty::Ref(..)) || ty.walk().any(|arg| matches!(arg.kind(), GenericArgKind::Lifetime(_)))
192192
}
193193

194194
pub(super) fn check<'tcx>(

clippy_lints/src/methods/unnecessary_to_owned.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ fn can_change_type<'a>(cx: &LateContext<'a>, mut expr: &'a Expr<'a>, mut ty: Ty<
608608
}
609609

610610
fn has_lifetime(ty: Ty<'_>) -> bool {
611-
ty.walk().any(|t| matches!(t.unpack(), GenericArgKind::Lifetime(_)))
611+
ty.walk().any(|t| matches!(t.kind(), GenericArgKind::Lifetime(_)))
612612
}
613613

614614
/// Returns true if the named method is `Iterator::cloned` or `Iterator::copied`.
@@ -643,7 +643,7 @@ fn is_to_string_on_string_like<'a>(
643643

644644
if let Some(args) = cx.typeck_results().node_args_opt(call_expr.hir_id)
645645
&& let [generic_arg] = args.as_slice()
646-
&& let GenericArgKind::Type(ty) = generic_arg.unpack()
646+
&& let GenericArgKind::Type(ty) = generic_arg.kind()
647647
&& let Some(deref_trait_id) = cx.tcx.get_diagnostic_item(sym::Deref)
648648
&& let Some(as_ref_trait_id) = cx.tcx.get_diagnostic_item(sym::AsRef)
649649
&& (cx.get_associated_type(ty, deref_trait_id, sym::Target) == Some(cx.tcx.types.str_)

clippy_lints/src/needless_borrows_for_generic_args.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ fn needless_borrow_count<'tcx>(
269269
.tcx
270270
.is_diagnostic_item(sym::IntoIterator, trait_predicate.trait_ref.def_id)
271271
&& let ty::Param(param_ty) = trait_predicate.self_ty().kind()
272-
&& let GenericArgKind::Type(ty) = args_with_referent_ty[param_ty.index as usize].unpack()
272+
&& let GenericArgKind::Type(ty) = args_with_referent_ty[param_ty.index as usize].kind()
273273
&& ty.is_array()
274274
&& !msrv.meets(cx, msrvs::ARRAY_INTO_ITERATOR)
275275
{

clippy_lints/src/non_send_fields_in_send_ty.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ impl NonSendField<'_> {
172172
/// Example: `MyStruct<P, Box<Q, R>>` => `vec![P, Q, R]`
173173
fn collect_generic_params(ty: Ty<'_>) -> Vec<Ty<'_>> {
174174
ty.walk()
175-
.filter_map(|inner| match inner.unpack() {
175+
.filter_map(|inner| match inner.kind() {
176176
GenericArgKind::Type(inner_ty) => Some(inner_ty),
177177
_ => None,
178178
})
@@ -208,7 +208,7 @@ fn ty_allowed_with_raw_pointer_heuristic<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'t
208208
ty::Adt(_, args) => {
209209
if contains_pointer_like(cx, ty) {
210210
// descends only if ADT contains any raw pointers
211-
args.iter().all(|generic_arg| match generic_arg.unpack() {
211+
args.iter().all(|generic_arg| match generic_arg.kind() {
212212
GenericArgKind::Type(ty) => ty_allowed_with_raw_pointer_heuristic(cx, ty, send_trait),
213213
// Lifetimes and const generics are not solid part of ADT and ignored
214214
GenericArgKind::Lifetime(_) | GenericArgKind::Const(_) => true,
@@ -226,7 +226,7 @@ fn ty_allowed_with_raw_pointer_heuristic<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'t
226226
/// Checks if the type contains any pointer-like types in args (including nested ones)
227227
fn contains_pointer_like<'tcx>(cx: &LateContext<'tcx>, target_ty: Ty<'tcx>) -> bool {
228228
for ty_node in target_ty.walk() {
229-
if let GenericArgKind::Type(inner_ty) = ty_node.unpack() {
229+
if let GenericArgKind::Type(inner_ty) = ty_node.kind() {
230230
match inner_ty.kind() {
231231
ty::RawPtr(_, _) => {
232232
return true;

clippy_lints/src/only_used_in_recursion.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ impl<'tcx> LateLintPass<'tcx> for OnlyUsedInRecursion {
385385
fn has_matching_args(kind: FnKind, args: GenericArgsRef<'_>) -> bool {
386386
match kind {
387387
FnKind::Fn => true,
388-
FnKind::TraitFn => args.iter().enumerate().all(|(idx, subst)| match subst.unpack() {
388+
FnKind::TraitFn => args.iter().enumerate().all(|(idx, subst)| match subst.kind() {
389389
GenericArgKind::Lifetime(_) => true,
390390
GenericArgKind::Type(ty) => matches!(*ty.kind(), ty::Param(ty) if ty.index as usize == idx),
391391
GenericArgKind::Const(c) => matches!(c.kind(), ConstKind::Param(c) if c.index as usize == idx),

clippy_lints/src/returns.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ fn last_statement_borrows<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>)
487487
.skip_binder()
488488
.output()
489489
.walk()
490-
.any(|arg| matches!(arg.unpack(), GenericArgKind::Lifetime(re) if !re.is_static()))
490+
.any(|arg| matches!(arg.kind(), GenericArgKind::Lifetime(re) if !re.is_static()))
491491
{
492492
ControlFlow::Break(())
493493
} else {

clippy_lints/src/significant_drop_tightening.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ impl<'cx, 'others, 'tcx> AttrChecker<'cx, 'others, 'tcx> {
184184
}
185185
}
186186
for generic_arg in *b {
187-
if let GenericArgKind::Type(ty) = generic_arg.unpack()
187+
if let GenericArgKind::Type(ty) = generic_arg.kind()
188188
&& self.has_sig_drop_attr(ty, depth)
189189
{
190190
return true;

clippy_lints/src/use_self.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ fn same_lifetimes<'tcx>(a: MiddleTy<'tcx>, b: MiddleTy<'tcx>) -> bool {
319319
args_a
320320
.iter()
321321
.zip(args_b.iter())
322-
.all(|(arg_a, arg_b)| match (arg_a.unpack(), arg_b.unpack()) {
322+
.all(|(arg_a, arg_b)| match (arg_a.kind(), arg_b.kind()) {
323323
// TODO: Handle inferred lifetimes
324324
(GenericArgKind::Lifetime(inner_a), GenericArgKind::Lifetime(inner_b)) => inner_a == inner_b,
325325
(GenericArgKind::Type(type_a), GenericArgKind::Type(type_b)) => same_lifetimes(type_a, type_b),
@@ -337,7 +337,7 @@ fn has_no_lifetime(ty: MiddleTy<'_>) -> bool {
337337
&Adt(_, args) => !args
338338
.iter()
339339
// TODO: Handle inferred lifetimes
340-
.any(|arg| matches!(arg.unpack(), GenericArgKind::Lifetime(..))),
340+
.any(|arg| matches!(arg.kind(), GenericArgKind::Lifetime(..))),
341341
_ => true,
342342
}
343343
}

clippy_lints_internal/src/msrv_attr_impl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ impl LateLintPass<'_> for MsrvAttrImpl {
3737
.type_of(f.did)
3838
.instantiate_identity()
3939
.walk()
40-
.filter(|t| matches!(t.unpack(), GenericArgKind::Type(_)))
40+
.filter(|t| matches!(t.kind(), GenericArgKind::Type(_)))
4141
.any(|t| internal_paths::MSRV_STACK.matches_ty(cx, t.expect_ty()))
4242
})
4343
&& !items.iter().any(|item| item.ident.name.as_str() == "check_attributes")

clippy_utils/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3316,7 +3316,7 @@ pub fn leaks_droppable_temporary_with_limited_lifetime<'tcx>(cx: &LateContext<'t
33163316
if temporary_ty.has_significant_drop(cx.tcx, cx.typing_env())
33173317
&& temporary_ty
33183318
.walk()
3319-
.any(|arg| matches!(arg.unpack(), GenericArgKind::Lifetime(re) if !re.is_static()))
3319+
.any(|arg| matches!(arg.kind(), GenericArgKind::Lifetime(re) if !re.is_static()))
33203320
{
33213321
ControlFlow::Break(())
33223322
} else {

clippy_utils/src/qualify_min_const_fn.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ pub fn is_min_const_fn<'tcx>(cx: &LateContext<'tcx>, body: &Body<'tcx>, msrv: Ms
5555

5656
fn check_ty<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>, span: Span, msrv: Msrv) -> McfResult {
5757
for arg in ty.walk() {
58-
let ty = match arg.unpack() {
58+
let ty = match arg.kind() {
5959
GenericArgKind::Type(ty) => ty,
6060

6161
// No constraints on lifetimes or constants, except potentially

clippy_utils/src/ty/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ pub fn can_partially_move_ty<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> bool
7878
/// Walks into `ty` and returns `true` if any inner type is an instance of the given adt
7979
/// constructor.
8080
pub fn contains_adt_constructor<'tcx>(ty: Ty<'tcx>, adt: AdtDef<'tcx>) -> bool {
81-
ty.walk().any(|inner| match inner.unpack() {
81+
ty.walk().any(|inner| match inner.kind() {
8282
GenericArgKind::Type(inner_ty) => inner_ty.ty_adt_def() == Some(adt),
8383
GenericArgKind::Lifetime(_) | GenericArgKind::Const(_) => false,
8484
})
@@ -96,7 +96,7 @@ pub fn contains_ty_adt_constructor_opaque<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'
9696
needle: Ty<'tcx>,
9797
seen: &mut FxHashSet<DefId>,
9898
) -> bool {
99-
ty.walk().any(|inner| match inner.unpack() {
99+
ty.walk().any(|inner| match inner.kind() {
100100
GenericArgKind::Type(inner_ty) => {
101101
if inner_ty == needle {
102102
return true;
@@ -129,7 +129,7 @@ pub fn contains_ty_adt_constructor_opaque<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'
129129
// For `impl Trait<Assoc=U>`, it will register a predicate of `<T as Trait>::Assoc = U`,
130130
// so we check the term for `U`.
131131
ty::ClauseKind::Projection(projection_predicate) => {
132-
if let ty::TermKind::Ty(ty) = projection_predicate.term.unpack()
132+
if let ty::TermKind::Ty(ty) = projection_predicate.term.kind()
133133
&& contains_ty_adt_constructor_opaque_inner(cx, ty, needle, seen)
134134
{
135135
return true;
@@ -526,7 +526,7 @@ pub fn same_type_and_consts<'tcx>(a: Ty<'tcx>, b: Ty<'tcx>) -> bool {
526526
args_a
527527
.iter()
528528
.zip(args_b.iter())
529-
.all(|(arg_a, arg_b)| match (arg_a.unpack(), arg_b.unpack()) {
529+
.all(|(arg_a, arg_b)| match (arg_a.kind(), arg_b.kind()) {
530530
(GenericArgKind::Const(inner_a), GenericArgKind::Const(inner_b)) => inner_a == inner_b,
531531
(GenericArgKind::Type(type_a), GenericArgKind::Type(type_b)) => {
532532
same_type_and_consts(type_a, type_b)
@@ -996,7 +996,7 @@ fn assert_generic_args_match<'tcx>(tcx: TyCtxt<'tcx>, did: DefId, args: &[Generi
996996
if let Some((idx, (param, arg))) =
997997
params
998998
.clone()
999-
.zip(args.iter().map(|&x| x.unpack()))
999+
.zip(args.iter().map(|&x| x.kind()))
10001000
.enumerate()
10011001
.find(|(_, (param, arg))| match (param, arg) {
10021002
(GenericParamDefKind::Lifetime, GenericArgKind::Lifetime(_))

clippy_utils/src/ty/type_certainty/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,5 +326,5 @@ fn adt_def_id(ty: Ty<'_>) -> Option<DefId> {
326326

327327
fn contains_param(ty: Ty<'_>, index: u32) -> bool {
328328
ty.walk()
329-
.any(|arg| matches!(arg.unpack(), GenericArgKind::Type(ty) if ty.is_param(index)))
329+
.any(|arg| matches!(arg.kind(), GenericArgKind::Type(ty) if ty.is_param(index)))
330330
}

0 commit comments

Comments
 (0)