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

Commit bc9d26a

Browse files
extern-fn-explicit-align test: cleanup
1 parent 5f4472e commit bc9d26a

File tree

1 file changed

+6
-4
lines changed
  • tests/run-make/extern-fn-explicit-align

1 file changed

+6
-4
lines changed

tests/run-make/extern-fn-explicit-align/test.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// Issue #80127: Passing structs via FFI should work with explicit alignment.
22

3-
use std::ffi::{CString, c_char};
3+
use std::ffi::{CStr, c_char};
44
use std::ptr::null_mut;
55

6-
#[derive(Clone, Copy, Debug, PartialEq)]
6+
#[derive(Copy, Clone)]
77
#[repr(C)]
88
#[repr(align(16))]
99
pub struct TwoU64s {
@@ -12,7 +12,7 @@ pub struct TwoU64s {
1212
}
1313

1414
#[repr(C)]
15-
#[derive(Debug, Copy, Clone)]
15+
#[derive(Copy, Clone)]
1616
pub struct BoolAndU32 {
1717
pub a: bool,
1818
pub b: u32,
@@ -37,10 +37,12 @@ extern "C" {
3737
) -> i32;
3838
}
3939

40+
const STRING: &CStr = unsafe { CStr::from_bytes_with_nul_unchecked(b"Hello world\0") };
41+
4042
fn main() {
4143
let two_u64s = TwoU64s { a: 1, b: 2 };
4244
let bool_and_u32 = BoolAndU32 { a: true, b: 3 };
43-
let string = CString::new("Hello world").unwrap();
45+
let string = STRING;
4446
unsafe {
4547
many_args(
4648
null_mut(),

0 commit comments

Comments
 (0)