]> git.lizzy.rs Git - rust.git/blob - src/test/incremental/hashes/indexing_expressions.rs
Rollup merge of #95446 - notseanray:master, r=Mark-Simulacrum
[rust.git] / src / test / 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 // [cfail4]compile-flags: -Zincremental-relative-spans
15 // [cfail5]compile-flags: -Zincremental-relative-spans
16 // [cfail6]compile-flags: -Zincremental-relative-spans
17
18 #![allow(warnings)]
19 #![feature(rustc_attrs)]
20 #![crate_type="rlib"]
21
22 // Change simple index
23 #[cfg(any(cfail1,cfail4))]
24 fn change_simple_index(slice: &[u32]) -> u32 {
25     slice[3]
26 }
27
28 #[cfg(not(any(cfail1,cfail4)))]
29 #[rustc_clean(except="hir_owner_nodes", cfg="cfail2")]
30 #[rustc_clean(cfg="cfail3")]
31 #[rustc_clean(except="hir_owner_nodes", cfg="cfail5")]
32 #[rustc_clean(cfg="cfail6")]
33 fn change_simple_index(slice: &[u32]) -> u32 {
34     slice[4]
35 }
36
37
38
39 // Change lower bound
40 #[cfg(any(cfail1,cfail4))]
41 fn change_lower_bound(slice: &[u32]) -> &[u32] {
42     &slice[3..5]
43 }
44
45 #[cfg(not(any(cfail1,cfail4)))]
46 #[rustc_clean(except="hir_owner_nodes", cfg="cfail2")]
47 #[rustc_clean(cfg="cfail3")]
48 #[rustc_clean(except="hir_owner_nodes", cfg="cfail5")]
49 #[rustc_clean(cfg="cfail6")]
50 fn change_lower_bound(slice: &[u32]) -> &[u32] {
51     &slice[2..5]
52 }
53
54
55
56 // Change upper bound
57 #[cfg(any(cfail1,cfail4))]
58 fn change_upper_bound(slice: &[u32]) -> &[u32] {
59     &slice[3..5]
60 }
61
62 #[cfg(not(any(cfail1,cfail4)))]
63 #[rustc_clean(except="hir_owner_nodes", cfg="cfail2")]
64 #[rustc_clean(cfg="cfail3")]
65 #[rustc_clean(except="hir_owner_nodes", cfg="cfail5")]
66 #[rustc_clean(cfg="cfail6")]
67 fn change_upper_bound(slice: &[u32]) -> &[u32] {
68     &slice[3..7]
69 }
70
71
72
73 // Add lower bound
74 #[cfg(any(cfail1,cfail4))]
75 fn add_lower_bound(slice: &[u32]) -> &[u32] {
76     &slice[ ..4]
77 }
78
79 #[cfg(not(any(cfail1,cfail4)))]
80 #[rustc_clean(except="hir_owner,hir_owner_nodes,typeck", cfg="cfail2")]
81 #[rustc_clean(cfg="cfail3")]
82 #[rustc_clean(except="hir_owner,hir_owner_nodes,typeck", cfg="cfail5")]
83 #[rustc_clean(cfg="cfail6")]
84 fn add_lower_bound(slice: &[u32]) -> &[u32] {
85     &slice[3..4]
86 }
87
88
89
90 // Add upper bound
91 #[cfg(any(cfail1,cfail4))]
92 fn add_upper_bound(slice: &[u32]) -> &[u32] {
93     &slice[3.. ]
94 }
95
96 #[cfg(not(any(cfail1,cfail4)))]
97 #[rustc_clean(except="hir_owner,hir_owner_nodes,typeck", cfg="cfail2")]
98 #[rustc_clean(cfg="cfail3")]
99 #[rustc_clean(except="hir_owner,hir_owner_nodes,typeck", cfg="cfail5")]
100 #[rustc_clean(cfg="cfail6")]
101 fn add_upper_bound(slice: &[u32]) -> &[u32] {
102     &slice[3..7]
103 }
104
105
106
107 // Change mutability
108 #[cfg(any(cfail1,cfail4))]
109 fn change_mutability(slice: &mut [u32]) -> u32 {
110     (&mut slice[3..5])[0]
111 }
112
113 #[cfg(not(any(cfail1,cfail4)))]
114 #[rustc_clean(except="hir_owner_nodes,typeck", cfg="cfail2")]
115 #[rustc_clean(cfg="cfail3")]
116 #[rustc_clean(except="hir_owner_nodes,typeck", cfg="cfail5")]
117 #[rustc_clean(cfg="cfail6")]
118 fn change_mutability(slice: &mut [u32]) -> u32 {
119     (&    slice[3..5])[0]
120 }
121
122
123
124 // Exclusive to inclusive range
125 #[cfg(any(cfail1,cfail4))]
126 fn exclusive_to_inclusive_range(slice: &[u32]) -> &[u32] {
127     &slice[3.. 7]
128 }
129
130 #[cfg(not(any(cfail1,cfail4)))]
131 #[rustc_clean(except="hir_owner,hir_owner_nodes,typeck", cfg="cfail2")]
132 #[rustc_clean(cfg="cfail3")]
133 #[rustc_clean(except="hir_owner,hir_owner_nodes,typeck", cfg="cfail5")]
134 #[rustc_clean(cfg="cfail6")]
135 fn exclusive_to_inclusive_range(slice: &[u32]) -> &[u32] {
136     &slice[3..=7]
137 }