File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed
tests/run-make/extern-fn-explicit-align Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change 1
1
// Issue #80127: Passing structs via FFI should work with explicit alignment.
2
2
3
- use std:: ffi:: { CString , c_char} ;
3
+ use std:: ffi:: { CStr , c_char} ;
4
4
use std:: ptr:: null_mut;
5
5
6
- #[ derive( Clone , Copy , Debug , PartialEq ) ]
6
+ #[ derive( Copy , Clone ) ]
7
7
#[ repr( C ) ]
8
8
#[ repr( align( 16 ) ) ]
9
9
pub struct TwoU64s {
@@ -12,7 +12,7 @@ pub struct TwoU64s {
12
12
}
13
13
14
14
#[ repr( C ) ]
15
- #[ derive( Debug , Copy , Clone ) ]
15
+ #[ derive( Copy , Clone ) ]
16
16
pub struct BoolAndU32 {
17
17
pub a : bool ,
18
18
pub b : u32 ,
@@ -37,10 +37,12 @@ extern "C" {
37
37
) -> i32 ;
38
38
}
39
39
40
+ const STRING : & CStr = unsafe { CStr :: from_bytes_with_nul_unchecked ( b"Hello world\0 " ) } ;
41
+
40
42
fn main ( ) {
41
43
let two_u64s = TwoU64s { a : 1 , b : 2 } ;
42
44
let bool_and_u32 = BoolAndU32 { a : true , b : 3 } ;
43
- let string = CString :: new ( "Hello world" ) . unwrap ( ) ;
45
+ let string = STRING ;
44
46
unsafe {
45
47
many_args (
46
48
null_mut ( ) ,
You can’t perform that action at this time.
0 commit comments