-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.rs
42 lines (37 loc) · 778 Bytes
/
main.rs
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
// Copyright Kani Contributors
// SPDX-License-Identifier: Apache-2.0 OR MIT
/// Test using the unit type
/// - As a void function return
/// - As a variable type in a struct or union
struct S {
f: (),
}
#[repr(C)]
union U {
f: (),
g: i32,
}
fn ret_unit() {
()
}
#[kani::proof]
fn main() {
assert!(() == ());
let u = ret_unit();
assert!(u == ());
let s = S { f: () };
assert!(s.f == ());
let u = U { f: () };
unsafe {
assert!(u.f == ());
}
// TODO: determine whether we can say anything sensible about u.g
// i.e., assert!(u.g == ???)
// TODO: determine whether the following is defined
let mut u = U { f: () };
unsafe {
u.g = 42;
u.f = ();
assert!(u.g == 42);
}
}