]> git.lizzy.rs Git - rust.git/blob - src/test/incremental/hashes/statics.rs
Add load_cached query modifier and keep dep node names consistent with query names
[rust.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 // compile-pass
9 // revisions: cfail1 cfail2 cfail3
10 // compile-flags: -Z query-dep-graph -Zincremental-ignore-spans
11
12 #![allow(warnings)]
13 #![feature(rustc_attrs)]
14 #![feature(linkage)]
15 #![feature(thread_local)]
16 #![crate_type="rlib"]
17
18
19 // Change static visibility ---------------------------------------------------
20 #[cfg(cfail1)]
21 static STATIC_VISIBILITY: u8 = 0;
22
23 #[cfg(not(cfail1))]
24 #[rustc_clean(cfg="cfail2", except="Hir,HirBody")]
25 #[rustc_clean(cfg="cfail3")]
26 pub static STATIC_VISIBILITY: u8 = 0;
27
28
29 // Change static mutability ---------------------------------------------------
30 #[cfg(cfail1)]
31 static STATIC_MUTABILITY: u8 = 0;
32
33 #[cfg(not(cfail1))]
34 #[rustc_clean(cfg="cfail2", except="Hir,HirBody")]
35 #[rustc_clean(cfg="cfail3")]
36 static mut STATIC_MUTABILITY: u8 = 0;
37
38
39 // Add linkage attribute ------------------------------------------------------
40 #[cfg(cfail1)]
41 static STATIC_LINKAGE: u8 = 0;
42
43 #[cfg(not(cfail1))]
44 #[rustc_clean(cfg="cfail2", except="Hir,HirBody")]
45 #[rustc_clean(cfg="cfail3")]
46 #[linkage="weak_odr"]
47 static STATIC_LINKAGE: u8 = 0;
48
49
50 // Add no_mangle attribute ----------------------------------------------------
51 #[cfg(cfail1)]
52 static STATIC_NO_MANGLE: u8 = 0;
53
54 #[cfg(not(cfail1))]
55 #[rustc_clean(cfg="cfail2", except="Hir,HirBody")]
56 #[rustc_clean(cfg="cfail3")]
57 #[no_mangle]
58 static STATIC_NO_MANGLE: u8 = 0;
59
60
61 // Add thread_local attribute -------------------------------------------------
62 #[cfg(cfail1)]
63 static STATIC_THREAD_LOCAL: u8 = 0;
64
65 #[cfg(not(cfail1))]
66 #[rustc_clean(cfg="cfail2", except="Hir,HirBody")]
67 #[rustc_clean(cfg="cfail3")]
68 #[thread_local]
69 static STATIC_THREAD_LOCAL: u8 = 0;
70
71
72 // Change type from i16 to u64 ------------------------------------------------
73 #[cfg(cfail1)]
74 static STATIC_CHANGE_TYPE_1: i16 = 0;
75
76 #[cfg(not(cfail1))]
77 #[rustc_clean(cfg="cfail2", except="Hir,HirBody,type_of")]
78 #[rustc_clean(cfg="cfail3")]
79 static STATIC_CHANGE_TYPE_1: u64 = 0;
80
81
82 // Change type from Option<i8> to Option<u16> ---------------------------------
83 #[cfg(cfail1)]
84 static STATIC_CHANGE_TYPE_2: Option<i8> = None;
85
86 #[cfg(not(cfail1))]
87 #[rustc_clean(cfg="cfail2", except="Hir,HirBody,type_of")]
88 #[rustc_clean(cfg="cfail3")]
89 static STATIC_CHANGE_TYPE_2: Option<u16> = None;
90
91
92 // Change value between simple literals ---------------------------------------
93 #[rustc_clean(cfg="cfail2", except="HirBody")]
94 #[rustc_clean(cfg="cfail3")]
95 static STATIC_CHANGE_VALUE_1: i16 = {
96     #[cfg(cfail1)]
97     { 1 }
98
99     #[cfg(not(cfail1))]
100     { 2 }
101 };
102
103
104 // Change value between expressions -------------------------------------------
105 #[rustc_clean(cfg="cfail2", except="HirBody")]
106 #[rustc_clean(cfg="cfail3")]
107 static STATIC_CHANGE_VALUE_2: i16 = {
108     #[cfg(cfail1)]
109     { 1 + 1 }
110
111     #[cfg(not(cfail1))]
112     { 1 + 2 }
113 };
114
115 #[rustc_clean(cfg="cfail2", except="HirBody")]
116 #[rustc_clean(cfg="cfail3")]
117 static STATIC_CHANGE_VALUE_3: i16 = {
118     #[cfg(cfail1)]
119     { 2 + 3 }
120
121     #[cfg(not(cfail1))]
122     { 2 * 3 }
123 };
124
125 #[rustc_clean(cfg="cfail2", except="HirBody")]
126 #[rustc_clean(cfg="cfail3")]
127 static STATIC_CHANGE_VALUE_4: i16 = {
128     #[cfg(cfail1)]
129     { 1 + 2 * 3 }
130
131     #[cfg(not(cfail1))]
132     { 1 + 2 * 4 }
133 };
134
135
136 // Change type indirectly -----------------------------------------------------
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
147     #[rustc_clean(cfg="cfail2", except="Hir,HirBody,type_of")]
148     #[rustc_clean(cfg="cfail3")]
149     static STATIC_CHANGE_TYPE_INDIRECTLY_1: Type = Type;
150
151     #[rustc_clean(cfg="cfail2", except="Hir,HirBody,type_of")]
152     #[rustc_clean(cfg="cfail3")]
153     static STATIC_CHANGE_TYPE_INDIRECTLY_2: Option<Type> = None;
154 }