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