]> git.proxmox.com Git - rustc.git/blob - tests/incremental/hashes/match_expressions.rs
New upstream version 1.72.1+dfsg1
[rustc.git] / tests / incremental / hashes / match_expressions.rs
1 // This test case tests the incremental compilation hash (ICH) implementation
2 // for match expressions.
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 // Add Arm ---------------------------------------------------------------------
20 #[cfg(any(cfail1,cfail4))]
21 pub fn add_arm(x: u32) -> u32 {
22 match x {
23 0 => 0,
24 1 => 1,
25 /*---*/
26 _ => 100,
27 }
28 }
29
30 #[cfg(not(any(cfail1,cfail4)))]
31 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,optimized_mir,typeck")]
32 #[rustc_clean(cfg="cfail3")]
33 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,optimized_mir,typeck")]
34 #[rustc_clean(cfg="cfail6")]
35 pub fn add_arm(x: u32) -> u32 {
36 match x {
37 0 => 0,
38 1 => 1,
39 2 => 2,
40 _ => 100,
41 }
42 }
43
44
45
46 // Change Order Of Arms --------------------------------------------------------
47 #[cfg(any(cfail1,cfail4))]
48 pub fn change_order_of_arms(x: u32) -> u32 {
49 match x {
50 0 => 0,
51 1 => 1,
52 _ => 100,
53 }
54 }
55
56 #[cfg(not(any(cfail1,cfail4)))]
57 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir")]
58 #[rustc_clean(cfg="cfail3")]
59 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir")]
60 #[rustc_clean(cfg="cfail6")]
61 pub fn change_order_of_arms(x: u32) -> u32 {
62 match x {
63 1 => 1,
64 0 => 0,
65 _ => 100,
66 }
67 }
68
69
70
71 // Add Guard Clause ------------------------------------------------------------
72 #[cfg(any(cfail1,cfail4))]
73 pub fn add_guard_clause(x: u32, y: bool) -> u32 {
74 match x {
75 0 => 0,
76 1 => 1,
77 _ => 100,
78 }
79 }
80
81 #[cfg(not(any(cfail1,cfail4)))]
82 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,optimized_mir,typeck")]
83 #[rustc_clean(cfg="cfail3")]
84 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,optimized_mir,typeck")]
85 #[rustc_clean(cfg="cfail6")]
86 pub fn add_guard_clause(x: u32, y: bool) -> u32 {
87 match x {
88 0 => 0,
89 1 if y => 1,
90 _ => 100,
91 }
92 }
93
94
95
96 // Change Guard Clause ------------------------------------------------------------
97 #[cfg(any(cfail1,cfail4))]
98 pub fn change_guard_clause(x: u32, y: bool) -> u32 {
99 match x {
100 0 => 0,
101 1 if y => 1,
102 _ => 100,
103 }
104 }
105
106 #[cfg(not(any(cfail1,cfail4)))]
107 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,optimized_mir,typeck")]
108 #[rustc_clean(cfg="cfail3")]
109 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,optimized_mir,typeck")]
110 #[rustc_clean(cfg="cfail6")]
111 pub fn change_guard_clause(x: u32, y: bool) -> u32 {
112 match x {
113 0 => 0,
114 1 if !y => 1,
115 _ => 100,
116 }
117 }
118
119
120
121 // Add @-Binding ---------------------------------------------------------------
122 #[cfg(any(cfail1,cfail4))]
123 pub fn add_at_binding(x: u32) -> u32 {
124 match x {
125 0 => 0,
126 1 => 1,
127 _ => x,
128 }
129 }
130
131 #[cfg(not(any(cfail1,cfail4)))]
132 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,optimized_mir,typeck")]
133 #[rustc_clean(cfg="cfail3")]
134 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,optimized_mir,typeck")]
135 #[rustc_clean(cfg="cfail6")]
136 pub fn add_at_binding(x: u32) -> u32 {
137 match x {
138 0 => 0,
139 1 => 1,
140 x @ _ => x,
141 }
142 }
143
144
145
146 // Change Name of @-Binding ----------------------------------------------------
147 #[cfg(any(cfail1,cfail4))]
148 pub fn change_name_of_at_binding(x: u32) -> u32 {
149 match x {
150 0 => 0,
151 1 => 1,
152 x @ _ => 7,
153 }
154 }
155
156 #[cfg(not(any(cfail1,cfail4)))]
157 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir")]
158 #[rustc_clean(cfg="cfail3")]
159 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir")]
160 #[rustc_clean(cfg="cfail6")]
161 pub fn change_name_of_at_binding(x: u32) -> u32 {
162 match x {
163 0 => 0,
164 1 => 1,
165 y @ _ => 7,
166 }
167 }
168
169
170
171 // Change Simple Binding To Pattern --------------------------------------------
172 #[cfg(any(cfail1,cfail4))]
173 pub fn change_simple_name_to_pattern(x: u32) -> u32 {
174 match (x, x & 1) {
175 (0, 0) => 0,
176 a => 1,
177 }
178 }
179
180 #[cfg(not(any(cfail1,cfail4)))]
181 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,optimized_mir,typeck")]
182 #[rustc_clean(cfg="cfail3")]
183 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,optimized_mir,typeck")]
184 #[rustc_clean(cfg="cfail6")]
185 pub fn change_simple_name_to_pattern(x: u32) -> u32 {
186 match (x, x & 1) {
187 (0, 0) => 0,
188 (x, y) => 1,
189 }
190 }
191
192
193
194 // Change Name In Pattern ------------------------------------------------------
195 #[cfg(any(cfail1,cfail4))]
196 pub fn change_name_in_pattern(x: u32) -> u32 {
197 match (x, x & 1) {
198 (a, 0) => 0,
199 (a, 1) => a,
200 _ => 100,
201 }
202 }
203
204 #[cfg(not(any(cfail1,cfail4)))]
205 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir")]
206 #[rustc_clean(cfg="cfail3")]
207 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir")]
208 #[rustc_clean(cfg="cfail6")]
209 pub fn change_name_in_pattern(x: u32) -> u32 {
210 match (x, x & 1) {
211 (b, 0) => 0,
212 (a, 1) => a,
213 _ => 100,
214 }
215 }
216
217
218
219 // Change Mutability Of Binding In Pattern -------------------------------------
220 #[cfg(any(cfail1,cfail4))]
221 pub fn change_mutability_of_binding_in_pattern(x: u32) -> u32 {
222 match (x, x & 1) {
223 ( a, 0) => 0,
224 _ => 1,
225 }
226 }
227
228 // Ignore optimized_mir in cfail2, the only change to optimized MIR is a span.
229 #[cfg(not(any(cfail1,cfail4)))]
230 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir,typeck")]
231 #[rustc_clean(cfg="cfail3")]
232 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir,typeck")]
233 #[rustc_clean(cfg="cfail6")]
234 pub fn change_mutability_of_binding_in_pattern(x: u32) -> u32 {
235 match (x, x & 1) {
236 (mut a, 0) => 0,
237 _ => 1,
238 }
239 }
240
241
242
243 // Add `ref` To Binding In Pattern -------------------------------------
244 #[cfg(any(cfail1,cfail4))]
245 pub fn add_ref_to_binding_in_pattern(x: u32) -> u32 {
246 match (x, x & 1) {
247 ( a, 0) => 0,
248 _ => 1,
249 }
250 }
251
252 #[cfg(not(any(cfail1,cfail4)))]
253 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir,typeck")]
254 #[rustc_clean(cfg="cfail3")]
255 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir,typeck")]
256 #[rustc_clean(cfg="cfail6")]
257 pub fn add_ref_to_binding_in_pattern(x: u32) -> u32 {
258 match (x, x & 1) {
259 (ref a, 0) => 0,
260 _ => 1,
261 }
262 }
263
264
265
266 // Add `&` To Binding In Pattern -------------------------------------
267 #[cfg(any(cfail1,cfail4))]
268 pub fn add_amp_to_binding_in_pattern(x: u32) -> u32 {
269 match (&x, x & 1) {
270 ( a, 0) => 0,
271 _ => 1,
272 }
273 }
274
275 #[cfg(not(any(cfail1,cfail4)))]
276 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,optimized_mir,typeck")]
277 #[rustc_clean(cfg="cfail3")]
278 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,optimized_mir,typeck")]
279 #[rustc_clean(cfg="cfail6")]
280 pub fn add_amp_to_binding_in_pattern(x: u32) -> u32 {
281 match (&x, x & 1) {
282 (&a, 0) => 0,
283 _ => 1,
284 }
285 }
286
287
288
289 // Change RHS Of Arm -----------------------------------------------------------
290 #[cfg(any(cfail1,cfail4))]
291 pub fn change_rhs_of_arm(x: u32) -> u32 {
292 match x {
293 0 => 0,
294 1 => 1,
295 _ => 2,
296 }
297 }
298
299 #[cfg(not(any(cfail1,cfail4)))]
300 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir")]
301 #[rustc_clean(cfg="cfail3")]
302 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir")]
303 #[rustc_clean(cfg="cfail6")]
304 pub fn change_rhs_of_arm(x: u32) -> u32 {
305 match x {
306 0 => 0,
307 1 => 3,
308 _ => 2,
309 }
310 }
311
312
313
314 // Add Alternative To Arm ------------------------------------------------------
315 #[cfg(any(cfail1,cfail4))]
316 pub fn add_alternative_to_arm(x: u32) -> u32 {
317 match x {
318 0 => 0,
319 1 => 1,
320 _ => 2,
321 }
322 }
323
324 #[cfg(not(any(cfail1,cfail4)))]
325 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,optimized_mir,typeck")]
326 #[rustc_clean(cfg="cfail3")]
327 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,optimized_mir,typeck")]
328 #[rustc_clean(cfg="cfail6")]
329 pub fn add_alternative_to_arm(x: u32) -> u32 {
330 match x {
331 0 | 7 => 0,
332 1 => 3,
333 _ => 2,
334 }
335 }