]> git.proxmox.com Git - rustc.git/blob - src/test/incremental/hashes/indexing_expressions.rs
New upstream version 1.27.1+dfsg1
[rustc.git] / src / test / incremental / hashes / indexing_expressions.rs
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 indexing 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 // compile-pass
20 // revisions: cfail1 cfail2 cfail3
21 // compile-flags: -Z query-dep-graph -Zincremental-ignore-spans
22
23 #![allow(warnings)]
24 #![feature(rustc_attrs)]
25 #![crate_type="rlib"]
26
27 // Change simple index ---------------------------------------------------------
28 #[cfg(cfail1)]
29 fn change_simple_index(slice: &[u32]) -> u32 {
30 slice[3]
31 }
32
33 #[cfg(not(cfail1))]
34 #[rustc_clean(label="Hir", cfg="cfail2")]
35 #[rustc_clean(label="Hir", cfg="cfail3")]
36 #[rustc_dirty(label="HirBody", cfg="cfail2")]
37 #[rustc_clean(label="HirBody", cfg="cfail3")]
38 fn change_simple_index(slice: &[u32]) -> u32 {
39 slice[4]
40 }
41
42
43
44 // Change lower bound ----------------------------------------------------------
45 #[cfg(cfail1)]
46 fn change_lower_bound(slice: &[u32]) -> &[u32] {
47 &slice[3..5]
48 }
49
50 #[cfg(not(cfail1))]
51 #[rustc_clean(label="Hir", cfg="cfail2")]
52 #[rustc_clean(label="Hir", cfg="cfail3")]
53 #[rustc_dirty(label="HirBody", cfg="cfail2")]
54 #[rustc_clean(label="HirBody", cfg="cfail3")]
55 fn change_lower_bound(slice: &[u32]) -> &[u32] {
56 &slice[2..5]
57 }
58
59
60
61 // Change upper bound ----------------------------------------------------------
62 #[cfg(cfail1)]
63 fn change_upper_bound(slice: &[u32]) -> &[u32] {
64 &slice[3..5]
65 }
66
67 #[cfg(not(cfail1))]
68 #[rustc_clean(label="Hir", cfg="cfail2")]
69 #[rustc_clean(label="Hir", cfg="cfail3")]
70 #[rustc_dirty(label="HirBody", cfg="cfail2")]
71 #[rustc_clean(label="HirBody", cfg="cfail3")]
72 fn change_upper_bound(slice: &[u32]) -> &[u32] {
73 &slice[3..7]
74 }
75
76
77
78 // Add lower bound -------------------------------------------------------------
79 #[cfg(cfail1)]
80 fn add_lower_bound(slice: &[u32]) -> &[u32] {
81 &slice[..4]
82 }
83
84 #[cfg(not(cfail1))]
85 #[rustc_clean(label="Hir", cfg="cfail2")]
86 #[rustc_clean(label="Hir", cfg="cfail3")]
87 #[rustc_dirty(label="HirBody", cfg="cfail2")]
88 #[rustc_clean(label="HirBody", cfg="cfail3")]
89 fn add_lower_bound(slice: &[u32]) -> &[u32] {
90 &slice[3..4]
91 }
92
93
94
95 // Add upper bound -------------------------------------------------------------
96 #[cfg(cfail1)]
97 fn add_upper_bound(slice: &[u32]) -> &[u32] {
98 &slice[3..]
99 }
100
101 #[cfg(not(cfail1))]
102 #[rustc_clean(label="Hir", cfg="cfail2")]
103 #[rustc_clean(label="Hir", cfg="cfail3")]
104 #[rustc_dirty(label="HirBody", cfg="cfail2")]
105 #[rustc_clean(label="HirBody", cfg="cfail3")]
106 fn add_upper_bound(slice: &[u32]) -> &[u32] {
107 &slice[3..7]
108 }
109
110
111
112 // Change mutability -----------------------------------------------------------
113 #[cfg(cfail1)]
114 fn change_mutability(slice: &mut [u32]) -> u32 {
115 (&mut slice[3..5])[0]
116 }
117
118 #[cfg(not(cfail1))]
119 #[rustc_clean(label="Hir", cfg="cfail2")]
120 #[rustc_clean(label="Hir", cfg="cfail3")]
121 #[rustc_dirty(label="HirBody", cfg="cfail2")]
122 #[rustc_clean(label="HirBody", cfg="cfail3")]
123 fn change_mutability(slice: &mut [u32]) -> u32 {
124 (&slice[3..5])[0]
125 }
126
127
128
129 // Exclusive to inclusive range ------------------------------------------------
130 #[cfg(cfail1)]
131 fn exclusive_to_inclusive_range(slice: &[u32]) -> &[u32] {
132 &slice[3..7]
133 }
134
135 #[cfg(not(cfail1))]
136 #[rustc_clean(label="Hir", cfg="cfail2")]
137 #[rustc_clean(label="Hir", cfg="cfail3")]
138 #[rustc_dirty(label="HirBody", cfg="cfail2")]
139 #[rustc_clean(label="HirBody", cfg="cfail3")]
140 fn exclusive_to_inclusive_range(slice: &[u32]) -> &[u32] {
141 &slice[3..=7]
142 }