Skip to content

Commit d6c85a0

Browse files
committed
abi/compatibility: also test Option-like types
1 parent 3ec4308 commit d6c85a0

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

Diff for: tests/ui/abi/compatibility.rs

+14-1
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,14 @@ impl Clone for Zst {
211211
}
212212
}
213213

214+
enum Either<T, U> {
215+
Left(T),
216+
Right(U),
217+
}enum Either2<T, U> {
218+
Left(T),
219+
Right(U, ()),
220+
}
221+
214222
#[repr(C)]
215223
enum ReprCEnum<T> {
216224
Variant1,
@@ -328,7 +336,8 @@ mod unsized_ {
328336
test_transparent_unsized!(dyn_trait, dyn Any);
329337
}
330338

331-
// RFC 3391 <https://rust-lang.github.io/rfcs/3391-result_ffi_guarantees.html>.
339+
// RFC 3391 <https://rust-lang.github.io/rfcs/3391-result_ffi_guarantees.html>, including the
340+
// extension ratified at <https://github.com/rust-lang/rust/pull/130628#issuecomment-2402761599>.
332341
macro_rules! test_nonnull {
333342
($name:ident, $t:ty) => {
334343
mod $name {
@@ -340,6 +349,10 @@ macro_rules! test_nonnull {
340349
test_abi_compatible!(result_ok_zst, Result<Zst, $t>, $t);
341350
test_abi_compatible!(result_err_arr, Result<$t, [i8; 0]>, $t);
342351
test_abi_compatible!(result_ok_arr, Result<[i8; 0], $t>, $t);
352+
test_abi_compatible!(either_err_zst, Either<$t, Zst>, $t);
353+
test_abi_compatible!(either_ok_zst, Either<Zst, $t>, $t);
354+
test_abi_compatible!(either2_err_zst, Either2<$t, Zst>, $t);
355+
test_abi_compatible!(either2_err_arr, Either2<$t, [i8; 0]>, $t);
343356
}
344357
}
345358
}

0 commit comments

Comments
 (0)