Skip to content

Commit 277675c

Browse files
ICH: Add test case for indexing expressions.
1 parent 45b89b8 commit 277675c

File tree

1 file changed

+157
-0
lines changed

1 file changed

+157
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
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 closure expression.
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+
#![allow(warnings)]
24+
#![feature(rustc_attrs)]
25+
#![crate_type="rlib"]
26+
#![feature(inclusive_range_syntax)]
27+
28+
// Change simple index ---------------------------------------------------------
29+
#[cfg(cfail1)]
30+
fn change_simple_index(slice: &[u32]) -> u32 {
31+
slice[3]
32+
}
33+
34+
#[cfg(not(cfail1))]
35+
#[rustc_clean(label="Hir", cfg="cfail2")]
36+
#[rustc_clean(label="Hir", cfg="cfail3")]
37+
#[rustc_dirty(label="HirBody", cfg="cfail2")]
38+
#[rustc_clean(label="HirBody", cfg="cfail3")]
39+
#[rustc_metadata_clean(cfg="cfail2")]
40+
#[rustc_metadata_clean(cfg="cfail3")]
41+
fn change_simple_index(slice: &[u32]) -> u32 {
42+
slice[4]
43+
}
44+
45+
46+
47+
// Change lower bound ----------------------------------------------------------
48+
#[cfg(cfail1)]
49+
fn change_lower_bound(slice: &[u32]) -> &[u32] {
50+
&slice[3..5]
51+
}
52+
53+
#[cfg(not(cfail1))]
54+
#[rustc_clean(label="Hir", cfg="cfail2")]
55+
#[rustc_clean(label="Hir", cfg="cfail3")]
56+
#[rustc_dirty(label="HirBody", cfg="cfail2")]
57+
#[rustc_clean(label="HirBody", cfg="cfail3")]
58+
#[rustc_metadata_clean(cfg="cfail2")]
59+
#[rustc_metadata_clean(cfg="cfail3")]
60+
fn change_lower_bound(slice: &[u32]) -> &[u32] {
61+
&slice[2..5]
62+
}
63+
64+
65+
66+
// Change upper bound ----------------------------------------------------------
67+
#[cfg(cfail1)]
68+
fn change_upper_bound(slice: &[u32]) -> &[u32] {
69+
&slice[3..5]
70+
}
71+
72+
#[cfg(not(cfail1))]
73+
#[rustc_clean(label="Hir", cfg="cfail2")]
74+
#[rustc_clean(label="Hir", cfg="cfail3")]
75+
#[rustc_dirty(label="HirBody", cfg="cfail2")]
76+
#[rustc_clean(label="HirBody", cfg="cfail3")]
77+
#[rustc_metadata_clean(cfg="cfail2")]
78+
#[rustc_metadata_clean(cfg="cfail3")]
79+
fn change_upper_bound(slice: &[u32]) -> &[u32] {
80+
&slice[3..7]
81+
}
82+
83+
84+
85+
// Add lower bound -------------------------------------------------------------
86+
#[cfg(cfail1)]
87+
fn add_lower_bound(slice: &[u32]) -> &[u32] {
88+
&slice[..4]
89+
}
90+
91+
#[cfg(not(cfail1))]
92+
#[rustc_clean(label="Hir", cfg="cfail2")]
93+
#[rustc_clean(label="Hir", cfg="cfail3")]
94+
#[rustc_dirty(label="HirBody", cfg="cfail2")]
95+
#[rustc_clean(label="HirBody", cfg="cfail3")]
96+
#[rustc_metadata_clean(cfg="cfail2")]
97+
#[rustc_metadata_clean(cfg="cfail3")]
98+
fn add_lower_bound(slice: &[u32]) -> &[u32] {
99+
&slice[3..4]
100+
}
101+
102+
103+
104+
// Add upper bound -------------------------------------------------------------
105+
#[cfg(cfail1)]
106+
fn add_upper_bound(slice: &[u32]) -> &[u32] {
107+
&slice[3..]
108+
}
109+
110+
#[cfg(not(cfail1))]
111+
#[rustc_clean(label="Hir", cfg="cfail2")]
112+
#[rustc_clean(label="Hir", cfg="cfail3")]
113+
#[rustc_dirty(label="HirBody", cfg="cfail2")]
114+
#[rustc_clean(label="HirBody", cfg="cfail3")]
115+
#[rustc_metadata_clean(cfg="cfail2")]
116+
#[rustc_metadata_clean(cfg="cfail3")]
117+
fn add_upper_bound(slice: &[u32]) -> &[u32] {
118+
&slice[3..7]
119+
}
120+
121+
122+
123+
// Change mutability -----------------------------------------------------------
124+
#[cfg(cfail1)]
125+
fn change_mutability(slice: &mut [u32]) -> u32 {
126+
(&mut slice[3..5])[0]
127+
}
128+
129+
#[cfg(not(cfail1))]
130+
#[rustc_clean(label="Hir", cfg="cfail2")]
131+
#[rustc_clean(label="Hir", cfg="cfail3")]
132+
#[rustc_dirty(label="HirBody", cfg="cfail2")]
133+
#[rustc_clean(label="HirBody", cfg="cfail3")]
134+
#[rustc_metadata_clean(cfg="cfail2")]
135+
#[rustc_metadata_clean(cfg="cfail3")]
136+
fn change_mutability(slice: &mut [u32]) -> u32 {
137+
(&slice[3..5])[0]
138+
}
139+
140+
141+
142+
// Exclusive to inclusive range ------------------------------------------------
143+
#[cfg(cfail1)]
144+
fn exclusive_to_inclusive_range(slice: &[u32]) -> &[u32] {
145+
&slice[3..7]
146+
}
147+
148+
#[cfg(not(cfail1))]
149+
#[rustc_clean(label="Hir", cfg="cfail2")]
150+
#[rustc_clean(label="Hir", cfg="cfail3")]
151+
#[rustc_dirty(label="HirBody", cfg="cfail2")]
152+
#[rustc_clean(label="HirBody", cfg="cfail3")]
153+
#[rustc_metadata_clean(cfg="cfail2")]
154+
#[rustc_metadata_clean(cfg="cfail3")]
155+
fn exclusive_to_inclusive_range(slice: &[u32]) -> &[u32] {
156+
&slice[3...7]
157+
}

0 commit comments

Comments
 (0)