]> git.lizzy.rs Git - rust.git/blob - tests/incremental/hashes/while_loops.rs
Rollup merge of #106717 - klensy:typo, r=lcnr
[rust.git] / tests / incremental / hashes / while_loops.rs
1 // This test case tests the incremental compilation hash (ICH) implementation
2 // for `while` 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     while true {
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     while true {
38         _x = 2;
39         break;
40     }
41 }
42
43
44
45 // Change loop body
46 #[cfg(any(cfail1,cfail4))]
47 pub fn change_loop_condition() {
48     let mut _x = 0;
49     while true  {
50         _x = 1;
51         break;
52     }
53 }
54
55 #[cfg(not(any(cfail1,cfail4)))]
56 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes")]
57 #[rustc_clean(cfg="cfail3")]
58 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes")]
59 #[rustc_clean(cfg="cfail6")]
60 pub fn change_loop_condition() {
61     let mut _x = 0;
62     while false {
63         _x = 1;
64         break;
65     }
66 }
67
68
69
70 // Add break
71 #[cfg(any(cfail1,cfail4))]
72 pub fn add_break() {
73     let mut _x = 0;
74     while true {
75         _x = 1;
76         // ---
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 add_break() {
86     let mut _x = 0;
87     while true {
88         _x = 1;
89         break;
90     }
91 }
92
93
94
95 // Add loop label
96 #[cfg(any(cfail1,cfail4))]
97 pub fn add_loop_label() {
98     let mut _x = 0;
99             while true {
100         _x = 1;
101         break;
102     }
103 }
104
105 #[cfg(not(any(cfail1,cfail4)))]
106 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes")]
107 #[rustc_clean(cfg="cfail3")]
108 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes")]
109 #[rustc_clean(cfg="cfail6")]
110 pub fn add_loop_label() {
111     let mut _x = 0;
112     'label: while true {
113         _x = 1;
114         break;
115     }
116 }
117
118
119
120 // Add loop label to break
121 #[cfg(any(cfail1,cfail4))]
122 pub fn add_loop_label_to_break() {
123     let mut _x = 0;
124     'label: while true {
125         _x = 1;
126         break       ;
127     }
128 }
129
130 #[cfg(not(any(cfail1,cfail4)))]
131 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes")]
132 #[rustc_clean(cfg="cfail3")]
133 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes")]
134 #[rustc_clean(cfg="cfail6")]
135 pub fn add_loop_label_to_break() {
136     let mut _x = 0;
137     'label: while true {
138         _x = 1;
139         break 'label;
140     }
141 }
142
143
144
145 // Change break label
146 #[cfg(any(cfail1,cfail4))]
147 pub fn change_break_label() {
148     let mut _x = 0;
149     'outer: while true {
150         'inner: while true {
151             _x = 1;
152             break 'inner;
153         }
154     }
155 }
156
157 #[cfg(not(any(cfail1,cfail4)))]
158 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir")]
159 #[rustc_clean(cfg="cfail3")]
160 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir")]
161 #[rustc_clean(cfg="cfail6")]
162 pub fn change_break_label() {
163     let mut _x = 0;
164     'outer: while true {
165         'inner: while true {
166             _x = 1;
167             break 'outer;
168         }
169     }
170 }
171
172
173
174 // Add loop label to continue
175 #[cfg(any(cfail1,cfail4))]
176 pub fn add_loop_label_to_continue() {
177     let mut _x = 0;
178     'label: while true {
179         _x = 1;
180         continue       ;
181     }
182 }
183
184 #[cfg(not(any(cfail1,cfail4)))]
185 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes")]
186 #[rustc_clean(cfg="cfail3")]
187 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes")]
188 #[rustc_clean(cfg="cfail6")]
189 pub fn add_loop_label_to_continue() {
190     let mut _x = 0;
191     'label: while true {
192         _x = 1;
193         continue 'label;
194     }
195 }
196
197
198
199 // Change continue label
200 #[cfg(any(cfail1,cfail4))]
201 pub fn change_continue_label() {
202     let mut _x = 0;
203     'outer: while true {
204         'inner: while true {
205             _x = 1;
206             continue 'inner;
207         }
208     }
209 }
210
211 #[cfg(not(any(cfail1,cfail4)))]
212 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes")]
213 #[rustc_clean(cfg="cfail3")]
214 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir")]
215 #[rustc_clean(cfg="cfail6")]
216 pub fn change_continue_label() {
217     let mut _x = 0;
218     'outer: while true {
219         'inner: while true {
220             _x = 1;
221             continue 'outer;
222         }
223     }
224 }
225
226
227
228 // Change continue to break
229 #[cfg(any(cfail1,cfail4))]
230 pub fn change_continue_to_break() {
231     let mut _x = 0;
232     while true {
233         _x = 1;
234         continue;
235     }
236 }
237
238 #[cfg(not(any(cfail1,cfail4)))]
239 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes, optimized_mir")]
240 #[rustc_clean(cfg="cfail3")]
241 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes, optimized_mir")]
242 #[rustc_clean(cfg="cfail6")]
243 pub fn change_continue_to_break() {
244     let mut _x = 0;
245     while true {
246         _x = 1;
247         break   ;
248     }
249 }