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