Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 02217d1

Browse files
committed
add tests for RFC 3391
1 parent c3e14ed commit 02217d1

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

tests/ui/abi/compatibility.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,29 @@ test_abi_compatible!(zst_unit, Zst, ());
7373
test_abi_compatible!(zst_array, Zst, [u8; 0]);
7474
test_abi_compatible!(nonzero_int, NonZeroI32, i32);
7575

76+
// RFC 3391 <https://rust-lang.github.io/rfcs/3391-result_ffi_guarantees.html>.
77+
macro_rules! test_nonnull {
78+
($name:ident, $t:ty) => {
79+
mod $name {
80+
use super::*;
81+
test_abi_compatible!(option, Option<$t>, $t);
82+
test_abi_compatible!(result_err_unit, Result<$t, ()>, $t);
83+
test_abi_compatible!(result_ok_unit, Result<(), $t>, $t);
84+
test_abi_compatible!(result_err_zst, Result<$t, Zst>, $t);
85+
test_abi_compatible!(result_ok_zst, Result<Zst, $t>, $t);
86+
test_abi_compatible!(result_err_arr, Result<$t, [i8; 0]>, $t);
87+
test_abi_compatible!(result_ok_arr, Result<[i8; 0], $t>, $t);
88+
}
89+
}
90+
}
91+
92+
test_nonnull!(ref_, &i32);
93+
test_nonnull!(mut_, &mut i32);
94+
test_nonnull!(ref_unsized, &[i32]);
95+
test_nonnull!(mut_unsized, &mut [i32]);
96+
test_nonnull!(fn_, fn());
97+
test_nonnull!(nonnull, NonNull<i32>);
98+
test_nonnull!(nonnull_unsized, NonNull<dyn std::fmt::Debug>);
99+
test_nonnull!(non_zero, NonZeroI32);
100+
76101
fn main() {}

0 commit comments

Comments
 (0)