]> git.lizzy.rs Git - rust.git/blob - src/test/incremental/hashes/while_let_loops.rs
Rollup merge of #49858 - dmizuk:unique-doc-hidden, r=steveklabnik
[rust.git] / src / test / incremental / hashes / while_let_loops.rs
1 // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11
12 // This test case tests the incremental compilation hash (ICH) implementation
13 // for `while let` loops.
14
15 // The general pattern followed here is: Change one thing between rev1 and rev2
16 // and make sure that the hash has changed, then change nothing between rev2 and
17 // rev3 and make sure that the hash has not changed.
18
19 // compile-pass
20 // revisions: cfail1 cfail2 cfail3
21 // compile-flags: -Z query-dep-graph -Zincremental-ignore-spans
22
23 #![allow(warnings)]
24 #![feature(rustc_attrs)]
25 #![crate_type="rlib"]
26
27
28 // Change loop body ------------------------------------------------------------
29 #[cfg(cfail1)]
30 pub fn change_loop_body() {
31     let mut _x = 0;
32     while let Some(0u32) = None {
33         _x = 1;
34         break;
35     }
36 }
37
38 #[cfg(not(cfail1))]
39 #[rustc_clean(cfg="cfail2", except="HirBody, MirValidated, MirOptimized")]
40 #[rustc_clean(cfg="cfail3")]
41 pub fn change_loop_body() {
42     let mut _x = 0;
43     while let Some(0u32) = None {
44         _x = 2;
45         break;
46     }
47 }
48
49
50
51 // Change loop body ------------------------------------------------------------
52 #[cfg(cfail1)]
53 pub fn change_loop_condition() {
54     let mut _x = 0;
55     while let Some(0u32) = None {
56         _x = 1;
57         break;
58     }
59 }
60
61 #[cfg(not(cfail1))]
62 #[rustc_clean(cfg="cfail2", except="HirBody, MirValidated, MirOptimized")]
63 #[rustc_clean(cfg="cfail3")]
64 pub fn change_loop_condition() {
65     let mut _x = 0;
66     while let Some(1u32) = None {
67         _x = 1;
68         break;
69     }
70 }
71
72
73
74 // Add break -------------------------------------------------------------------
75 #[cfg(cfail1)]
76 pub fn add_break() {
77     let mut _x = 0;
78     while let Some(0u32) = None {
79         _x = 1;
80     }
81 }
82
83 #[cfg(not(cfail1))]
84 #[rustc_clean(cfg="cfail2", except="HirBody, MirValidated, MirOptimized, TypeckTables")]
85 #[rustc_clean(cfg="cfail3")]
86 pub fn add_break() {
87     let mut _x = 0;
88     while let Some(0u32) = None {
89         _x = 1;
90         break;
91     }
92 }
93
94
95
96 // Add loop label --------------------------------------------------------------
97 #[cfg(cfail1)]
98 pub fn add_loop_label() {
99     let mut _x = 0;
100     while let Some(0u32) = None {
101         _x = 1;
102         break;
103     }
104 }
105
106 #[cfg(not(cfail1))]
107 #[rustc_clean(cfg="cfail2", except="HirBody")]
108 #[rustc_clean(cfg="cfail3")]
109 pub fn add_loop_label() {
110     let mut _x = 0;
111     'label: while let Some(0u32) = None {
112         _x = 1;
113         break;
114     }
115 }
116
117
118
119 // Add loop label to break -----------------------------------------------------
120 #[cfg(cfail1)]
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;
126     }
127 }
128
129 #[cfg(not(cfail1))]
130 #[rustc_clean(cfg="cfail2", except="HirBody")]
131 #[rustc_clean(cfg="cfail3")]
132 pub fn add_loop_label_to_break() {
133     let mut _x = 0;
134     'label: while let Some(0u32) = None {
135         _x = 1;
136         break 'label;
137     }
138 }
139
140
141
142 // Change break label ----------------------------------------------------------
143 #[cfg(cfail1)]
144 pub fn change_break_label() {
145     let mut _x = 0;
146     'outer: while let Some(0u32) = None {
147         'inner: while let Some(0u32) = None {
148             _x = 1;
149             break 'inner;
150         }
151     }
152 }
153
154 #[cfg(not(cfail1))]
155 #[rustc_clean(cfg="cfail2", except="HirBody, MirValidated, MirOptimized, TypeckTables")]
156 #[rustc_clean(cfg="cfail3")]
157 pub fn change_break_label() {
158     let mut _x = 0;
159     'outer: while let Some(0u32) = None {
160         'inner: while let Some(0u32) = None {
161             _x = 1;
162             break 'outer;
163         }
164     }
165 }
166
167
168
169 // Add loop label to continue --------------------------------------------------
170 #[cfg(cfail1)]
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;
176     }
177 }
178
179 #[cfg(not(cfail1))]
180 #[rustc_clean(cfg="cfail2", except="HirBody")]
181 #[rustc_clean(cfg="cfail3")]
182 pub fn add_loop_label_to_continue() {
183     let mut _x = 0;
184     'label: while let Some(0u32) = None {
185         _x = 1;
186         continue 'label;
187     }
188 }
189
190
191
192 // Change continue label ----------------------------------------------------------
193 #[cfg(cfail1)]
194 pub fn change_continue_label() {
195     let mut _x = 0;
196     'outer: while let Some(0u32) = None {
197         'inner: while let Some(0u32) = None {
198             _x = 1;
199             continue 'inner;
200         }
201     }
202 }
203
204 #[cfg(not(cfail1))]
205 #[rustc_clean(cfg="cfail2", except="HirBody, MirValidated, MirOptimized, TypeckTables")]
206 #[rustc_clean(cfg="cfail3")]
207 pub fn change_continue_label() {
208     let mut _x = 0;
209     'outer: while let Some(0u32) = None {
210         'inner: while let Some(0u32) = None {
211             _x = 1;
212             continue 'outer;
213         }
214     }
215 }
216
217
218
219 // Change continue to break ----------------------------------------------------
220 #[cfg(cfail1)]
221 pub fn change_continue_to_break() {
222     let mut _x = 0;
223     while let Some(0u32) = None {
224         _x = 1;
225         continue;
226     }
227 }
228
229 #[cfg(not(cfail1))]
230 #[rustc_clean(cfg="cfail2", except="HirBody, MirValidated, MirOptimized")]
231 #[rustc_clean(cfg="cfail3")]
232 pub fn change_continue_to_break() {
233     let mut _x = 0;
234     while let Some(0u32) = None {
235         _x = 1;
236         break;
237     }
238 }