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