summaryrefslogtreecommitdiffstats
path: root/tests/rust/nonnull_attribute.rs
blob: 5089ba9972977ad3612ed0333f4402e285c6d770 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
use std::ptr::NonNull;

struct Opaque;

#[repr(C)]
pub struct Pointers<T> {
    a: NonNull<f32>,
    b: NonNull<T>,
    c: NonNull<Opaque>,
    d: NonNull<NonNull<T>>,
    e: NonNull<NonNull<f32>>,
    f: NonNull<NonNull<Opaque>>,
    g: Option<NonNull<T>>,
    h: Option<NonNull<i32>>,
    i: Option<NonNull<NonNull<i32>>>,
    j: *const T,
    k: *mut T,
}

#[repr(C)]
pub struct References<'a> {
    a: &'a Opaque,
    b: &'a mut Opaque,
    c: Option<&'a Opaque>,
    d: Option<&'a mut Opaque>,
}

#[no_mangle]
pub extern "C" fn value_arg(arg: References<'static>) {}

#[no_mangle]
pub extern "C" fn mutltiple_args(
    arg: NonNull<i32>,
    foo: *mut Pointers<u64>,
    d: NonNull<NonNull<Opaque>>,
) {
}

#[no_mangle]
pub extern "C" fn ref_arg(arg: &Pointers<u64>) {}

#[no_mangle]
pub extern "C" fn mut_ref_arg(arg: &mut Pointers<u64>) {}

#[no_mangle]
pub extern "C" fn optional_ref_arg(arg: Option<&Pointers<u64>>) {}

#[no_mangle]
pub extern "C" fn optional_mut_ref_arg(arg: Option<&mut Pointers<u64>>) {}

#[no_mangle]
pub extern "C" fn nullable_const_ptr(arg: *const Pointers<u64>) {}

#[no_mangle]
pub extern "C" fn nullable_mut_ptr(arg: *mut Pointers<u64>) {}