]> git.lizzy.rs Git - rust.git/blob - tests/incremental/hashes/indexing_expressions.rs
Merge commit '7f27e2e74ef957baa382dc05cf08df6368165c74' into clippyup
[rust.git] / tests / incremental / hashes / indexing_expressions.rs
1 // This test case tests the incremental compilation hash (ICH) implementation
2 // for indexing expression.
3
4 // The general pattern followed here is: Change one thing between rev1 and rev2
5 // and make sure that the hash has changed, then change nothing between rev2 and
6 // rev3 and make sure that the hash has not changed.
7
8 // build-pass (FIXME(62277): could be check-pass?)
9 // revisions: cfail1 cfail2 cfail3 cfail4 cfail5 cfail6
10 // compile-flags: -Z query-dep-graph -O
11 // [cfail1]compile-flags: -Zincremental-ignore-spans
12 // [cfail2]compile-flags: -Zincremental-ignore-spans
13 // [cfail3]compile-flags: -Zincremental-ignore-spans
14
15 #![allow(warnings)]
16 #![feature(rustc_attrs)]
17 #![crate_type="rlib"]
18
19 // Change simple index
20 #[cfg(any(cfail1,cfail4))]
21 fn change_simple_index(slice: &[u32]) -> u32 {
22     slice[3]
23 }
24
25 #[cfg(not(any(cfail1,cfail4)))]
26 #[rustc_clean(except="hir_owner_nodes", cfg="cfail2")]
27 #[rustc_clean(cfg="cfail3")]
28 #[rustc_clean(except="hir_owner_nodes", cfg="cfail5")]
29 #[rustc_clean(cfg="cfail6")]
30 fn change_simple_index(slice: &[u32]) -> u32 {
31     slice[4]
32 }
33
34
35
36 // Change lower bound
37 #[cfg(any(cfail1,cfail4))]
38 fn change_lower_bound(slice: &[u32]) -> &[u32] {
39     &slice[3..5]
40 }
41
42 #[cfg(not(any(cfail1,cfail4)))]
43 #[rustc_clean(except="hir_owner_nodes", cfg="cfail2")]
44 #[rustc_clean(cfg="cfail3")]
45 #[rustc_clean(except="hir_owner_nodes", cfg="cfail5")]
46 #[rustc_clean(cfg="cfail6")]
47 fn change_lower_bound(slice: &[u32]) -> &[u32] {
48     &slice[2..5]
49 }
50
51
52
53 // Change upper bound
54 #[cfg(any(cfail1,cfail4))]
55 fn change_upper_bound(slice: &[u32]) -> &[u32] {
56     &slice[3..5]
57 }
58
59 #[cfg(not(any(cfail1,cfail4)))]
60 #[rustc_clean(except="hir_owner_nodes", cfg="cfail2")]
61 #[rustc_clean(cfg="cfail3")]
62 #[rustc_clean(except="hir_owner_nodes", cfg="cfail5")]
63 #[rustc_clean(cfg="cfail6")]
64 fn change_upper_bound(slice: &[u32]) -> &[u32] {
65     &slice[3..7]
66 }
67
68
69
70 // Add lower bound
71 #[cfg(any(cfail1,cfail4))]
72 fn add_lower_bound(slice: &[u32]) -> &[u32] {
73     &slice[ ..4]
74 }
75
76 #[cfg(not(any(cfail1,cfail4)))]
77 #[rustc_clean(except="hir_owner,hir_owner_nodes,typeck", cfg="cfail2")]
78 #[rustc_clean(cfg="cfail3")]
79 #[rustc_clean(except="hir_owner,hir_owner_nodes,typeck", cfg="cfail5")]
80 #[rustc_clean(cfg="cfail6")]
81 fn add_lower_bound(slice: &[u32]) -> &[u32] {
82     &slice[3..4]
83 }
84
85
86
87 // Add upper bound
88 #[cfg(any(cfail1,cfail4))]
89 fn add_upper_bound(slice: &[u32]) -> &[u32] {
90     &slice[3.. ]
91 }
92
93 #[cfg(not(any(cfail1,cfail4)))]
94 #[rustc_clean(except="hir_owner,hir_owner_nodes,typeck", cfg="cfail2")]
95 #[rustc_clean(cfg="cfail3")]
96 #[rustc_clean(except="hir_owner,hir_owner_nodes,typeck", cfg="cfail5")]
97 #[rustc_clean(cfg="cfail6")]
98 fn add_upper_bound(slice: &[u32]) -> &[u32] {
99     &slice[3..7]
100 }
101
102
103
104 // Change mutability
105 #[cfg(any(cfail1,cfail4))]
106 fn change_mutability(slice: &mut [u32]) -> u32 {
107     (&mut slice[3..5])[0]
108 }
109
110 #[cfg(not(any(cfail1,cfail4)))]
111 #[rustc_clean(except="hir_owner_nodes,typeck", cfg="cfail2")]
112 #[rustc_clean(cfg="cfail3")]
113 #[rustc_clean(except="hir_owner_nodes,typeck", cfg="cfail5")]
114 #[rustc_clean(cfg="cfail6")]
115 fn change_mutability(slice: &mut [u32]) -> u32 {
116     (&    slice[3..5])[0]
117 }
118
119
120
121 // Exclusive to inclusive range
122 #[cfg(any(cfail1,cfail4))]
123 fn exclusive_to_inclusive_range(slice: &[u32]) -> &[u32] {
124     &slice[3.. 7]
125 }
126
127 #[cfg(not(any(cfail1,cfail4)))]
128 #[rustc_clean(except="hir_owner,hir_owner_nodes,typeck", cfg="cfail2")]
129 #[rustc_clean(cfg="cfail3")]
130 #[rustc_clean(except="hir_owner,hir_owner_nodes,typeck", cfg="cfail5")]
131 #[rustc_clean(cfg="cfail6")]
132 fn exclusive_to_inclusive_range(slice: &[u32]) -> &[u32] {
133     &slice[3..=7]
134 }