]>
Commit | Line | Data |
---|---|---|
c30ab7b3 SL |
1 | // This test case tests the incremental compilation hash (ICH) implementation |
2 | // for statics. | |
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 | ||
416331ca | 8 | // build-pass (FIXME(62277): could be check-pass?) |
c30ab7b3 | 9 | // revisions: cfail1 cfail2 cfail3 |
ff7c6d11 | 10 | // compile-flags: -Z query-dep-graph -Zincremental-ignore-spans |
c30ab7b3 SL |
11 | |
12 | #![allow(warnings)] | |
13 | #![feature(rustc_attrs)] | |
14 | #![feature(linkage)] | |
15 | #![feature(thread_local)] | |
16 | #![crate_type="rlib"] | |
17 | ||
18 | ||
e1599b0c | 19 | // Change static visibility |
c30ab7b3 SL |
20 | #[cfg(cfail1)] |
21 | static STATIC_VISIBILITY: u8 = 0; | |
22 | ||
23 | #[cfg(not(cfail1))] | |
ba9703b0 | 24 | #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")] |
abe05a73 | 25 | #[rustc_clean(cfg="cfail3")] |
c30ab7b3 SL |
26 | pub static STATIC_VISIBILITY: u8 = 0; |
27 | ||
28 | ||
e1599b0c | 29 | // Change static mutability |
c30ab7b3 SL |
30 | #[cfg(cfail1)] |
31 | static STATIC_MUTABILITY: u8 = 0; | |
32 | ||
33 | #[cfg(not(cfail1))] | |
ba9703b0 | 34 | #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")] |
abe05a73 | 35 | #[rustc_clean(cfg="cfail3")] |
c30ab7b3 SL |
36 | static mut STATIC_MUTABILITY: u8 = 0; |
37 | ||
38 | ||
e1599b0c | 39 | // Add linkage attribute |
c30ab7b3 SL |
40 | #[cfg(cfail1)] |
41 | static STATIC_LINKAGE: u8 = 0; | |
42 | ||
43 | #[cfg(not(cfail1))] | |
ba9703b0 | 44 | #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")] |
abe05a73 | 45 | #[rustc_clean(cfg="cfail3")] |
c30ab7b3 SL |
46 | #[linkage="weak_odr"] |
47 | static STATIC_LINKAGE: u8 = 0; | |
48 | ||
49 | ||
e1599b0c | 50 | // Add no_mangle attribute |
c30ab7b3 SL |
51 | #[cfg(cfail1)] |
52 | static STATIC_NO_MANGLE: u8 = 0; | |
53 | ||
54 | #[cfg(not(cfail1))] | |
ba9703b0 | 55 | #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")] |
abe05a73 | 56 | #[rustc_clean(cfg="cfail3")] |
c30ab7b3 SL |
57 | #[no_mangle] |
58 | static STATIC_NO_MANGLE: u8 = 0; | |
59 | ||
60 | ||
e1599b0c | 61 | // Add thread_local attribute |
c30ab7b3 SL |
62 | #[cfg(cfail1)] |
63 | static STATIC_THREAD_LOCAL: u8 = 0; | |
64 | ||
65 | #[cfg(not(cfail1))] | |
ba9703b0 | 66 | #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")] |
abe05a73 | 67 | #[rustc_clean(cfg="cfail3")] |
c30ab7b3 SL |
68 | #[thread_local] |
69 | static STATIC_THREAD_LOCAL: u8 = 0; | |
70 | ||
71 | ||
e1599b0c | 72 | // Change type from i16 to u64 |
c30ab7b3 SL |
73 | #[cfg(cfail1)] |
74 | static STATIC_CHANGE_TYPE_1: i16 = 0; | |
75 | ||
76 | #[cfg(not(cfail1))] | |
ba9703b0 | 77 | #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")] |
abe05a73 | 78 | #[rustc_clean(cfg="cfail3")] |
c30ab7b3 SL |
79 | static STATIC_CHANGE_TYPE_1: u64 = 0; |
80 | ||
81 | ||
e1599b0c | 82 | // Change type from Option<i8> to Option<u16> |
c30ab7b3 SL |
83 | #[cfg(cfail1)] |
84 | static STATIC_CHANGE_TYPE_2: Option<i8> = None; | |
85 | ||
86 | #[cfg(not(cfail1))] | |
ba9703b0 | 87 | #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")] |
abe05a73 | 88 | #[rustc_clean(cfg="cfail3")] |
c30ab7b3 SL |
89 | static STATIC_CHANGE_TYPE_2: Option<u16> = None; |
90 | ||
91 | ||
e1599b0c | 92 | // Change value between simple literals |
ba9703b0 | 93 | #[rustc_clean(cfg="cfail2", except="hir_owner_nodes")] |
abe05a73 | 94 | #[rustc_clean(cfg="cfail3")] |
abe05a73 XL |
95 | static STATIC_CHANGE_VALUE_1: i16 = { |
96 | #[cfg(cfail1)] | |
97 | { 1 } | |
c30ab7b3 | 98 | |
abe05a73 XL |
99 | #[cfg(not(cfail1))] |
100 | { 2 } | |
101 | }; | |
c30ab7b3 | 102 | |
c30ab7b3 | 103 | |
e1599b0c | 104 | // Change value between expressions |
ba9703b0 | 105 | #[rustc_clean(cfg="cfail2", except="hir_owner_nodes")] |
abe05a73 | 106 | #[rustc_clean(cfg="cfail3")] |
abe05a73 XL |
107 | static STATIC_CHANGE_VALUE_2: i16 = { |
108 | #[cfg(cfail1)] | |
109 | { 1 + 1 } | |
c30ab7b3 | 110 | |
abe05a73 XL |
111 | #[cfg(not(cfail1))] |
112 | { 1 + 2 } | |
113 | }; | |
c30ab7b3 | 114 | |
ba9703b0 | 115 | #[rustc_clean(cfg="cfail2", except="hir_owner_nodes")] |
abe05a73 | 116 | #[rustc_clean(cfg="cfail3")] |
abe05a73 XL |
117 | static STATIC_CHANGE_VALUE_3: i16 = { |
118 | #[cfg(cfail1)] | |
119 | { 2 + 3 } | |
c30ab7b3 | 120 | |
abe05a73 XL |
121 | #[cfg(not(cfail1))] |
122 | { 2 * 3 } | |
123 | }; | |
c30ab7b3 | 124 | |
ba9703b0 | 125 | #[rustc_clean(cfg="cfail2", except="hir_owner_nodes")] |
abe05a73 | 126 | #[rustc_clean(cfg="cfail3")] |
abe05a73 XL |
127 | static STATIC_CHANGE_VALUE_4: i16 = { |
128 | #[cfg(cfail1)] | |
129 | { 1 + 2 * 3 } | |
130 | ||
131 | #[cfg(not(cfail1))] | |
132 | { 1 + 2 * 4 } | |
133 | }; | |
c30ab7b3 SL |
134 | |
135 | ||
e1599b0c | 136 | // Change type indirectly |
c30ab7b3 SL |
137 | struct ReferencedType1; |
138 | struct ReferencedType2; | |
139 | ||
140 | mod static_change_type_indirectly { | |
141 | #[cfg(cfail1)] | |
142 | use super::ReferencedType1 as Type; | |
143 | ||
144 | #[cfg(not(cfail1))] | |
145 | use super::ReferencedType2 as Type; | |
146 | ||
ba9703b0 | 147 | #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")] |
abe05a73 | 148 | #[rustc_clean(cfg="cfail3")] |
c30ab7b3 SL |
149 | static STATIC_CHANGE_TYPE_INDIRECTLY_1: Type = Type; |
150 | ||
ba9703b0 | 151 | #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")] |
abe05a73 | 152 | #[rustc_clean(cfg="cfail3")] |
c30ab7b3 SL |
153 | static STATIC_CHANGE_TYPE_INDIRECTLY_2: Option<Type> = None; |
154 | } |