]> git.proxmox.com Git - rustc.git/blob - src/test/incremental/hashes/statics.rs
New upstream version 1.63.0+dfsg1
[rustc.git] / src / test / incremental / hashes / statics.rs
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
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 #![feature(linkage)]
21 #![feature(thread_local)]
22 #![crate_type="rlib"]
23
24
25 // Change static visibility
26 #[cfg(any(cfail1,cfail4))]
27 static STATIC_VISIBILITY: u8 = 0;
28
29 #[cfg(not(any(cfail1,cfail4)))]
30 #[rustc_clean(cfg="cfail2")]
31 #[rustc_clean(cfg="cfail3")]
32 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes")]
33 #[rustc_clean(cfg="cfail6")]
34 pub static STATIC_VISIBILITY: u8 = 0;
35
36
37 // Change static mutability
38 #[cfg(any(cfail1,cfail4))]
39 static STATIC_MUTABILITY: u8 = 0;
40
41 #[cfg(not(any(cfail1,cfail4)))]
42 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
43 #[rustc_clean(cfg="cfail3")]
44 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes")]
45 #[rustc_clean(cfg="cfail6")]
46 static mut STATIC_MUTABILITY: u8 = 0;
47
48
49 // Add linkage attribute
50 #[cfg(any(cfail1,cfail4))]
51 static STATIC_LINKAGE: u8 = 0;
52
53 #[cfg(not(any(cfail1,cfail4)))]
54 #[rustc_clean(cfg="cfail2")]
55 #[rustc_clean(cfg="cfail3")]
56 #[rustc_clean(cfg="cfail5")]
57 #[rustc_clean(cfg="cfail6")]
58 #[linkage="weak_odr"]
59 static STATIC_LINKAGE: u8 = 0;
60
61
62 // Add no_mangle attribute
63 #[cfg(any(cfail1,cfail4))]
64 static STATIC_NO_MANGLE: u8 = 0;
65
66 #[cfg(not(any(cfail1,cfail4)))]
67 #[rustc_clean(cfg="cfail2")]
68 #[rustc_clean(cfg="cfail3")]
69 #[rustc_clean(cfg="cfail5")]
70 #[rustc_clean(cfg="cfail6")]
71 #[no_mangle]
72 static STATIC_NO_MANGLE: u8 = 0;
73
74
75 // Add thread_local attribute
76 #[cfg(any(cfail1,cfail4))]
77 static STATIC_THREAD_LOCAL: u8 = 0;
78
79 #[cfg(not(any(cfail1,cfail4)))]
80 #[rustc_clean(cfg="cfail2")]
81 #[rustc_clean(cfg="cfail3")]
82 #[rustc_clean(cfg="cfail5")]
83 #[rustc_clean(cfg="cfail6")]
84 #[thread_local]
85 static STATIC_THREAD_LOCAL: u8 = 0;
86
87
88 // Change type from i16 to u64
89 #[cfg(any(cfail1,cfail4))]
90 static STATIC_CHANGE_TYPE_1: i16 = 0;
91
92 #[cfg(not(any(cfail1,cfail4)))]
93 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
94 #[rustc_clean(cfg="cfail3")]
95 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,type_of")]
96 #[rustc_clean(cfg="cfail6")]
97 static STATIC_CHANGE_TYPE_1: u64 = 0;
98
99
100 // Change type from Option<i8> to Option<u16>
101 #[cfg(any(cfail1,cfail4))]
102 static STATIC_CHANGE_TYPE_2: Option<i8> = None;
103
104 #[cfg(not(any(cfail1,cfail4)))]
105 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
106 #[rustc_clean(cfg="cfail3")]
107 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,type_of")]
108 #[rustc_clean(cfg="cfail6")]
109 static STATIC_CHANGE_TYPE_2: Option<u16> = None;
110
111
112 // Change value between simple literals
113 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes")]
114 #[rustc_clean(cfg="cfail3")]
115 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes")]
116 #[rustc_clean(cfg="cfail6")]
117 static STATIC_CHANGE_VALUE_1: i16 = {
118 #[cfg(any(cfail1,cfail4))]
119 { 1 }
120
121 #[cfg(not(any(cfail1,cfail4)))]
122 { 2 }
123 };
124
125
126 // Change value between expressions
127 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes")]
128 #[rustc_clean(cfg="cfail3")]
129 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes")]
130 #[rustc_clean(cfg="cfail6")]
131 static STATIC_CHANGE_VALUE_2: i16 = {
132 #[cfg(any(cfail1,cfail4))]
133 { 1 + 1 }
134
135 #[cfg(not(any(cfail1,cfail4)))]
136 { 1 + 2 }
137 };
138
139 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes")]
140 #[rustc_clean(cfg="cfail3")]
141 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes")]
142 #[rustc_clean(cfg="cfail6")]
143 static STATIC_CHANGE_VALUE_3: i16 = {
144 #[cfg(any(cfail1,cfail4))]
145 { 2 + 3 }
146
147 #[cfg(not(any(cfail1,cfail4)))]
148 { 2 * 3 }
149 };
150
151 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes")]
152 #[rustc_clean(cfg="cfail3")]
153 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes")]
154 #[rustc_clean(cfg="cfail6")]
155 static STATIC_CHANGE_VALUE_4: i16 = {
156 #[cfg(any(cfail1,cfail4))]
157 { 1 + 2 * 3 }
158
159 #[cfg(not(any(cfail1,cfail4)))]
160 { 1 + 2 * 4 }
161 };
162
163
164 // Change type indirectly
165 struct ReferencedType1;
166 struct ReferencedType2;
167
168 mod static_change_type_indirectly {
169 #[cfg(any(cfail1,cfail4))]
170 use super::ReferencedType1 as Type;
171
172 #[cfg(not(any(cfail1,cfail4)))]
173 use super::ReferencedType2 as Type;
174
175 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
176 #[rustc_clean(cfg="cfail3")]
177 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,type_of")]
178 #[rustc_clean(cfg="cfail6")]
179 static STATIC_CHANGE_TYPE_INDIRECTLY_1: Type = Type;
180
181 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
182 #[rustc_clean(cfg="cfail3")]
183 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,type_of")]
184 #[rustc_clean(cfg="cfail6")]
185 static STATIC_CHANGE_TYPE_INDIRECTLY_2: Option<Type> = None;
186 }