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