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