@@ -4,7 +4,7 @@ use clippy_utils::ty::is_c_void;
4
4
use rustc_hir:: Expr ;
5
5
use rustc_lint:: LateContext ;
6
6
use rustc_middle:: ty:: subst:: Subst ;
7
- use rustc_middle:: ty:: { self , Ty , TypeAndMut } ;
7
+ use rustc_middle:: ty:: { self , IntTy , Ty , TypeAndMut , UintTy } ;
8
8
use rustc_span:: Span ;
9
9
10
10
#[ allow( clippy:: too_many_lines) ]
@@ -24,6 +24,7 @@ pub(super) fn check<'tcx>(
24
24
to_ty : to_sub_ty,
25
25
} => match reduce_ty ( cx, to_sub_ty) {
26
26
ReducedTy :: IntArray | ReducedTy :: TypeErasure => break ,
27
+ ReducedTy :: UnorderedFields ( ty) if is_size_pair ( ty) => break ,
27
28
ReducedTy :: Ref ( to_sub_ty) => {
28
29
from_ty = unsized_ty;
29
30
to_ty = to_sub_ty;
@@ -49,6 +50,7 @@ pub(super) fn check<'tcx>(
49
50
from_ty : from_sub_ty,
50
51
} => match reduce_ty ( cx, from_sub_ty) {
51
52
ReducedTy :: IntArray | ReducedTy :: TypeErasure => break ,
53
+ ReducedTy :: UnorderedFields ( ty) if is_size_pair ( ty) => break ,
52
54
ReducedTy :: Ref ( from_sub_ty) => {
53
55
from_ty = from_sub_ty;
54
56
to_ty = unsized_ty;
@@ -333,3 +335,14 @@ fn is_zero_sized_ty<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> bool {
333
335
}
334
336
}
335
337
}
338
+
339
+ fn is_size_pair ( ty : Ty < ' _ > ) -> bool {
340
+ if let ty:: Tuple ( tys) = * ty. kind ( )
341
+ && let [ ty1, ty2] = & * * tys
342
+ {
343
+ matches ! ( ty1. kind( ) , ty:: Int ( IntTy :: Isize ) | ty:: Uint ( UintTy :: Usize ) )
344
+ && matches ! ( ty2. kind( ) , ty:: Int ( IntTy :: Isize ) | ty:: Uint ( UintTy :: Usize ) )
345
+ } else {
346
+ false
347
+ }
348
+ }
0 commit comments