Skip to content

Commit a42d67e

Browse files
authored
Rollup merge of #130185 - RalfJung:abi-compat-repr-c-wrappers, r=compiler-errors
abi/compatibility test: remove tests inside repr(C) wrappers When I wrote the test I assumed we'd guarantee ABI compatibility to be "structural" wrt `repr(C)` types, i.e. if two `repr(C)` types have all their fields be pairwise ABI-compatible then the types are ABI-compatible. That got removed from the ABI compatibility docs before they landed, though, so let's also remove it from this test.
2 parents 98222a5 + 8607575 commit a42d67e

1 file changed

Lines changed: 11 additions & 41 deletions

File tree

‎tests/ui/abi/compatibility.rs‎

Lines changed: 11 additions & 41 deletions
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
usesuper::*;
@@ -212,16 +212,6 @@ impl Clone for Zst {
212212
}
213213
}
214214

215-
#[repr(C)]
216-
structReprC1<T: ?Sized>(T);
217-
#[repr(C)]
218-
structReprC2Int<T>(i32,T);
219-
#[repr(C)]
220-
structReprC2Float<T>(f32,T);
221-
#[repr(C)]
222-
structReprC4<T>(T,Vec<i32>,Zst,T);
223-
#[repr(C)]
224-
structReprC4Mixed<T>(T,f32,i32,T);
225215
#[repr(C)]
226216
enumReprCEnum<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-
usesuper::*;
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,*consti32,*muti32);
255228
test_abi_compatible!(ptr_pointee,*consti32,*constVec<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-
structWrapper1<T: ?Sized>(T);
260+
structTransparentWrapper1<T: ?Sized>(T);
289261
#[repr(transparent)]
290-
structWrapper2<T: ?Sized>((),Zst,T);
262+
structTransparentWrapper2<T: ?Sized>((),Zst,T);
291263
#[repr(transparent)]
292-
structWrapper3<T>(T,[u8;0],PhantomData<u64>);
264+
structTransparentWrapper3<T>(T,[u8;0],PhantomData<u64>);
293265
#[repr(transparent)]
294-
unionWrapperUnion<T>{
266+
unionTransparentWrapperUnion<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
usesuper::*;
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
usesuper::*;
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)