]> git.lizzy.rs Git - rust.git/blob - src/test/incremental/hashes/while_let_loops.rs
ICH: Add regression tests for various kinds of loops.
[rust.git] / src / test / incremental / hashes / while_let_loops.rs
1 // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11
12 // This test case tests the incremental compilation hash (ICH) implementation
13 // for `while let` loops.
14
15 // The general pattern followed here is: Change one thing between rev1 and rev2
16 // and make sure that the hash has changed, then change nothing between rev2 and
17 // rev3 and make sure that the hash has not changed.
18
19 // must-compile-successfully
20 // revisions: cfail1 cfail2 cfail3
21 // compile-flags: -Z query-dep-graph
22
23 #![allow(warnings)]
24 #![feature(rustc_attrs)]
25 #![crate_type="rlib"]
26
27
28 // Change loop body ------------------------------------------------------------
29 #[cfg(cfail1)]
30 fn change_loop_body() {
31     let mut _x = 0;
32     while let Some(0u32) = None {
33         _x = 1;
34         break;
35     }
36 }
37
38 #[cfg(not(cfail1))]
39 #[rustc_dirty(label="Hir", cfg="cfail2")]
40 #[rustc_clean(label="Hir", cfg="cfail3")]
41 #[rustc_metadata_dirty(cfg="cfail2")]
42 #[rustc_metadata_clean(cfg="cfail3")]
43 fn change_loop_body() {
44     let mut _x = 0;
45     while let Some(0u32) = None {
46         _x = 2;
47         break;
48     }
49 }
50
51
52
53 // Change loop body ------------------------------------------------------------
54 #[cfg(cfail1)]
55 fn change_loop_condition() {
56     let mut _x = 0;
57     while let Some(0u32) = None {
58         _x = 1;
59         break;
60     }
61 }
62
63 #[cfg(not(cfail1))]
64 #[rustc_dirty(label="Hir", cfg="cfail2")]
65 #[rustc_clean(label="Hir", cfg="cfail3")]
66 #[rustc_metadata_dirty(cfg="cfail2")]
67 #[rustc_metadata_clean(cfg="cfail3")]
68 fn change_loop_condition() {
69     let mut _x = 0;
70     while let Some(1u32) = None {
71         _x = 1;
72         break;
73     }
74 }
75
76
77
78 // Add break -------------------------------------------------------------------
79 #[cfg(cfail1)]
80 fn add_break() {
81     let mut _x = 0;
82     while let Some(0u32) = None {
83         _x = 1;
84     }
85 }
86
87 #[cfg(not(cfail1))]
88 #[rustc_dirty(label="Hir", cfg="cfail2")]
89 #[rustc_clean(label="Hir", cfg="cfail3")]
90 #[rustc_metadata_dirty(cfg="cfail2")]
91 #[rustc_metadata_clean(cfg="cfail3")]
92 fn add_break() {
93     let mut _x = 0;
94     while let Some(0u32) = None {
95         _x = 1;
96         break;
97     }
98 }
99
100
101
102 // Add loop label --------------------------------------------------------------
103 #[cfg(cfail1)]
104 fn add_loop_label() {
105     let mut _x = 0;
106     while let Some(0u32) = None {
107         _x = 1;
108         break;
109     }
110 }
111
112 #[cfg(not(cfail1))]
113 #[rustc_dirty(label="Hir", cfg="cfail2")]
114 #[rustc_clean(label="Hir", cfg="cfail3")]
115 #[rustc_metadata_dirty(cfg="cfail2")]
116 #[rustc_metadata_clean(cfg="cfail3")]
117 fn add_loop_label() {
118     let mut _x = 0;
119     'label: while let Some(0u32) = None {
120         _x = 1;
121         break;
122     }
123 }
124
125
126
127 // Add loop label to break -----------------------------------------------------
128 #[cfg(cfail1)]
129 fn add_loop_label_to_break() {
130     let mut _x = 0;
131     'label: while let Some(0u32) = None {
132         _x = 1;
133         break;
134     }
135 }
136
137 #[cfg(not(cfail1))]
138 #[rustc_dirty(label="Hir", cfg="cfail2")]
139 #[rustc_clean(label="Hir", cfg="cfail3")]
140 #[rustc_metadata_dirty(cfg="cfail2")]
141 #[rustc_metadata_clean(cfg="cfail3")]
142 fn add_loop_label_to_break() {
143     let mut _x = 0;
144     'label: while let Some(0u32) = None {
145         _x = 1;
146         break 'label;
147     }
148 }
149
150
151
152 // Change break label ----------------------------------------------------------
153 #[cfg(cfail1)]
154 fn change_break_label() {
155     let mut _x = 0;
156     'outer: while let Some(0u32) = None {
157         'inner: while let Some(0u32) = None {
158             _x = 1;
159             break 'inner;
160         }
161     }
162 }
163
164 #[cfg(not(cfail1))]
165 #[rustc_dirty(label="Hir", cfg="cfail2")]
166 #[rustc_clean(label="Hir", cfg="cfail3")]
167 #[rustc_metadata_dirty(cfg="cfail2")]
168 #[rustc_metadata_clean(cfg="cfail3")]
169 fn change_break_label() {
170     let mut _x = 0;
171     'outer: while let Some(0u32) = None {
172         'inner: while let Some(0u32) = None {
173             _x = 1;
174             break 'outer;
175         }
176     }
177 }
178
179
180
181 // Add loop label to continue --------------------------------------------------
182 #[cfg(cfail1)]
183 fn add_loop_label_to_continue() {
184     let mut _x = 0;
185     'label: while let Some(0u32) = None {
186         _x = 1;
187         continue;
188     }
189 }
190
191 #[cfg(not(cfail1))]
192 #[rustc_dirty(label="Hir", cfg="cfail2")]
193 #[rustc_clean(label="Hir", cfg="cfail3")]
194 #[rustc_metadata_dirty(cfg="cfail2")]
195 #[rustc_metadata_clean(cfg="cfail3")]
196 fn add_loop_label_to_continue() {
197     let mut _x = 0;
198     'label: while let Some(0u32) = None {
199         _x = 1;
200         continue 'label;
201     }
202 }
203
204
205
206 // Change continue label ----------------------------------------------------------
207 #[cfg(cfail1)]
208 fn change_continue_label() {
209     let mut _x = 0;
210     'outer: while let Some(0u32) = None {
211         'inner: while let Some(0u32) = None {
212             _x = 1;
213             continue 'inner;
214         }
215     }
216 }
217
218 #[cfg(not(cfail1))]
219 #[rustc_dirty(label="Hir", cfg="cfail2")]
220 #[rustc_clean(label="Hir", cfg="cfail3")]
221 #[rustc_metadata_dirty(cfg="cfail2")]
222 #[rustc_metadata_clean(cfg="cfail3")]
223 fn change_continue_label() {
224     let mut _x = 0;
225     'outer: while let Some(0u32) = None {
226         'inner: while let Some(0u32) = None {
227             _x = 1;
228             continue 'outer;
229         }
230     }
231 }
232
233
234
235 // Change continue to break ----------------------------------------------------
236 #[cfg(cfail1)]
237 fn change_continue_to_break() {
238     let mut _x = 0;
239     while let Some(0u32) = None {
240         _x = 1;
241         continue;
242     }
243 }
244
245 #[cfg(not(cfail1))]
246 #[rustc_dirty(label="Hir", cfg="cfail2")]
247 #[rustc_clean(label="Hir", cfg="cfail3")]
248 #[rustc_metadata_dirty(cfg="cfail2")]
249 #[rustc_metadata_clean(cfg="cfail3")]
250 fn change_continue_to_break() {
251     let mut _x = 0;
252     while let Some(0u32) = None {
253         _x = 1;
254         break;
255     }
256 }