]> git.lizzy.rs Git - rust.git/blob - src/test/incremental/hashes/for_loops.rs
Rollup merge of #100026 - WaffleLapkin:array-chunks, r=scottmcm
[rust.git] / src / test / incremental / hashes / for_loops.rs
1 // This test case tests the incremental compilation hash (ICH) implementation
2 // for `for` loops.
3
4 // The general pattern followed here is: Change one thing between rev1 and rev2
5 // and make sure that the hash has changed, then change nothing between rev2 and
6 // rev3 and make sure that the hash has not changed.
7
8 // build-pass (FIXME(62277): could be check-pass?)
9 // revisions: cfail1 cfail2 cfail3 cfail4 cfail5 cfail6
10 // compile-flags: -Z query-dep-graph -O
11 // [cfail1]compile-flags: -Zincremental-ignore-spans
12 // [cfail2]compile-flags: -Zincremental-ignore-spans
13 // [cfail3]compile-flags: -Zincremental-ignore-spans
14 // [cfail4]compile-flags: -Zincremental-relative-spans
15 // [cfail5]compile-flags: -Zincremental-relative-spans
16 // [cfail6]compile-flags: -Zincremental-relative-spans
17
18 #![allow(warnings)]
19 #![feature(rustc_attrs)]
20 #![crate_type="rlib"]
21
22
23 // Change loop body ------------------------------------------------------------
24 #[cfg(any(cfail1,cfail4))]
25 pub fn change_loop_body() {
26     let mut _x = 0;
27     for _ in 0..1 {
28         _x = 1;
29         break;
30     }
31 }
32
33 #[cfg(not(any(cfail1,cfail4)))]
34 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes")]
35 #[rustc_clean(cfg="cfail3")]
36 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes")]
37 #[rustc_clean(cfg="cfail6")]
38 pub fn change_loop_body() {
39     let mut _x = 0;
40     for _ in 0..1 {
41         _x = 2;
42         break;
43     }
44 }
45
46
47
48 // Change iteration variable name ----------------------------------------------
49 #[cfg(any(cfail1,cfail4))]
50 pub fn change_iteration_variable_name() {
51     let mut _x = 0;
52     for _i in 0..1 {
53         _x = 1;
54         break;
55     }
56 }
57
58 #[cfg(not(any(cfail1,cfail4)))]
59 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes, optimized_mir")]
60 #[rustc_clean(cfg="cfail3")]
61 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes, optimized_mir")]
62 #[rustc_clean(cfg="cfail6")]
63 pub fn change_iteration_variable_name() {
64     let mut _x = 0;
65     for _a in 0..1 {
66         _x = 1;
67         break;
68     }
69 }
70
71
72
73 // Change iteration variable pattern -------------------------------------------
74 #[cfg(any(cfail1,cfail4))]
75 pub fn change_iteration_variable_pattern() {
76     let mut _x = 0;
77     for  _i in &[0, 1, 2] {
78         _x = 1;
79         break;
80     }
81 }
82
83 #[cfg(not(any(cfail1,cfail4)))]
84 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes, optimized_mir, typeck")]
85 #[rustc_clean(cfg="cfail3")]
86 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes, optimized_mir, typeck")]
87 #[rustc_clean(cfg="cfail6")]
88 pub fn change_iteration_variable_pattern() {
89     let mut _x = 0;
90     for &_i in &[0, 1, 2] {
91         _x = 1;
92         break;
93     }
94 }
95
96
97
98 // Change iterable -------------------------------------------------------------
99 #[cfg(any(cfail1,cfail4))]
100 pub fn change_iterable() {
101     let mut _x = 0;
102     for _ in &[0, 1, 2] {
103         _x = 1;
104         break;
105     }
106 }
107
108 #[cfg(not(any(cfail1,cfail4)))]
109 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes, promoted_mir")]
110 #[rustc_clean(cfg="cfail3")]
111 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes, promoted_mir")]
112 #[rustc_clean(cfg="cfail6")]
113 pub fn change_iterable() {
114     let mut _x = 0;
115     for _ in &[0, 1, 3] {
116         _x = 1;
117         break;
118     }
119 }
120
121
122
123 // Add break -------------------------------------------------------------------
124 #[cfg(any(cfail1,cfail4))]
125 pub fn add_break() {
126     let mut _x = 0;
127     for _ in 0..1 {
128         _x = 1;
129         // ---
130     }
131 }
132
133 #[cfg(not(any(cfail1,cfail4)))]
134 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes, optimized_mir, typeck")]
135 #[rustc_clean(cfg="cfail3")]
136 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes, optimized_mir, typeck")]
137 #[rustc_clean(cfg="cfail6")]
138 pub fn add_break() {
139     let mut _x = 0;
140     for _ in 0..1 {
141         _x = 1;
142         break;
143     }
144 }
145
146
147
148 // Add loop label --------------------------------------------------------------
149 #[cfg(any(cfail1,cfail4))]
150 pub fn add_loop_label() {
151     let mut _x = 0;
152             for _ in 0..1 {
153         _x = 1;
154         break;
155     }
156 }
157
158 #[cfg(not(any(cfail1,cfail4)))]
159 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes")]
160 #[rustc_clean(cfg="cfail3")]
161 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes, optimized_mir")]
162 #[rustc_clean(cfg="cfail6")]
163 pub fn add_loop_label() {
164     let mut _x = 0;
165     'label: for _ in 0..1 {
166         _x = 1;
167         break;
168     }
169 }
170
171
172
173 // Add loop label to break -----------------------------------------------------
174 #[cfg(any(cfail1,cfail4))]
175 pub fn add_loop_label_to_break() {
176     let mut _x = 0;
177     'label: for _ in 0..1 {
178         _x = 1;
179         break       ;
180     }
181 }
182
183 #[cfg(not(any(cfail1,cfail4)))]
184 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes")]
185 #[rustc_clean(cfg="cfail3")]
186 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes")]
187 #[rustc_clean(cfg="cfail6")]
188 pub fn add_loop_label_to_break() {
189     let mut _x = 0;
190     'label: for _ in 0..1 {
191         _x = 1;
192         break 'label;
193     }
194 }
195
196
197
198 // Change break label ----------------------------------------------------------
199 #[cfg(any(cfail1,cfail4))]
200 pub fn change_break_label() {
201     let mut _x = 0;
202     'outer: for _ in 0..1 {
203         'inner: for _ in 0..1 {
204             _x = 1;
205             break 'inner;
206         }
207     }
208 }
209
210 #[cfg(not(any(cfail1,cfail4)))]
211 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes, optimized_mir")]
212 #[rustc_clean(cfg="cfail3")]
213 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes, optimized_mir")]
214 #[rustc_clean(cfg="cfail6")]
215 pub fn change_break_label() {
216     let mut _x = 0;
217     'outer: for _ in 0..1 {
218         'inner: for _ in 0..1 {
219             _x = 1;
220             break 'outer;
221         }
222     }
223 }
224
225
226
227 // Add loop label to continue --------------------------------------------------
228 #[cfg(any(cfail1,cfail4))]
229 pub fn add_loop_label_to_continue() {
230     let mut _x = 0;
231     'label: for _ in 0..1 {
232         _x = 1;
233         continue       ;
234     }
235 }
236
237 #[cfg(not(any(cfail1,cfail4)))]
238 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes")]
239 #[rustc_clean(cfg="cfail3")]
240 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes")]
241 #[rustc_clean(cfg="cfail6")]
242 pub fn add_loop_label_to_continue() {
243     let mut _x = 0;
244     'label: for _ in 0..1 {
245         _x = 1;
246         continue 'label;
247     }
248 }
249
250
251
252 // Change continue label ----------------------------------------------------------
253 #[cfg(any(cfail1,cfail4))]
254 pub fn change_continue_label() {
255     let mut _x = 0;
256     'outer: for _ in 0..1 {
257         'inner: for _ in 0..1 {
258             _x = 1;
259             continue 'inner;
260         }
261     }
262 }
263
264 #[cfg(not(any(cfail1,cfail4)))]
265 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes, optimized_mir")]
266 #[rustc_clean(cfg="cfail3")]
267 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes, optimized_mir")]
268 #[rustc_clean(cfg="cfail6")]
269 pub fn change_continue_label() {
270     let mut _x = 0;
271     'outer: for _ in 0..1 {
272         'inner: for _ in 0..1 {
273             _x = 1;
274             continue 'outer;
275         }
276     }
277 }
278
279
280
281 // Change continue to break ----------------------------------------------------
282 #[cfg(any(cfail1,cfail4))]
283 pub fn change_continue_to_break() {
284     let mut _x = 0;
285     for _ in 0..1 {
286         _x = 1;
287         continue;
288     }
289 }
290
291 #[cfg(not(any(cfail1,cfail4)))]
292 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes, optimized_mir")]
293 #[rustc_clean(cfg="cfail3")]
294 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes, optimized_mir")]
295 #[rustc_clean(cfg="cfail6")]
296 pub fn change_continue_to_break() {
297     let mut _x = 0;
298     for _ in 0..1 {
299         _x = 1;
300         break   ;
301     }
302 }