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