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:: mem:: ManuallyDrop ;
@@ -26,7 +26,7 @@ macro_rules! assert_abi_compatible {
26
26
struct Zst ;
27
27
28
28
#[ repr( C ) ]
29
- struct ReprC1 < T > ( T ) ;
29
+ struct ReprC1 < T : ? Sized > ( T ) ;
30
30
#[ repr( C ) ]
31
31
struct ReprC2Int < T > ( i32 , T ) ;
32
32
#[ repr( C ) ]
@@ -119,6 +119,23 @@ test_transparent!(large_array, [i32; 16]);
119
119
test_transparent ! ( enum_, Option <i32 >) ;
120
120
test_transparent ! ( enum_niched, Option <& ' static i32 >) ;
121
121
122
+ // Some tests with unsized types (not all wrappers are compatible with that).
123
+ macro_rules! test_transparent_unsized {
124
+ ( $name: ident, $t: ty) => {
125
+ mod $name {
126
+ use super :: * ;
127
+ assert_abi_compatible!( wrap1, $t, Wrapper1 <$t>) ;
128
+ assert_abi_compatible!( wrap1_reprc, ReprC1 <$t>, ReprC1 <Wrapper1 <$t>>) ;
129
+ assert_abi_compatible!( wrap2, $t, Wrapper2 <$t>) ;
130
+ assert_abi_compatible!( wrap2_reprc, ReprC1 <$t>, ReprC1 <Wrapper2 <$t>>) ;
131
+ }
132
+ } ;
133
+ }
134
+
135
+ test_transparent_unsized ! ( str_, str ) ;
136
+ test_transparent_unsized ! ( slice, [ u8 ] ) ;
137
+ test_transparent_unsized ! ( dyn_trait, dyn std:: any:: Any ) ;
138
+
122
139
// RFC 3391 <https://rust-lang.github.io/rfcs/3391-result_ffi_guarantees.html>.
123
140
macro_rules! test_nonnull {
124
141
( $name: ident, $t: ty) => {
0 commit comments