Skip to content

Commit 8607575

Browse files
committed
abi/compatibility test: remove tests inside repr(C) wrappers
1 parent 304b7f8 commit 8607575

File tree

1 file changed

+11
-41
lines changed

1 file changed

+11
-41
lines changed

tests/ui/abi/compatibility.rs

+11-41
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ mod prelude {
189189
#[cfg(not(host))]
190190
use prelude::*;
191191

192-
macro_rules! assert_abi_compatible {
192+
macro_rules! test_abi_compatible {
193193
($name:ident, $t1:ty, $t2:ty) => {
194194
mod $name {
195195
use super::*;
@@ -212,16 +212,6 @@ impl Clone for Zst {
212212
}
213213
}
214214

215-
#[repr(C)]
216-
struct ReprC1<T: ?Sized>(T);
217-
#[repr(C)]
218-
struct ReprC2Int<T>(i32, T);
219-
#[repr(C)]
220-
struct ReprC2Float<T>(f32, T);
221-
#[repr(C)]
222-
struct ReprC4<T>(T, Vec<i32>, Zst, T);
223-
#[repr(C)]
224-
struct ReprC4Mixed<T>(T, f32, i32, T);
225215
#[repr(C)]
226216
enum ReprCEnum<T> {
227217
Variant1,
@@ -233,23 +223,6 @@ union ReprCUnion<T> {
233223
something: ManuallyDrop<T>,
234224
}
235225

236-
macro_rules! test_abi_compatible {
237-
($name:ident, $t1:ty, $t2:ty) => {
238-
mod $name {
239-
use super::*;
240-
assert_abi_compatible!(plain, $t1, $t2);
241-
// We also do some tests with differences in fields of `repr(C)` types.
242-
assert_abi_compatible!(repr_c_1, ReprC1<$t1>, ReprC1<$t2>);
243-
assert_abi_compatible!(repr_c_2_int, ReprC2Int<$t1>, ReprC2Int<$t2>);
244-
assert_abi_compatible!(repr_c_2_float, ReprC2Float<$t1>, ReprC2Float<$t2>);
245-
assert_abi_compatible!(repr_c_4, ReprC4<$t1>, ReprC4<$t2>);
246-
assert_abi_compatible!(repr_c_4mixed, ReprC4Mixed<$t1>, ReprC4Mixed<$t2>);
247-
assert_abi_compatible!(repr_c_enum, ReprCEnum<$t1>, ReprCEnum<$t2>);
248-
assert_abi_compatible!(repr_c_union, ReprCUnion<$t1>, ReprCUnion<$t2>);
249-
}
250-
};
251-
}
252-
253226
// Compatibility of pointers.
254227
test_abi_compatible!(ptr_mut, *const i32, *mut i32);
255228
test_abi_compatible!(ptr_pointee, *const i32, *const Vec<i32>);
@@ -268,7 +241,6 @@ test_abi_compatible!(isize_int, isize, i64);
268241

269242
// Compatibility of 1-ZST.
270243
test_abi_compatible!(zst_unit, Zst, ());
271-
#[cfg(not(any(target_arch = "sparc64")))]
272244
test_abi_compatible!(zst_array, Zst, [u8; 0]);
273245
test_abi_compatible!(nonzero_int, NonZero<i32>, i32);
274246

@@ -285,13 +257,13 @@ test_abi_compatible!(arc, Arc<i32>, *mut i32);
285257

286258
// `repr(transparent)` compatibility.
287259
#[repr(transparent)]
288-
struct Wrapper1<T: ?Sized>(T);
260+
struct TransparentWrapper1<T: ?Sized>(T);
289261
#[repr(transparent)]
290-
struct Wrapper2<T: ?Sized>((), Zst, T);
262+
struct TransparentWrapper2<T: ?Sized>((), Zst, T);
291263
#[repr(transparent)]
292-
struct Wrapper3<T>(T, [u8; 0], PhantomData<u64>);
264+
struct TransparentWrapper3<T>(T, [u8; 0], PhantomData<u64>);
293265
#[repr(transparent)]
294-
union WrapperUnion<T> {
266+
union TransparentWrapperUnion<T> {
295267
nothing: (),
296268
something: ManuallyDrop<T>,
297269
}
@@ -300,10 +272,10 @@ macro_rules! test_transparent {
300272
($name:ident, $t:ty) => {
301273
mod $name {
302274
use super::*;
303-
test_abi_compatible!(wrap1, $t, Wrapper1<$t>);
304-
test_abi_compatible!(wrap2, $t, Wrapper2<$t>);
305-
test_abi_compatible!(wrap3, $t, Wrapper3<$t>);
306-
test_abi_compatible!(wrap4, $t, WrapperUnion<$t>);
275+
test_abi_compatible!(wrap1, $t, TransparentWrapper1<$t>);
276+
test_abi_compatible!(wrap2, $t, TransparentWrapper2<$t>);
277+
test_abi_compatible!(wrap3, $t, TransparentWrapper3<$t>);
278+
test_abi_compatible!(wrap4, $t, TransparentWrapperUnion<$t>);
307279
}
308280
};
309281
}
@@ -342,10 +314,8 @@ macro_rules! test_transparent_unsized {
342314
($name:ident, $t:ty) => {
343315
mod $name {
344316
use super::*;
345-
assert_abi_compatible!(wrap1, $t, Wrapper1<$t>);
346-
assert_abi_compatible!(wrap1_reprc, ReprC1<$t>, ReprC1<Wrapper1<$t>>);
347-
assert_abi_compatible!(wrap2, $t, Wrapper2<$t>);
348-
assert_abi_compatible!(wrap2_reprc, ReprC1<$t>, ReprC1<Wrapper2<$t>>);
317+
test_abi_compatible!(wrap1, $t, TransparentWrapper1<$t>);
318+
test_abi_compatible!(wrap2, $t, TransparentWrapper2<$t>);
349319
}
350320
};
351321
}

0 commit comments

Comments
 (0)