11// check-pass
22#![ feature( rustc_attrs, unsized_fn_params, transparent_unions) ]
3- #![ allow( unused, improper_ctypes_definitions) ]
3+ #![ allow( unused, improper_ctypes_definitions, internal_features ) ]
44use std:: marker:: PhantomData ;
55use std:: num:: NonZeroI32 ;
66use std:: ptr:: NonNull ;
77use std:: mem:: ManuallyDrop ;
8+ // FIXME: a bunch of targets are broken in various ways.
9+ // Hence there are `cfg` throughout this test to disable parts of it on those targets.
10+ // sparc64: https://github.com/rust-lang/rust/issues/115336
11+ // mips64: https://github.com/rust-lang/rust/issues/115404
12+ // riscv64: https://github.com/rust-lang/rust/issues/115481
13+ // loongarch64: https://github.com/rust-lang/rust/issues/115509
14+ // arm, aarch64: https://github.com/rust-lang/rust/issues/115664
815
916macro_rules! assert_abi_compatible {
1017 ( $name: ident, $t1: ty, $t2: ty) => {
@@ -74,6 +81,7 @@ test_abi_compatible!(fn_fn, fn(), fn(i32) -> i32);
7481
7582// Some further guarantees we will likely (have to) make.
7683test_abi_compatible ! ( zst_unit, Zst , ( ) ) ;
84+ #[ cfg( not( any( target_arch = "sparc64" ) ) ) ]
7785test_abi_compatible ! ( zst_array, Zst , [ u8 ; 0 ] ) ;
7886test_abi_compatible ! ( nonzero_int, NonZeroI32 , i32 ) ;
7987
@@ -97,6 +105,7 @@ macro_rules! test_transparent {
97105 test_abi_compatible!( wrap1, $t, Wrapper1 <$t>) ;
98106 test_abi_compatible!( wrap2, $t, Wrapper2 <$t>) ;
99107 test_abi_compatible!( wrap3, $t, Wrapper3 <$t>) ;
108+ #[ cfg( not( any( target_arch = "riscv64" , target_arch = "loongarch64" ) ) ) ]
100109 test_abi_compatible!( wrap4, $t, WrapperUnion <$t>) ;
101110 }
102111 } ;
@@ -106,23 +115,31 @@ test_transparent!(simple, i32);
106115test_transparent ! ( reference, & ' static i32 ) ;
107116test_transparent ! ( zst, Zst ) ;
108117test_transparent ! ( unit, ( ) ) ;
109- test_transparent ! ( pair, ( i32 , f32 ) ) ; // mixing in some floats since they often get special treatment
110- test_transparent ! ( triple, ( i8 , i16 , f32 ) ) ; // chosen to fit into 64bit
111- test_transparent ! ( tuple, ( i32 , f32 , i64 , f64 ) ) ;
112- test_transparent ! ( empty_array, [ u32 ; 0 ] ) ;
113- test_transparent ! ( empty_1zst_array, [ u8 ; 0 ] ) ;
114- test_transparent ! ( small_array, [ i32 ; 2 ] ) ; // chosen to fit into 64bit
115- test_transparent ! ( large_array, [ i32 ; 16 ] ) ;
116118test_transparent ! ( enum_, Option <i32 >) ;
117119test_transparent ! ( enum_niched, Option <& ' static i32 >) ;
120+ #[ cfg( not( any( target_arch = "mips64" , target_arch = "sparc64" ) ) ) ]
121+ mod problematic_tuples1 {
122+ use super :: * ;
123+ test_transparent ! ( pair, ( i32 , f32 ) ) ; // mixing in some floats since they often get special treatment
124+ test_transparent ! ( triple, ( i8 , i16 , f32 ) ) ; // chosen to fit into 64bit
125+ test_transparent ! ( tuple, ( i32 , f32 , i64 , f64 ) ) ;
126+ }
118127// Pure-float types that are not ScalarPair seem to be tricky.
119- // FIXME: <https://github.com/rust-lang/rust/issues/115664>
120- #[ cfg( not( any( target_arch = "arm" , target_arch = "aarch64" ) ) ) ]
121- mod tricky {
128+ #[ cfg( not( any( target_arch = "arm" , target_arch = "aarch64" , target_arch = "mips64" , target_arch = "sparc64" ) ) ) ]
129+ mod problematic_tuples2 {
122130 use super :: * ;
123131 test_transparent ! ( triple_f32, ( f32 , f32 , f32 ) ) ;
124132 test_transparent ! ( triple_f64, ( f64 , f64 , f64 ) ) ;
125133}
134+ // Some targets have special rules for arrays.
135+ #[ cfg( not( any( target_arch = "mips64" , target_arch = "sparc64" ) ) ) ]
136+ mod arrays {
137+ use super :: * ;
138+ test_transparent ! ( empty_array, [ u32 ; 0 ] ) ;
139+ test_transparent ! ( empty_1zst_array, [ u8 ; 0 ] ) ;
140+ test_transparent ! ( small_array, [ i32 ; 2 ] ) ; // chosen to fit into 64bit
141+ test_transparent ! ( large_array, [ i32 ; 16 ] ) ;
142+ }
126143
127144// Some tests with unsized types (not all wrappers are compatible with that).
128145macro_rules! test_transparent_unsized {
@@ -137,9 +154,13 @@ macro_rules! test_transparent_unsized {
137154 } ;
138155}
139156
140- test_transparent_unsized ! ( str_, str ) ;
141- test_transparent_unsized ! ( slice, [ u8 ] ) ;
142- test_transparent_unsized ! ( dyn_trait, dyn std:: any:: Any ) ;
157+ #[ cfg( not( any( target_arch = "mips64" , target_arch = "sparc64" ) ) ) ]
158+ mod unsized_ {
159+ use super :: * ;
160+ test_transparent_unsized ! ( str_, str ) ;
161+ test_transparent_unsized ! ( slice, [ u8 ] ) ;
162+ test_transparent_unsized ! ( dyn_trait, dyn std:: any:: Any ) ;
163+ }
143164
144165// RFC 3391 <https://rust-lang.github.io/rfcs/3391-result_ffi_guarantees.html>.
145166macro_rules! test_nonnull {
0 commit comments