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.
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.
12 // This test case tests the incremental compilation hash (ICH) implementation
13 // for `while let` loops.
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.
19 // must-compile-successfully
20 // revisions: cfail1 cfail2 cfail3
21 // compile-flags: -Z query-dep-graph
24 #![feature(rustc_attrs)]
28 // Change loop body ------------------------------------------------------------
30 fn change_loop_body() {
32 while let Some(0u32) = None {
39 #[rustc_dirty(label="Hir", cfg="cfail2")]
40 #[rustc_clean(label="Hir", cfg="cfail3")]
41 #[rustc_metadata_dirty(cfg="cfail2")]
42 #[rustc_metadata_clean(cfg="cfail3")]
43 fn change_loop_body() {
45 while let Some(0u32) = None {
53 // Change loop body ------------------------------------------------------------
55 fn change_loop_condition() {
57 while let Some(0u32) = None {
64 #[rustc_dirty(label="Hir", cfg="cfail2")]
65 #[rustc_clean(label="Hir", cfg="cfail3")]
66 #[rustc_metadata_dirty(cfg="cfail2")]
67 #[rustc_metadata_clean(cfg="cfail3")]
68 fn change_loop_condition() {
70 while let Some(1u32) = None {
78 // Add break -------------------------------------------------------------------
82 while let Some(0u32) = None {
88 #[rustc_dirty(label="Hir", cfg="cfail2")]
89 #[rustc_clean(label="Hir", cfg="cfail3")]
90 #[rustc_metadata_dirty(cfg="cfail2")]
91 #[rustc_metadata_clean(cfg="cfail3")]
94 while let Some(0u32) = None {
102 // Add loop label --------------------------------------------------------------
104 fn add_loop_label() {
106 while let Some(0u32) = None {
113 #[rustc_dirty(label="Hir", cfg="cfail2")]
114 #[rustc_clean(label="Hir", cfg="cfail3")]
115 #[rustc_metadata_dirty(cfg="cfail2")]
116 #[rustc_metadata_clean(cfg="cfail3")]
117 fn add_loop_label() {
119 'label: while let Some(0u32) = None {
127 // Add loop label to break -----------------------------------------------------
129 fn add_loop_label_to_break() {
131 'label: while let Some(0u32) = None {
138 #[rustc_dirty(label="Hir", cfg="cfail2")]
139 #[rustc_clean(label="Hir", cfg="cfail3")]
140 #[rustc_metadata_dirty(cfg="cfail2")]
141 #[rustc_metadata_clean(cfg="cfail3")]
142 fn add_loop_label_to_break() {
144 'label: while let Some(0u32) = None {
152 // Change break label ----------------------------------------------------------
154 fn change_break_label() {
156 'outer: while let Some(0u32) = None {
157 'inner: while let Some(0u32) = None {
165 #[rustc_dirty(label="Hir", cfg="cfail2")]
166 #[rustc_clean(label="Hir", cfg="cfail3")]
167 #[rustc_metadata_dirty(cfg="cfail2")]
168 #[rustc_metadata_clean(cfg="cfail3")]
169 fn change_break_label() {
171 'outer: while let Some(0u32) = None {
172 'inner: while let Some(0u32) = None {
181 // Add loop label to continue --------------------------------------------------
183 fn add_loop_label_to_continue() {
185 'label: while let Some(0u32) = None {
192 #[rustc_dirty(label="Hir", cfg="cfail2")]
193 #[rustc_clean(label="Hir", cfg="cfail3")]
194 #[rustc_metadata_dirty(cfg="cfail2")]
195 #[rustc_metadata_clean(cfg="cfail3")]
196 fn add_loop_label_to_continue() {
198 'label: while let Some(0u32) = None {
206 // Change continue label ----------------------------------------------------------
208 fn change_continue_label() {
210 'outer: while let Some(0u32) = None {
211 'inner: while let Some(0u32) = None {
219 #[rustc_dirty(label="Hir", cfg="cfail2")]
220 #[rustc_clean(label="Hir", cfg="cfail3")]
221 #[rustc_metadata_dirty(cfg="cfail2")]
222 #[rustc_metadata_clean(cfg="cfail3")]
223 fn change_continue_label() {
225 'outer: while let Some(0u32) = None {
226 'inner: while let Some(0u32) = None {
235 // Change continue to break ----------------------------------------------------
237 fn change_continue_to_break() {
239 while let Some(0u32) = None {
246 #[rustc_dirty(label="Hir", cfg="cfail2")]
247 #[rustc_clean(label="Hir", cfg="cfail3")]
248 #[rustc_metadata_dirty(cfg="cfail2")]
249 #[rustc_metadata_clean(cfg="cfail3")]
250 fn change_continue_to_break() {
252 while let Some(0u32) = None {