]> git.proxmox.com Git - rustc.git/blame - tests/incremental/hashes/consts.rs
bump version to 1.80.1+dfsg1-1~bpo12+pve1
[rustc.git] / tests / incremental / hashes / consts.rs
CommitLineData
c30ab7b3
SL
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
c620b35d
FG
8//@ build-pass (FIXME(62277): could be check-pass?)
9//@ revisions: cfail1 cfail2 cfail3
10//@ compile-flags: -Z query-dep-graph -O
c30ab7b3
SL
11
12#![allow(warnings)]
13#![feature(rustc_attrs)]
14#![crate_type="rlib"]
15
16
e1599b0c 17// Change const visibility
c30ab7b3
SL
18#[cfg(cfail1)]
19const CONST_VISIBILITY: u8 = 0;
20
21#[cfg(not(cfail1))]
c0240ec0 22#[rustc_clean(cfg="cfail2", except="opt_hir_owner_nodes")]
abe05a73 23#[rustc_clean(cfg="cfail3")]
c30ab7b3
SL
24pub const CONST_VISIBILITY: u8 = 0;
25
26
e1599b0c 27// Change type from i32 to u32
c30ab7b3
SL
28#[cfg(cfail1)]
29const CONST_CHANGE_TYPE_1: i32 = 0;
30
31#[cfg(not(cfail1))]
c0240ec0 32#[rustc_clean(cfg="cfail2", except="opt_hir_owner_nodes,type_of")]
abe05a73 33#[rustc_clean(cfg="cfail3")]
c30ab7b3
SL
34const CONST_CHANGE_TYPE_1: u32 = 0;
35
36
e1599b0c 37// Change type from Option<u32> to Option<u64>
c30ab7b3
SL
38#[cfg(cfail1)]
39const CONST_CHANGE_TYPE_2: Option<u32> = None;
40
41#[cfg(not(cfail1))]
c0240ec0 42#[rustc_clean(cfg="cfail2", except="opt_hir_owner_nodes,type_of")]
abe05a73 43#[rustc_clean(cfg="cfail3")]
c30ab7b3
SL
44const CONST_CHANGE_TYPE_2: Option<u64> = None;
45
46
e1599b0c 47// Change value between simple literals
c0240ec0 48#[rustc_clean(cfg="cfail2", except="opt_hir_owner_nodes")]
abe05a73 49#[rustc_clean(cfg="cfail3")]
abe05a73
XL
50const CONST_CHANGE_VALUE_1: i16 = {
51 #[cfg(cfail1)]
52 { 1 }
53
54 #[cfg(not(cfail1))]
55 { 2 }
56};
c30ab7b3
SL
57
58
e1599b0c 59// Change value between expressions
c0240ec0 60#[rustc_clean(cfg="cfail2", except="opt_hir_owner_nodes")]
abe05a73 61#[rustc_clean(cfg="cfail3")]
abe05a73
XL
62const CONST_CHANGE_VALUE_2: i16 = {
63 #[cfg(cfail1)]
64 { 1 + 1 }
c30ab7b3 65
abe05a73
XL
66 #[cfg(not(cfail1))]
67 { 1 + 2 }
68};
c30ab7b3 69
c0240ec0 70#[rustc_clean(cfg="cfail2", except="opt_hir_owner_nodes")]
abe05a73 71#[rustc_clean(cfg="cfail3")]
abe05a73
XL
72const CONST_CHANGE_VALUE_3: i16 = {
73 #[cfg(cfail1)]
74 { 2 + 3 }
c30ab7b3 75
abe05a73
XL
76 #[cfg(not(cfail1))]
77 { 2 * 3 }
78};
c30ab7b3 79
c0240ec0 80#[rustc_clean(cfg="cfail2", except="opt_hir_owner_nodes")]
abe05a73 81#[rustc_clean(cfg="cfail3")]
abe05a73
XL
82const CONST_CHANGE_VALUE_4: i16 = {
83 #[cfg(cfail1)]
84 { 1 + 2 * 3 }
85
86 #[cfg(not(cfail1))]
87 { 1 + 2 * 4 }
88};
c30ab7b3
SL
89
90
e1599b0c 91// Change type indirectly
c30ab7b3
SL
92struct ReferencedType1;
93struct ReferencedType2;
94
95mod 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
c0240ec0 102 #[rustc_clean(cfg="cfail2", except="opt_hir_owner_nodes,type_of")]
abe05a73 103 #[rustc_clean(cfg="cfail3")]
c30ab7b3
SL
104 const CONST_CHANGE_TYPE_INDIRECTLY_1: Type = Type;
105
c0240ec0 106 #[rustc_clean(cfg="cfail2", except="opt_hir_owner_nodes,type_of")]
abe05a73 107 #[rustc_clean(cfg="cfail3")]
c30ab7b3
SL
108 const CONST_CHANGE_TYPE_INDIRECTLY_2: Option<Type> = None;
109}