]> git.lizzy.rs Git - rust.git/blob - src/test/incremental/hashes/while_let_loops.rs
Update const_forget.rs
[rust.git] / src / test / 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
10 // compile-flags: -Z query-dep-graph -Zincremental-ignore-spans
11
12 #![allow(warnings)]
13 #![feature(rustc_attrs)]
14 #![crate_type="rlib"]
15
16
17 // Change loop body
18 #[cfg(cfail1)]
19 pub fn change_loop_body() {
20     let mut _x = 0;
21     while let Some(0u32) = None {
22         _x = 1;
23         break;
24     }
25 }
26
27 #[cfg(not(cfail1))]
28 #[rustc_clean(cfg="cfail2", except="HirBody, mir_built")]
29 #[rustc_clean(cfg="cfail3")]
30 pub fn change_loop_body() {
31     let mut _x = 0;
32     while let Some(0u32) = None {
33         _x = 2;
34         break;
35     }
36 }
37
38
39
40 // Change loop body
41 #[cfg(cfail1)]
42 pub fn change_loop_condition() {
43     let mut _x = 0;
44     while let Some(0u32) = None {
45         _x = 1;
46         break;
47     }
48 }
49
50 #[cfg(not(cfail1))]
51 #[rustc_clean(cfg="cfail2", except="HirBody, mir_built")]
52 #[rustc_clean(cfg="cfail3")]
53 pub fn change_loop_condition() {
54     let mut _x = 0;
55     while let Some(1u32) = None {
56         _x = 1;
57         break;
58     }
59 }
60
61
62
63 // Add break
64 #[cfg(cfail1)]
65 pub fn add_break() {
66     let mut _x = 0;
67     while let Some(0u32) = None {
68         _x = 1;
69     }
70 }
71
72 #[cfg(not(cfail1))]
73 #[rustc_clean(cfg="cfail2", except="HirBody, mir_built, typeck_tables_of")]
74 #[rustc_clean(cfg="cfail3")]
75 pub fn add_break() {
76     let mut _x = 0;
77     while let Some(0u32) = None {
78         _x = 1;
79         break;
80     }
81 }
82
83
84
85 // Add loop label
86 #[cfg(cfail1)]
87 pub fn add_loop_label() {
88     let mut _x = 0;
89     while let Some(0u32) = None {
90         _x = 1;
91         break;
92     }
93 }
94
95 #[cfg(not(cfail1))]
96 #[rustc_clean(cfg="cfail2", except="HirBody")]
97 #[rustc_clean(cfg="cfail3")]
98 pub fn add_loop_label() {
99     let mut _x = 0;
100     'label: while let Some(0u32) = None {
101         _x = 1;
102         break;
103     }
104 }
105
106
107
108 // Add loop label to break
109 #[cfg(cfail1)]
110 pub fn add_loop_label_to_break() {
111     let mut _x = 0;
112     'label: while let Some(0u32) = None {
113         _x = 1;
114         break;
115     }
116 }
117
118 #[cfg(not(cfail1))]
119 #[rustc_clean(cfg="cfail2", except="HirBody")]
120 #[rustc_clean(cfg="cfail3")]
121 pub fn add_loop_label_to_break() {
122     let mut _x = 0;
123     'label: while let Some(0u32) = None {
124         _x = 1;
125         break 'label;
126     }
127 }
128
129
130
131 // Change break label
132 #[cfg(cfail1)]
133 pub fn change_break_label() {
134     let mut _x = 0;
135     'outer: while let Some(0u32) = None {
136         'inner: while let Some(0u32) = None {
137             _x = 1;
138             break 'inner;
139         }
140     }
141 }
142
143 #[cfg(not(cfail1))]
144 #[rustc_clean(cfg="cfail2", except="HirBody, mir_built")]
145 #[rustc_clean(cfg="cfail3")]
146 pub fn change_break_label() {
147     let mut _x = 0;
148     'outer: while let Some(0u32) = None {
149         'inner: while let Some(0u32) = None {
150             _x = 1;
151             break 'outer;
152         }
153     }
154 }
155
156
157
158 // Add loop label to continue
159 #[cfg(cfail1)]
160 pub fn add_loop_label_to_continue() {
161     let mut _x = 0;
162     'label: while let Some(0u32) = None {
163         _x = 1;
164         continue;
165     }
166 }
167
168 #[cfg(not(cfail1))]
169 #[rustc_clean(cfg="cfail2", except="HirBody")]
170 #[rustc_clean(cfg="cfail3")]
171 pub fn add_loop_label_to_continue() {
172     let mut _x = 0;
173     'label: while let Some(0u32) = None {
174         _x = 1;
175         continue 'label;
176     }
177 }
178
179
180
181 // Change continue label
182 #[cfg(cfail1)]
183 pub fn change_continue_label() {
184     let mut _x = 0;
185     'outer: while let Some(0u32) = None {
186         'inner: while let Some(0u32) = None {
187             _x = 1;
188             continue 'inner;
189         }
190     }
191 }
192
193 #[cfg(not(cfail1))]
194 #[rustc_clean(cfg="cfail2", except="HirBody, mir_built")]
195 #[rustc_clean(cfg="cfail3")]
196 pub fn change_continue_label() {
197     let mut _x = 0;
198     'outer: while let Some(0u32) = None {
199         'inner: while let Some(0u32) = None {
200             _x = 1;
201             continue 'outer;
202         }
203     }
204 }
205
206
207
208 // Change continue to break
209 #[cfg(cfail1)]
210 pub fn change_continue_to_break() {
211     let mut _x = 0;
212     while let Some(0u32) = None {
213         _x = 1;
214         continue;
215     }
216 }
217
218 #[cfg(not(cfail1))]
219 #[rustc_clean(cfg="cfail2", except="HirBody, mir_built")]
220 #[rustc_clean(cfg="cfail3")]
221 pub fn change_continue_to_break() {
222     let mut _x = 0;
223     while let Some(0u32) = None {
224         _x = 1;
225         break;
226     }
227 }