]> git.proxmox.com Git - rustc.git/blob - src/test/incremental/hashes/for_loops.rs
New upstream version 1.27.1+dfsg1
[rustc.git] / src / test / incremental / hashes / for_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 `for` 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 // compile-pass
20 // revisions: cfail1 cfail2 cfail3
21 // compile-flags: -Z query-dep-graph -Zincremental-ignore-spans
22
23 #![allow(warnings)]
24 #![feature(rustc_attrs)]
25 #![crate_type="rlib"]
26
27
28 // Change loop body ------------------------------------------------------------
29 #[cfg(cfail1)]
30 pub fn change_loop_body() {
31 let mut _x = 0;
32 for _ in 0..1 {
33 _x = 1;
34 break;
35 }
36 }
37
38 #[cfg(not(cfail1))]
39 #[rustc_clean(cfg="cfail2", except="HirBody, MirValidated, MirOptimized")]
40 #[rustc_clean(cfg="cfail3")]
41 pub fn change_loop_body() {
42 let mut _x = 0;
43 for _ in 0..1 {
44 _x = 2;
45 break;
46 }
47 }
48
49
50
51 // Change iteration variable name ----------------------------------------------
52 #[cfg(cfail1)]
53 pub fn change_iteration_variable_name() {
54 let mut _x = 0;
55 for _i in 0..1 {
56 _x = 1;
57 break;
58 }
59 }
60
61 #[cfg(not(cfail1))]
62 #[rustc_clean(cfg="cfail2", except="HirBody, MirValidated, MirOptimized")]
63 #[rustc_clean(cfg="cfail3")]
64 pub fn change_iteration_variable_name() {
65 let mut _x = 0;
66 for _a in 0..1 {
67 _x = 1;
68 break;
69 }
70 }
71
72
73
74 // Change iteration variable pattern -------------------------------------------
75 #[cfg(cfail1)]
76 pub fn change_iteration_variable_pattern() {
77 let mut _x = 0;
78 for _i in &[0, 1, 2] {
79 _x = 1;
80 break;
81 }
82 }
83
84 #[cfg(not(cfail1))]
85 #[rustc_clean(cfg="cfail2", except="HirBody, MirValidated, MirOptimized, TypeckTables")]
86 #[rustc_clean(cfg="cfail3")]
87 pub fn change_iteration_variable_pattern() {
88 let mut _x = 0;
89 for &_i in &[0, 1, 2] {
90 _x = 1;
91 break;
92 }
93 }
94
95
96
97 // Change iterable -------------------------------------------------------------
98 #[cfg(cfail1)]
99 pub fn change_iterable() {
100 let mut _x = 0;
101 for _ in &[0, 1, 2] {
102 _x = 1;
103 break;
104 }
105 }
106
107 #[cfg(not(cfail1))]
108 #[rustc_clean(cfg="cfail2", except="HirBody, MirValidated, MirOptimized")]
109 #[rustc_clean(cfg="cfail3")]
110 pub fn change_iterable() {
111 let mut _x = 0;
112 for _ in &[0, 1, 3] {
113 _x = 1;
114 break;
115 }
116 }
117
118
119
120 // Add break -------------------------------------------------------------------
121 #[cfg(cfail1)]
122 pub fn add_break() {
123 let mut _x = 0;
124 for _ in 0..1 {
125 _x = 1;
126 }
127 }
128
129 #[cfg(not(cfail1))]
130 #[rustc_clean(cfg="cfail2", except="HirBody, MirValidated, MirOptimized, TypeckTables")]
131 #[rustc_clean(cfg="cfail3")]
132 pub fn add_break() {
133 let mut _x = 0;
134 for _ in 0..1 {
135 _x = 1;
136 break;
137 }
138 }
139
140
141
142 // Add loop label --------------------------------------------------------------
143 #[cfg(cfail1)]
144 pub fn add_loop_label() {
145 let mut _x = 0;
146 for _ in 0..1 {
147 _x = 1;
148 break;
149 }
150 }
151
152 #[cfg(not(cfail1))]
153 #[rustc_clean(cfg="cfail2", except="HirBody")]
154 #[rustc_clean(cfg="cfail3")]
155 pub fn add_loop_label() {
156 let mut _x = 0;
157 'label: for _ in 0..1 {
158 _x = 1;
159 break;
160 }
161 }
162
163
164
165 // Add loop label to break -----------------------------------------------------
166 #[cfg(cfail1)]
167 pub fn add_loop_label_to_break() {
168 let mut _x = 0;
169 'label: for _ in 0..1 {
170 _x = 1;
171 break;
172 }
173 }
174
175 #[cfg(not(cfail1))]
176 #[rustc_clean(cfg="cfail2", except="HirBody")]
177 #[rustc_clean(cfg="cfail3")]
178 pub fn add_loop_label_to_break() {
179 let mut _x = 0;
180 'label: for _ in 0..1 {
181 _x = 1;
182 break 'label;
183 }
184 }
185
186
187
188 // Change break label ----------------------------------------------------------
189 #[cfg(cfail1)]
190 pub fn change_break_label() {
191 let mut _x = 0;
192 'outer: for _ in 0..1 {
193 'inner: for _ in 0..1 {
194 _x = 1;
195 break 'inner;
196 }
197 }
198 }
199
200 #[cfg(not(cfail1))]
201 #[rustc_clean(cfg="cfail2", except="HirBody, MirValidated, MirOptimized")]
202 #[rustc_clean(cfg="cfail3")]
203 pub fn change_break_label() {
204 let mut _x = 0;
205 'outer: for _ in 0..1 {
206 'inner: for _ in 0..1 {
207 _x = 1;
208 break 'outer;
209 }
210 }
211 }
212
213
214
215 // Add loop label to continue --------------------------------------------------
216 #[cfg(cfail1)]
217 pub fn add_loop_label_to_continue() {
218 let mut _x = 0;
219 'label: for _ in 0..1 {
220 _x = 1;
221 continue;
222 }
223 }
224
225 #[cfg(not(cfail1))]
226 #[rustc_clean(cfg="cfail2", except="HirBody")]
227 #[rustc_clean(cfg="cfail3")]
228 pub fn add_loop_label_to_continue() {
229 let mut _x = 0;
230 'label: for _ in 0..1 {
231 _x = 1;
232 continue 'label;
233 }
234 }
235
236
237
238 // Change continue label ----------------------------------------------------------
239 #[cfg(cfail1)]
240 pub fn change_continue_label() {
241 let mut _x = 0;
242 'outer: for _ in 0..1 {
243 'inner: for _ in 0..1 {
244 _x = 1;
245 continue 'inner;
246 }
247 }
248 }
249
250 #[cfg(not(cfail1))]
251 #[rustc_clean(cfg="cfail2", except="HirBody, MirValidated, MirOptimized")]
252 #[rustc_clean(cfg="cfail3")]
253 pub fn change_continue_label() {
254 let mut _x = 0;
255 'outer: for _ in 0..1 {
256 'inner: for _ in 0..1 {
257 _x = 1;
258 continue 'outer;
259 }
260 }
261 }
262
263
264
265 // Change continue to break ----------------------------------------------------
266 #[cfg(cfail1)]
267 pub fn change_continue_to_break() {
268 let mut _x = 0;
269 for _ in 0..1 {
270 _x = 1;
271 continue;
272 }
273 }
274
275 #[cfg(not(cfail1))]
276 #[rustc_clean(cfg="cfail2", except="HirBody, MirValidated, MirOptimized")]
277 #[rustc_clean(cfg="cfail3")]
278 pub fn change_continue_to_break() {
279 let mut _x = 0;
280 for _ in 0..1 {
281 _x = 1;
282 break;
283 }
284 }