From 71f8ea99fe5cfbca752ddcfb1c0b13453941a9e6 Mon Sep 17 00:00:00 2001 From: BD103 <59022059+BD103@users.noreply.github.com> Date: Tue, 13 Jan 2026 12:19:37 -0500 Subject: [PATCH] refactor: move tuples type info ui test to coretest --- library/coretests/tests/mem/type_info.rs | 33 ++++++++++++++++++++++ tests/ui/reflection/tuples.rs | 36 ------------------------ 2 files changed, 33 insertions(+), 36 deletions(-) delete mode 100644 tests/ui/reflection/tuples.rs diff --git a/library/coretests/tests/mem/type_info.rs b/library/coretests/tests/mem/type_info.rs index 5cd690363a01..b3b8d96d49b0 100644 --- a/library/coretests/tests/mem/type_info.rs +++ b/library/coretests/tests/mem/type_info.rs @@ -21,3 +21,36 @@ fn test_arrays() { _ => unreachable!(), } } + +#[test] +fn test_tuples() { + fn assert_tuple_arity() { + match const { Type::of::() }.kind { + TypeKind::Tuple(tup) => { + assert_eq!(tup.fields.len(), N); + } + _ => unreachable!(), + } + } + + assert_tuple_arity::<(), 0>(); + assert_tuple_arity::<(u8,), 1>(); + assert_tuple_arity::<(u8, u8), 2>(); + + const { + match Type::of::<(u8, u8)>().kind { + TypeKind::Tuple(tup) => { + let [a, b] = tup.fields else { unreachable!() }; + + assert!(a.offset == 0); + assert!(b.offset == 1); + + match (a.ty.info().kind, b.ty.info().kind) { + (TypeKind::Leaf, TypeKind::Leaf) => {} + _ => unreachable!(), + } + } + _ => unreachable!(), + } + } +} diff --git a/tests/ui/reflection/tuples.rs b/tests/ui/reflection/tuples.rs deleted file mode 100644 index eab25a691efe..000000000000 --- a/tests/ui/reflection/tuples.rs +++ /dev/null @@ -1,36 +0,0 @@ -#![feature(type_info)] - -//@ run-pass - -use std::mem::type_info::{Type, TypeKind}; - -fn assert_tuple_arity() { - const { - match &Type::of::().kind { - TypeKind::Tuple(tup) => { - assert!(tup.fields.len() == N); - } - _ => unreachable!(), - } - } -} - -fn main() { - assert_tuple_arity::<(), 0>(); - assert_tuple_arity::<(u8,), 1>(); - assert_tuple_arity::<(u8, u8), 2>(); - const { - match &Type::of::<(u8, u8)>().kind { - TypeKind::Tuple(tup) => { - let [a, b] = tup.fields else { unreachable!() }; - assert!(a.offset == 0); - assert!(b.offset == 1); - match (&a.ty.info().kind, &b.ty.info().kind) { - (TypeKind::Leaf, TypeKind::Leaf) => {} - _ => unreachable!(), - } - } - _ => unreachable!(), - } - } -}