Skip to content

Commit 7fd52b5

Browse files
committed
Small simplification to transmute_undefined_repr
1 parent 442d4ce commit 7fd52b5

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

clippy_lints/src/transmute/transmute_undefined_repr.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub(super) fn check<'tcx>(
2323
unsized_ty,
2424
to_ty: to_sub_ty,
2525
} => match reduce_ty(cx, to_sub_ty) {
26-
ReducedTy::IntArray | ReducedTy::TypeErasure => break,
26+
ReducedTy::TypeErasure => break,
2727
ReducedTy::UnorderedFields(ty) if is_size_pair(ty) => break,
2828
ReducedTy::Ref(to_sub_ty) => {
2929
from_ty = unsized_ty;
@@ -49,7 +49,7 @@ pub(super) fn check<'tcx>(
4949
unsized_ty,
5050
from_ty: from_sub_ty,
5151
} => match reduce_ty(cx, from_sub_ty) {
52-
ReducedTy::IntArray | ReducedTy::TypeErasure => break,
52+
ReducedTy::TypeErasure => break,
5353
ReducedTy::UnorderedFields(ty) if is_size_pair(ty) => break,
5454
ReducedTy::Ref(from_sub_ty) => {
5555
from_ty = from_sub_ty;
@@ -125,8 +125,7 @@ pub(super) fn check<'tcx>(
125125
from_ty: from_sub_ty,
126126
to_ty: to_sub_ty,
127127
} => match (reduce_ty(cx, from_sub_ty), reduce_ty(cx, to_sub_ty)) {
128-
(ReducedTy::IntArray | ReducedTy::TypeErasure, _)
129-
| (_, ReducedTy::IntArray | ReducedTy::TypeErasure) => return false,
128+
(ReducedTy::TypeErasure, _) | (_, ReducedTy::TypeErasure) => return false,
130129
(ReducedTy::UnorderedFields(from_ty), ReducedTy::UnorderedFields(to_ty)) if from_ty != to_ty => {
131130
span_lint_and_then(
132131
cx,
@@ -265,9 +264,6 @@ enum ReducedTy<'tcx> {
265264
UnorderedFields(Ty<'tcx>),
266265
/// The type is a reference to the contained type.
267266
Ref(Ty<'tcx>),
268-
/// The type is an array of a primitive integer type. These can be used as storage for a value
269-
/// of another type.
270-
IntArray,
271267
/// Any other type.
272268
Other(Ty<'tcx>),
273269
}
@@ -277,7 +273,7 @@ fn reduce_ty<'tcx>(cx: &LateContext<'tcx>, mut ty: Ty<'tcx>) -> ReducedTy<'tcx>
277273
loop {
278274
ty = cx.tcx.try_normalize_erasing_regions(cx.param_env, ty).unwrap_or(ty);
279275
return match *ty.kind() {
280-
ty::Array(sub_ty, _) if matches!(sub_ty.kind(), ty::Int(_) | ty::Uint(_)) => ReducedTy::IntArray,
276+
ty::Array(sub_ty, _) if matches!(sub_ty.kind(), ty::Int(_) | ty::Uint(_)) => ReducedTy::TypeErasure,
281277
ty::Array(sub_ty, _) | ty::Slice(sub_ty) => {
282278
ty = sub_ty;
283279
continue;

0 commit comments

Comments
 (0)