]> git.proxmox.com Git - rustc.git/blob - src/test/incremental/hashes/loop_expressions.rs
New upstream version 1.41.1+dfsg1
[rustc.git] / src / test / incremental / hashes / loop_expressions.rs
1 // This test case tests the incremental compilation hash (ICH) implementation
2 // for `loop` 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 loop {
22 _x = 1;
23 break;
24 }
25 }
26
27 #[cfg(not(cfail1))]
28 #[rustc_clean(cfg="cfail2", except="HirBody, mir_built, optimized_mir")]
29 #[rustc_clean(cfg="cfail3")]
30 pub fn change_loop_body() {
31 let mut _x = 0;
32 loop {
33 _x = 2;
34 break;
35 }
36 }
37
38
39
40 // Add break
41 #[cfg(cfail1)]
42 pub fn add_break() {
43 let mut _x = 0;
44 loop {
45 _x = 1;
46 }
47 }
48
49 #[cfg(not(cfail1))]
50 #[rustc_clean(cfg="cfail2", except="HirBody, mir_built, optimized_mir, typeck_tables_of")]
51 #[rustc_clean(cfg="cfail3")]
52 pub fn add_break() {
53 let mut _x = 0;
54 loop {
55 _x = 1;
56 break;
57 }
58 }
59
60
61
62 // Add loop label
63 #[cfg(cfail1)]
64 pub fn add_loop_label() {
65 let mut _x = 0;
66 loop {
67 _x = 1;
68 break;
69 }
70 }
71
72 #[cfg(not(cfail1))]
73 #[rustc_clean(cfg="cfail2", except="HirBody")]
74 #[rustc_clean(cfg="cfail3")]
75 pub fn add_loop_label() {
76 let mut _x = 0;
77 'label: loop {
78 _x = 1;
79 break;
80 }
81 }
82
83
84
85 // Add loop label to break
86 #[cfg(cfail1)]
87 pub fn add_loop_label_to_break() {
88 let mut _x = 0;
89 'label: loop {
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_to_break() {
99 let mut _x = 0;
100 'label: loop {
101 _x = 1;
102 break 'label;
103 }
104 }
105
106
107
108 // Change break label
109 #[cfg(cfail1)]
110 pub fn change_break_label() {
111 let mut _x = 0;
112 'outer: loop {
113 'inner: loop {
114 _x = 1;
115 break 'inner;
116 }
117 }
118 }
119
120 #[cfg(not(cfail1))]
121 #[rustc_clean(cfg="cfail2", except="HirBody, mir_built, optimized_mir, typeck_tables_of")]
122 #[rustc_clean(cfg="cfail3")]
123 pub fn change_break_label() {
124 let mut _x = 0;
125 'outer: loop {
126 'inner: loop {
127 _x = 1;
128 break 'outer;
129 }
130 }
131 }
132
133
134
135 // Add loop label to continue
136 #[cfg(cfail1)]
137 pub fn add_loop_label_to_continue() {
138 let mut _x = 0;
139 'label: loop {
140 _x = 1;
141 continue;
142 }
143 }
144
145 #[cfg(not(cfail1))]
146 #[rustc_clean(cfg="cfail2", except="HirBody")]
147 #[rustc_clean(cfg="cfail3")]
148 pub fn add_loop_label_to_continue() {
149 let mut _x = 0;
150 'label: loop {
151 _x = 1;
152 continue 'label;
153 }
154 }
155
156
157
158 // Change continue label
159 #[cfg(cfail1)]
160 pub fn change_continue_label() {
161 let mut _x = 0;
162 'outer: loop {
163 'inner: loop {
164 _x = 1;
165 continue 'inner;
166 }
167 }
168 }
169
170 #[cfg(not(cfail1))]
171 #[rustc_clean(cfg="cfail2", except="HirBody, mir_built, typeck_tables_of")]
172 #[rustc_clean(cfg="cfail3")]
173 pub fn change_continue_label() {
174 let mut _x = 0;
175 'outer: loop {
176 'inner: loop {
177 _x = 1;
178 continue 'outer;
179 }
180 }
181 }
182
183
184
185 // Change continue to break
186 #[cfg(cfail1)]
187 pub fn change_continue_to_break() {
188 let mut _x = 0;
189 loop {
190 _x = 1;
191 continue;
192 }
193 }
194
195 #[cfg(not(cfail1))]
196 #[rustc_clean(cfg="cfail2", except="HirBody, mir_built, optimized_mir, typeck_tables_of")]
197 #[rustc_clean(cfg="cfail3")]
198 pub fn change_continue_to_break() {
199 let mut _x = 0;
200 loop {
201 _x = 1;
202 break;
203 }
204 }