]> git.proxmox.com Git - rustc.git/blob - src/test/incremental/hashes/consts.rs
New upstream version 1.63.0+dfsg1
[rustc.git] / src / test / incremental / hashes / consts.rs
1 // This test case tests the incremental compilation hash (ICH) implementation
2 // for consts.
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
10 // compile-flags: -Z query-dep-graph -O
11
12 #![allow(warnings)]
13 #![feature(rustc_attrs)]
14 #![crate_type="rlib"]
15
16
17 // Change const visibility
18 #[cfg(cfail1)]
19 const CONST_VISIBILITY: u8 = 0;
20
21 #[cfg(not(cfail1))]
22 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
23 #[rustc_clean(cfg="cfail3")]
24 pub const CONST_VISIBILITY: u8 = 0;
25
26
27 // Change type from i32 to u32
28 #[cfg(cfail1)]
29 const CONST_CHANGE_TYPE_1: i32 = 0;
30
31 #[cfg(not(cfail1))]
32 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
33 #[rustc_clean(cfg="cfail3")]
34 const CONST_CHANGE_TYPE_1: u32 = 0;
35
36
37 // Change type from Option<u32> to Option<u64>
38 #[cfg(cfail1)]
39 const CONST_CHANGE_TYPE_2: Option<u32> = None;
40
41 #[cfg(not(cfail1))]
42 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
43 #[rustc_clean(cfg="cfail3")]
44 const CONST_CHANGE_TYPE_2: Option<u64> = None;
45
46
47 // Change value between simple literals
48 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes")]
49 #[rustc_clean(cfg="cfail3")]
50 const CONST_CHANGE_VALUE_1: i16 = {
51 #[cfg(cfail1)]
52 { 1 }
53
54 #[cfg(not(cfail1))]
55 { 2 }
56 };
57
58
59 // Change value between expressions
60 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes")]
61 #[rustc_clean(cfg="cfail3")]
62 const CONST_CHANGE_VALUE_2: i16 = {
63 #[cfg(cfail1)]
64 { 1 + 1 }
65
66 #[cfg(not(cfail1))]
67 { 1 + 2 }
68 };
69
70 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes")]
71 #[rustc_clean(cfg="cfail3")]
72 const CONST_CHANGE_VALUE_3: i16 = {
73 #[cfg(cfail1)]
74 { 2 + 3 }
75
76 #[cfg(not(cfail1))]
77 { 2 * 3 }
78 };
79
80 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes")]
81 #[rustc_clean(cfg="cfail3")]
82 const CONST_CHANGE_VALUE_4: i16 = {
83 #[cfg(cfail1)]
84 { 1 + 2 * 3 }
85
86 #[cfg(not(cfail1))]
87 { 1 + 2 * 4 }
88 };
89
90
91 // Change type indirectly
92 struct ReferencedType1;
93 struct ReferencedType2;
94
95 mod const_change_type_indirectly {
96 #[cfg(cfail1)]
97 use super::ReferencedType1 as Type;
98
99 #[cfg(not(cfail1))]
100 use super::ReferencedType2 as Type;
101
102 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
103 #[rustc_clean(cfg="cfail3")]
104 const CONST_CHANGE_TYPE_INDIRECTLY_1: Type = Type;
105
106 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
107 #[rustc_clean(cfg="cfail3")]
108 const CONST_CHANGE_TYPE_INDIRECTLY_2: Option<Type> = None;
109 }