]> git.proxmox.com Git - rustc.git/blob - tests/incremental/hashes/while_let_loops.rs
New upstream version 1.68.2+dfsg1
[rustc.git] / tests / incremental / hashes / while_let_loops.rs
1 // This test case tests the incremental compilation hash (ICH) implementation
2 // for `while let` 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 let Some(0u32) = None {
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 let Some(0u32) = None {
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 let Some(0u32) = None {
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 let Some(1u32) = None {
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 let Some(0u32) = None {
75 _x = 1;
76 // ---
77 }
78 }
79
80 #[cfg(not(any(cfail1,cfail4)))]
81 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes, typeck")]
82 #[rustc_clean(cfg="cfail3")]
83 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes, typeck")]
84 #[rustc_clean(cfg="cfail6")]
85 pub fn add_break() {
86 let mut _x = 0;
87 while let Some(0u32) = None {
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 let Some(0u32) = None {
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 let Some(0u32) = None {
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 let Some(0u32) = None {
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 let Some(0u32) = None {
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 let Some(0u32) = None {
150 'inner: while let Some(0u32) = None {
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")]
159 #[rustc_clean(cfg="cfail3")]
160 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes")]
161 #[rustc_clean(cfg="cfail6")]
162 pub fn change_break_label() {
163 let mut _x = 0;
164 'outer: while let Some(0u32) = None {
165 'inner: while let Some(0u32) = None {
166 _x = 1;
167 break 'outer;
168 }
169 }
170 }
171
172 // Add loop label to continue
173 #[cfg(any(cfail1,cfail4))]
174 pub fn add_loop_label_to_continue() {
175 let mut _x = 0;
176 'label: while let Some(0u32) = None {
177 _x = 1;
178 continue ;
179 }
180 }
181
182 #[cfg(not(any(cfail1,cfail4)))]
183 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes")]
184 #[rustc_clean(cfg="cfail3")]
185 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes")]
186 #[rustc_clean(cfg="cfail6")]
187 pub fn add_loop_label_to_continue() {
188 let mut _x = 0;
189 'label: while let Some(0u32) = None {
190 _x = 1;
191 continue 'label;
192 }
193 }
194
195
196
197 // Change continue label
198 #[cfg(any(cfail1,cfail4))]
199 pub fn change_continue_label() {
200 let mut _x = 0;
201 'outer: while let Some(0u32) = None {
202 'inner: while let Some(0u32) = None {
203 _x = 1;
204 continue 'inner;
205 }
206 }
207 }
208
209 #[cfg(not(any(cfail1,cfail4)))]
210 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes")]
211 #[rustc_clean(cfg="cfail3")]
212 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes")]
213 #[rustc_clean(cfg="cfail6")]
214 pub fn change_continue_label() {
215 let mut _x = 0;
216 'outer: while let Some(0u32) = None {
217 'inner: while let Some(0u32) = None {
218 _x = 1;
219 continue 'outer;
220 }
221 }
222 }
223
224
225
226 // Change continue to break
227 #[cfg(any(cfail1,cfail4))]
228 pub fn change_continue_to_break() {
229 let mut _x = 0;
230 while let Some(0u32) = None {
231 _x = 1;
232 continue;
233 }
234 }
235
236 #[cfg(not(any(cfail1,cfail4)))]
237 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes")]
238 #[rustc_clean(cfg="cfail3")]
239 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes")]
240 #[rustc_clean(cfg="cfail6")]
241 pub fn change_continue_to_break() {
242 let mut _x = 0;
243 while let Some(0u32) = None {
244 _x = 1;
245 break ;
246 }
247 }