]>
git.proxmox.com Git - rustc.git/blob - src/test/ui/nullable-pointer-ffi-compat.rs
3 // This would previously crash on i686 Linux due to abi differences
4 // between returning an Option<T> and T, where T is a non nullable
6 // If we have an enum with two variants such that one is zero sized
7 // and the other contains a nonnullable pointer, we don't use a
8 // separate discriminant. Instead we use that pointer field to differentiate
9 // between the 2 cases.
10 // Also, if the variant with the nonnullable pointer has no other fields
11 // then we simply express the enum as just a pointer and not wrap it
18 extern "C" fn foo(x
: &isize) -> Option
<&isize> { Some(x) }
20 static FOO
: isize = 0xDEADBEE;
24 let f
: extern "C" fn(&isize) -> &isize =
25 mem
::transmute(foo
as extern "C" fn(&isize) -> Option
<&isize>);
26 assert_eq
!(*f(&FOO
), FOO
);