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