Skip to content

Commit 60c74b7

Browse files
authored
Rollup merge of rust-lang#37654 - michaelwoerister:test-let-ich, r=nikomatsakis
ICH: Add tests for let- and match-expressions. r? @nikomatsakis
2 parents a41a87e + 5d186d0 commit 60c74b7

File tree

2 files changed

+570
-0
lines changed

2 files changed

+570
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,228 @@
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 let expressions.
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+
19+
// must-compile-successfully
20+
// revisions: cfail1 cfail2 cfail3
21+
// compile-flags: -Z query-dep-graph
22+
23+
24+
#![allow(warnings)]
25+
#![feature(rustc_attrs)]
26+
#![crate_type="rlib"]
27+
28+
// Change Name -----------------------------------------------------------------
29+
#[cfg(cfail1)]
30+
pub fn change_name() {
31+
let _x = 2u64;
32+
}
33+
34+
#[cfg(not(cfail1))]
35+
#[rustc_dirty(label="Hir", cfg="cfail2")]
36+
#[rustc_clean(label="Hir", cfg="cfail3")]
37+
#[rustc_metadata_dirty(cfg="cfail2")]
38+
#[rustc_metadata_clean(cfg="cfail3")]
39+
pub fn change_name() {
40+
let _y = 2u64;
41+
}
42+
43+
44+
45+
// Add Type --------------------------------------------------------------------
46+
#[cfg(cfail1)]
47+
pub fn add_type() {
48+
let _x = 2u32;
49+
}
50+
51+
#[cfg(not(cfail1))]
52+
#[rustc_dirty(label="Hir", cfg="cfail2")]
53+
#[rustc_clean(label="Hir", cfg="cfail3")]
54+
#[rustc_metadata_dirty(cfg="cfail2")]
55+
#[rustc_metadata_clean(cfg="cfail3")]
56+
pub fn add_type() {
57+
let _x: u32 = 2u32;
58+
}
59+
60+
61+
62+
// Change Type -----------------------------------------------------------------
63+
#[cfg(cfail1)]
64+
pub fn change_type() {
65+
let _x: u64 = 2;
66+
}
67+
68+
#[cfg(not(cfail1))]
69+
#[rustc_dirty(label="Hir", cfg="cfail2")]
70+
#[rustc_clean(label="Hir", cfg="cfail3")]
71+
#[rustc_metadata_dirty(cfg="cfail2")]
72+
#[rustc_metadata_clean(cfg="cfail3")]
73+
pub fn change_type() {
74+
let _x: u8 = 2;
75+
}
76+
77+
78+
79+
// Change Mutability of Reference Type -----------------------------------------
80+
#[cfg(cfail1)]
81+
pub fn change_mutability_of_reference_type() {
82+
let _x: &u64;
83+
}
84+
85+
#[cfg(not(cfail1))]
86+
#[rustc_dirty(label="Hir", cfg="cfail2")]
87+
#[rustc_clean(label="Hir", cfg="cfail3")]
88+
#[rustc_metadata_dirty(cfg="cfail2")]
89+
#[rustc_metadata_clean(cfg="cfail3")]
90+
pub fn change_mutability_of_reference_type() {
91+
let _x: &mut u64;
92+
}
93+
94+
95+
96+
// Change Mutability of Slot ---------------------------------------------------
97+
#[cfg(cfail1)]
98+
pub fn change_mutability_of_slot() {
99+
let mut _x: u64 = 0;
100+
}
101+
102+
#[cfg(not(cfail1))]
103+
#[rustc_dirty(label="Hir", cfg="cfail2")]
104+
#[rustc_clean(label="Hir", cfg="cfail3")]
105+
#[rustc_metadata_dirty(cfg="cfail2")]
106+
#[rustc_metadata_clean(cfg="cfail3")]
107+
pub fn change_mutability_of_slot() {
108+
let _x: u64 = 0;
109+
}
110+
111+
112+
113+
// Change Simple Binding to Pattern --------------------------------------------
114+
#[cfg(cfail1)]
115+
pub fn change_simple_binding_to_pattern() {
116+
let _x = (0u8, 'x');
117+
}
118+
119+
#[cfg(not(cfail1))]
120+
#[rustc_dirty(label="Hir", cfg="cfail2")]
121+
#[rustc_clean(label="Hir", cfg="cfail3")]
122+
#[rustc_metadata_dirty(cfg="cfail2")]
123+
#[rustc_metadata_clean(cfg="cfail3")]
124+
pub fn change_simple_binding_to_pattern() {
125+
let (_a, _b) = (0u8, 'x');
126+
}
127+
128+
129+
130+
// Change Name in Pattern ------------------------------------------------------
131+
#[cfg(cfail1)]
132+
pub fn change_name_in_pattern() {
133+
let (_a, _b) = (1u8, 'y');
134+
}
135+
136+
#[cfg(not(cfail1))]
137+
#[rustc_dirty(label="Hir", cfg="cfail2")]
138+
#[rustc_clean(label="Hir", cfg="cfail3")]
139+
#[rustc_metadata_dirty(cfg="cfail2")]
140+
#[rustc_metadata_clean(cfg="cfail3")]
141+
pub fn change_name_in_pattern() {
142+
let (_a, _c) = (1u8, 'y');
143+
}
144+
145+
146+
147+
// Add `ref` in Pattern --------------------------------------------------------
148+
#[cfg(cfail1)]
149+
pub fn add_ref_in_pattern() {
150+
let (_a, _b) = (1u8, 'y');
151+
}
152+
153+
#[cfg(not(cfail1))]
154+
#[rustc_dirty(label="Hir", cfg="cfail2")]
155+
#[rustc_clean(label="Hir", cfg="cfail3")]
156+
#[rustc_metadata_dirty(cfg="cfail2")]
157+
#[rustc_metadata_clean(cfg="cfail3")]
158+
pub fn add_ref_in_pattern() {
159+
let (ref _a, _b) = (1u8, 'y');
160+
}
161+
162+
163+
164+
// Add `&` in Pattern ----------------------------------------------------------
165+
#[cfg(cfail1)]
166+
pub fn add_amp_in_pattern() {
167+
let (_a, _b) = (&1u8, 'y');
168+
}
169+
170+
#[cfg(not(cfail1))]
171+
#[rustc_dirty(label="Hir", cfg="cfail2")]
172+
#[rustc_clean(label="Hir", cfg="cfail3")]
173+
#[rustc_metadata_dirty(cfg="cfail2")]
174+
#[rustc_metadata_clean(cfg="cfail3")]
175+
pub fn add_amp_in_pattern() {
176+
let (&_a, _b) = (&1u8, 'y');
177+
}
178+
179+
180+
181+
// Change Mutability of Binding in Pattern -------------------------------------
182+
#[cfg(cfail1)]
183+
pub fn change_mutability_of_binding_in_pattern() {
184+
let (_a, _b) = (99u8, 'q');
185+
}
186+
187+
#[cfg(not(cfail1))]
188+
#[rustc_dirty(label="Hir", cfg="cfail2")]
189+
#[rustc_clean(label="Hir", cfg="cfail3")]
190+
#[rustc_metadata_dirty(cfg="cfail2")]
191+
#[rustc_metadata_clean(cfg="cfail3")]
192+
pub fn change_mutability_of_binding_in_pattern() {
193+
let (mut _a, _b) = (99u8, 'q');
194+
}
195+
196+
197+
198+
// Add Initializer -------------------------------------------------------------
199+
#[cfg(cfail1)]
200+
pub fn add_initializer() {
201+
let _x: i16;
202+
}
203+
204+
#[cfg(not(cfail1))]
205+
#[rustc_dirty(label="Hir", cfg="cfail2")]
206+
#[rustc_clean(label="Hir", cfg="cfail3")]
207+
#[rustc_metadata_dirty(cfg="cfail2")]
208+
#[rustc_metadata_clean(cfg="cfail3")]
209+
pub fn add_initializer() {
210+
let _x: i16 = 3i16;
211+
}
212+
213+
214+
215+
// Change Initializer ----------------------------------------------------------
216+
#[cfg(cfail1)]
217+
pub fn change_initializer() {
218+
let _x = 4u16;
219+
}
220+
221+
#[cfg(not(cfail1))]
222+
#[rustc_dirty(label="Hir", cfg="cfail2")]
223+
#[rustc_clean(label="Hir", cfg="cfail3")]
224+
#[rustc_metadata_dirty(cfg="cfail2")]
225+
#[rustc_metadata_clean(cfg="cfail3")]
226+
pub fn change_initializer() {
227+
let _x = 5u16;
228+
}

0 commit comments

Comments
 (0)