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