]> git.lizzy.rs Git - rust.git/blob - tests/ui/abi/extern/extern-pass-TwoU32s.rs
Rollup merge of #106648 - Nilstrieb:poly-cleanup, r=compiler-errors
[rust.git] / tests / ui / abi / extern / extern-pass-TwoU32s.rs
1 // run-pass
2 #![allow(improper_ctypes)]
3
4 // ignore-wasm32-bare no libc for ffi testing
5
6 // Test a foreign function that accepts and returns a struct
7 // by value.
8
9 #[derive(Copy, Clone, PartialEq, Debug)]
10 pub struct TwoU32s {
11     one: u32,
12     two: u32,
13 }
14
15 #[link(name = "rust_test_helpers", kind = "static")]
16 extern "C" {
17     pub fn rust_dbg_extern_identity_TwoU32s(v: TwoU32s) -> TwoU32s;
18 }
19
20 pub fn main() {
21     unsafe {
22         let x = TwoU32s { one: 22, two: 23 };
23         let y = rust_dbg_extern_identity_TwoU32s(x);
24         assert_eq!(x, y);
25     }
26 }