]> git.lizzy.rs Git - rust.git/blob - tests/target/expr.rs
Merge pull request #175 from marcusklaas/assignment
[rust.git] / tests / target / expr.rs
1 // Test expressions
2
3 fn foo() -> bool {
4     let boxed: Box<i32> = box 5;
5     let referenced = &5;
6
7     let very_long_variable_name = (a + first + simple + test);
8     let very_long_variable_name = (a + first + simple + test + AAAAAAAAAAAAA +
9                                    BBBBBBBBBBBBBBBBB + b + c);
10
11     let is_internalxxxx = self.codemap.span_to_filename(s) ==
12                           self.codemap.span_to_filename(m.inner);
13
14     let some_val = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa * bbbb /
15                    (bbbbbb - function_call(x, *very_long_pointer, y)) + 1000;
16
17     some_ridiculously_loooooooooooooooooooooong_function(10000 * 30000000000 +
18                                                          40000 / 1002200000000 -
19                                                          50000 * sqrt(-1),
20                                                          trivial_value);
21     (((((((((aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +
22              a +
23              aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +
24              aaaaa)))))))));
25
26     {
27         for _ in 0..10 {}
28     }
29
30     {
31         {
32             {
33                 {}
34             }
35         }
36     }
37
38     if 1 + 2 > 0 {
39         let result = 5;
40         result
41     } else {
42         4
43     };
44
45     if let Some(x) = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa {
46         // Nothing
47     }
48
49     if let Some(x) = (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +
50                       aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {}
51
52     if let (some_very_large,
53             tuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuple) = 1 + 2 + 3 {
54     }
55
56     if let (some_very_large,
57             tuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuple) = 1111 +
58                                                                                          2222 {}
59
60     if let (some_very_large, tuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuple) =
61            1 + 2 + 3 {
62     }
63
64     if cond() {
65         something();
66     } else if different_cond() {
67         something_else();
68     } else {
69         // Check subformatting
70         aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +
71         aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
72     }
73 }
74
75 fn bar() {
76     let range = (111111111 + 333333333333333333 + 1111 + 400000000000000000)..(2222 +
77                                                                                2333333333333333);
78
79     let another_range = 5..some_func(a, b /* comment */);
80
81     for _ in 1.. {
82         call_forever();
83     }
84
85     syntactically_correct(loop {
86             sup('?');
87         },
88                           if cond {
89             0
90         } else {
91             1
92         });
93
94     let third = ..10;
95     let infi_range = ..;
96     let foo = 1..;
97     let bar = 5;
98     let nonsense = (10..0)..(0..10);
99
100     let x = (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa && aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
101              a);
102 }
103
104 fn baz() {
105     unsafe /* {}{}{}{{{{}} */ {
106         let foo = 1u32;
107     }
108
109     unsafe /* very looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong
110             * comment */ {
111     }
112
113     unsafe /* So this is a very long comment.
114             * Multi-line, too.
115             * Will it still format correctly? */ {
116     }
117
118     unsafe {
119         // Regular unsafe block
120     }
121 }
122
123 // Test some empty blocks.
124 fn qux() {
125     {}
126     // FIXME this one could be done better.
127     { /* a block with a comment */
128     }
129     {
130
131     }
132     {
133         // A block with a comment.
134     }
135 }