]> git.lizzy.rs Git - rust.git/blob - src/tools/miri/tests/pass/sums.rs
Auto merge of #104915 - weihanglo:update-cargo, r=ehuss
[rust.git] / src / tools / miri / tests / pass / sums.rs
1 #[derive(Debug, PartialEq)]
2 enum Unit {
3     Unit(()), // Force non-C-enum representation.
4 }
5
6 fn return_unit() -> Unit {
7     Unit::Unit(())
8 }
9
10 #[derive(Debug, PartialEq)]
11 enum MyBool {
12     False(()), // Force non-C-enum representation.
13     True(()),
14 }
15
16 fn return_true() -> MyBool {
17     MyBool::True(())
18 }
19
20 fn return_false() -> MyBool {
21     MyBool::False(())
22 }
23
24 fn return_none() -> Option<i64> {
25     None
26 }
27
28 fn return_some() -> Option<i64> {
29     Some(42)
30 }
31
32 fn match_opt_none() -> i8 {
33     let x = None;
34     match x {
35         Some(data) => data,
36         None => 42,
37     }
38 }
39
40 fn match_opt_some() -> i8 {
41     let x = Some(13);
42     match x {
43         Some(data) => data,
44         None => 20,
45     }
46 }
47
48 fn two_nones() -> (Option<i16>, Option<i16>) {
49     (None, None)
50 }
51
52 fn main() {
53     assert_eq!(two_nones(), (None, None));
54     assert_eq!(match_opt_some(), 13);
55     assert_eq!(match_opt_none(), 42);
56     assert_eq!(return_some(), Some(42));
57     assert_eq!(return_none(), None);
58     assert_eq!(return_false(), MyBool::False(()));
59     assert_eq!(return_true(), MyBool::True(()));
60     assert_eq!(return_unit(), Unit::Unit(()));
61 }