]> git.lizzy.rs Git - rust.git/blob - tests/incremental/hashes/let_expressions.rs
Move /src/test to /tests
[rust.git] / tests / incremental / hashes / let_expressions.rs
1 // This test case tests the incremental compilation hash (ICH) implementation
2 // for let expressions.
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 #![crate_type="rlib"]
18
19 // Change Name -----------------------------------------------------------------
20 #[cfg(any(cfail1,cfail4))]
21 pub fn change_name() {
22     let _x = 2u64;
23 }
24
25 #[cfg(not(any(cfail1,cfail4)))]
26 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir")]
27 #[rustc_clean(cfg="cfail3")]
28 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir")]
29 #[rustc_clean(cfg="cfail6")]
30 pub fn change_name() {
31     let _y = 2u64;
32 }
33
34
35
36 // Add Type --------------------------------------------------------------------
37 #[cfg(any(cfail1,cfail4))]
38 pub fn add_type() {
39     let _x      = 2u32;
40 }
41
42 #[cfg(not(any(cfail1,cfail4)))]
43 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,typeck")]
44 #[rustc_clean(cfg="cfail3")]
45 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,typeck")]
46 #[rustc_clean(cfg="cfail6")]
47 pub fn add_type() {
48     let _x: u32 = 2u32;
49 }
50
51
52
53 // Change Type -----------------------------------------------------------------
54 #[cfg(any(cfail1,cfail4))]
55 pub fn change_type() {
56     let _x: u64 = 2;
57 }
58
59 #[cfg(not(any(cfail1,cfail4)))]
60 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,typeck,optimized_mir")]
61 #[rustc_clean(cfg="cfail3")]
62 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,typeck,optimized_mir")]
63 #[rustc_clean(cfg="cfail6")]
64 pub fn change_type() {
65     let _x: u8  = 2;
66 }
67
68
69
70 // Change Mutability of Reference Type -----------------------------------------
71 #[cfg(any(cfail1,cfail4))]
72 pub fn change_mutability_of_reference_type() {
73     let _x: &    u64;
74 }
75
76 #[cfg(not(any(cfail1,cfail4)))]
77 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,typeck,optimized_mir")]
78 #[rustc_clean(cfg="cfail3")]
79 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,typeck,optimized_mir")]
80 #[rustc_clean(cfg="cfail6")]
81 pub fn change_mutability_of_reference_type() {
82     let _x: &mut u64;
83 }
84
85
86
87 // Change Mutability of Slot ---------------------------------------------------
88 #[cfg(any(cfail1,cfail4))]
89 pub fn change_mutability_of_slot() {
90     let mut _x: u64 = 0;
91 }
92
93 #[cfg(not(any(cfail1,cfail4)))]
94 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,typeck,optimized_mir")]
95 #[rustc_clean(cfg="cfail3")]
96 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,typeck,optimized_mir")]
97 #[rustc_clean(cfg="cfail6")]
98 pub fn change_mutability_of_slot() {
99     let     _x: u64 = 0;
100 }
101
102
103
104 // Change Simple Binding to Pattern --------------------------------------------
105 #[cfg(any(cfail1,cfail4))]
106 pub fn change_simple_binding_to_pattern() {
107     let  _x      = (0u8, 'x');
108 }
109
110 #[cfg(not(any(cfail1,cfail4)))]
111 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,typeck,optimized_mir")]
112 #[rustc_clean(cfg="cfail3")]
113 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,typeck,optimized_mir")]
114 #[rustc_clean(cfg="cfail6")]
115 pub fn change_simple_binding_to_pattern() {
116     let (_a, _b) = (0u8, 'x');
117 }
118
119
120
121 // Change Name in Pattern ------------------------------------------------------
122 #[cfg(any(cfail1,cfail4))]
123 pub fn change_name_in_pattern() {
124     let (_a, _b) = (1u8, 'y');
125 }
126
127 #[cfg(not(any(cfail1,cfail4)))]
128 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir")]
129 #[rustc_clean(cfg="cfail3")]
130 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir")]
131 #[rustc_clean(cfg="cfail6")]
132 pub fn change_name_in_pattern() {
133     let (_a, _c) = (1u8, 'y');
134 }
135
136
137
138 // Add `ref` in Pattern --------------------------------------------------------
139 #[cfg(any(cfail1,cfail4))]
140 pub fn add_ref_in_pattern() {
141     let (    _a, _b) = (1u8, 'y');
142 }
143
144 #[cfg(not(any(cfail1,cfail4)))]
145 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,typeck,optimized_mir")]
146 #[rustc_clean(cfg="cfail3")]
147 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,typeck,optimized_mir")]
148 #[rustc_clean(cfg="cfail6")]
149 pub fn add_ref_in_pattern() {
150     let (ref _a, _b) = (1u8, 'y');
151 }
152
153
154
155 // Add `&` in Pattern ----------------------------------------------------------
156 #[cfg(any(cfail1,cfail4))]
157 pub fn add_amp_in_pattern() {
158     let ( _a, _b) = (&1u8, 'y');
159 }
160
161 #[cfg(not(any(cfail1,cfail4)))]
162 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,typeck,optimized_mir")]
163 #[rustc_clean(cfg="cfail3")]
164 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,typeck,optimized_mir")]
165 #[rustc_clean(cfg="cfail6")]
166 pub fn add_amp_in_pattern() {
167     let (&_a, _b) = (&1u8, 'y');
168 }
169
170
171
172 // Change Mutability of Binding in Pattern -------------------------------------
173 #[cfg(any(cfail1,cfail4))]
174 pub fn change_mutability_of_binding_in_pattern() {
175     let (    _a, _b) = (99u8, 'q');
176 }
177
178 #[cfg(not(any(cfail1,cfail4)))]
179 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,typeck,optimized_mir")]
180 #[rustc_clean(cfg="cfail3")]
181 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,typeck,optimized_mir")]
182 #[rustc_clean(cfg="cfail6")]
183 pub fn change_mutability_of_binding_in_pattern() {
184     let (mut _a, _b) = (99u8, 'q');
185 }
186
187
188
189 // Add Initializer -------------------------------------------------------------
190 #[cfg(any(cfail1,cfail4))]
191 pub fn add_initializer() {
192     let _x: i16       ;
193 }
194
195 #[cfg(not(any(cfail1,cfail4)))]
196 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,typeck,optimized_mir")]
197 #[rustc_clean(cfg="cfail3")]
198 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,typeck,optimized_mir")]
199 #[rustc_clean(cfg="cfail6")]
200 pub fn add_initializer() {
201     let _x: i16 = 3i16;
202 }
203
204
205
206 // Change Initializer ----------------------------------------------------------
207 #[cfg(any(cfail1,cfail4))]
208 pub fn change_initializer() {
209     let _x = 4u16;
210 }
211
212 #[cfg(not(any(cfail1,cfail4)))]
213 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes")]
214 #[rustc_clean(cfg="cfail3")]
215 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes")]
216 #[rustc_clean(cfg="cfail6")]
217 pub fn change_initializer() {
218     let _x = 5u16;
219 }