1
1
// check-pass
2
- #![ feature( rustc_attrs, transparent_unions) ]
2
+ #![ feature( rustc_attrs, unsized_fn_params , transparent_unions) ]
3
3
#![ allow( unused, improper_ctypes_definitions) ]
4
4
use std:: marker:: PhantomData ;
5
5
use std:: num:: NonZeroI32 ;
@@ -25,7 +25,7 @@ macro_rules! assert_abi_compatible {
25
25
struct Zst ;
26
26
27
27
#[ repr( C ) ]
28
- struct ReprC1 < T > ( T ) ;
28
+ struct ReprC1 < T : ? Sized > ( T ) ;
29
29
#[ repr( C ) ]
30
30
struct ReprC2Int < T > ( i32 , T ) ;
31
31
#[ repr( C ) ]
@@ -124,6 +124,23 @@ mod tricky {
124
124
test_transparent ! ( triple_f64, ( f64 , f64 , f64 ) ) ;
125
125
}
126
126
127
+ // Some tests with unsized types (not all wrappers are compatible with that).
128
+ macro_rules! test_transparent_unsized {
129
+ ( $name: ident, $t: ty) => {
130
+ mod $name {
131
+ use super :: * ;
132
+ assert_abi_compatible!( wrap1, $t, Wrapper1 <$t>) ;
133
+ assert_abi_compatible!( wrap1_reprc, ReprC1 <$t>, ReprC1 <Wrapper1 <$t>>) ;
134
+ assert_abi_compatible!( wrap2, $t, Wrapper2 <$t>) ;
135
+ assert_abi_compatible!( wrap2_reprc, ReprC1 <$t>, ReprC1 <Wrapper2 <$t>>) ;
136
+ }
137
+ } ;
138
+ }
139
+
140
+ test_transparent_unsized ! ( str_, str ) ;
141
+ test_transparent_unsized ! ( slice, [ u8 ] ) ;
142
+ test_transparent_unsized ! ( dyn_trait, dyn std:: any:: Any ) ;
143
+
127
144
// RFC 3391 <https://rust-lang.github.io/rfcs/3391-result_ffi_guarantees.html>.
128
145
macro_rules! test_nonnull {
129
146
( $name: ident, $t: ty) => {
0 commit comments