@@ -73,4 +73,29 @@ test_abi_compatible!(zst_unit, Zst, ());
73
73
test_abi_compatible ! ( zst_array, Zst , [ u8 ; 0 ] ) ;
74
74
test_abi_compatible ! ( nonzero_int, NonZeroI32 , i32 ) ;
75
75
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
+
76
101
fn main ( ) { }
0 commit comments