1 // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
12 // This test case tests the incremental compilation hash (ICH) implementation
13 // for struct constructor expressions.
15 // The general pattern followed here is: Change one thing between rev1 and rev2
16 // and make sure that the hash has changed, then change nothing between rev2 and
17 // rev3 and make sure that the hash has not changed.
20 // revisions: cfail1 cfail2 cfail3
21 // compile-flags: -Z query-dep-graph -Zincremental-ignore-spans
24 #![feature(rustc_attrs)]
37 // Change field value (struct-like) -----------------------------------------
39 pub fn change_field_value_struct_like() -> Enum {
48 #[rustc_clean(cfg="cfail2", except="HirBody,MirOptimized,MirValidated")]
49 #[rustc_clean(cfg="cfail3")]
50 pub fn change_field_value_struct_like() -> Enum {
60 // Change field order (struct-like) -----------------------------------------
62 pub fn change_field_order_struct_like() -> Enum {
71 #[rustc_clean(cfg="cfail2", except="HirBody,TypeckTables")]
72 #[rustc_clean(cfg="cfail3")]
73 // FIXME(michaelwoerister):Interesting. I would have thought that that changes the MIR. And it
74 // would if it were not all constants
75 pub fn change_field_order_struct_like() -> Enum {
96 Tuple2(u64, u64, u64),
99 // Change constructor path (struct-like) ------------------------------------
101 pub fn change_constructor_path_struct_like() {
102 let _ = Enum::Struct {
110 #[rustc_clean(cfg="cfail2", except="HirBody,MirOptimized,MirValidated,TypeckTables")]
111 #[rustc_clean(cfg="cfail3")]
112 pub fn change_constructor_path_struct_like() {
113 let _ = Enum2::Struct {
122 // Change variant (regular struct) ------------------------------------
124 pub fn change_constructor_variant_struct_like() {
125 let _ = Enum2::Struct {
133 #[rustc_clean(cfg="cfail2", except="HirBody,MirOptimized,MirValidated")]
134 #[rustc_clean(cfg="cfail3")]
135 pub fn change_constructor_variant_struct_like() {
136 let _ = Enum2::Struct2 {
144 // Change constructor path indirectly (struct-like) -------------------------
145 pub mod change_constructor_path_indirectly_struct_like {
147 use super::Enum as TheEnum;
149 use super::Enum2 as TheEnum;
153 except="FnSignature,Hir,HirBody,MirOptimized,MirValidated,\
156 #[rustc_clean(cfg="cfail3")]
157 pub fn function() -> TheEnum {
167 // Change constructor variant indirectly (struct-like) ---------------------------
168 pub mod change_constructor_variant_indirectly_struct_like {
171 use super::Enum2::Struct as Variant;
173 use super::Enum2::Struct2 as Variant;
175 #[rustc_clean(cfg="cfail2", except="HirBody,MirOptimized,MirValidated")]
176 #[rustc_clean(cfg="cfail3")]
177 pub fn function() -> Enum2 {
187 // Change field value (tuple-like) -------------------------------------------
189 pub fn change_field_value_tuple_like() -> Enum {
194 #[rustc_clean(cfg="cfail2", except="HirBody,MirOptimized,MirValidated")]
195 #[rustc_clean(cfg="cfail3")]
196 pub fn change_field_value_tuple_like() -> Enum {
202 // Change constructor path (tuple-like) --------------------------------------
204 pub fn change_constructor_path_tuple_like() {
205 let _ = Enum::Tuple(0, 1, 2);
211 except="HirBody,MirOptimized,MirValidated,TypeckTables"
213 #[rustc_clean(cfg="cfail3")]
214 pub fn change_constructor_path_tuple_like() {
215 let _ = Enum2::Tuple(0, 1, 2);
220 // Change constructor variant (tuple-like) --------------------------------------
222 pub fn change_constructor_variant_tuple_like() {
223 let _ = Enum2::Tuple(0, 1, 2);
229 except="HirBody,MirOptimized,MirValidated,TypeckTables"
231 #[rustc_clean(cfg="cfail3")]
232 pub fn change_constructor_variant_tuple_like() {
233 let _ = Enum2::Tuple2(0, 1, 2);
237 // Change constructor path indirectly (tuple-like) ---------------------------
238 pub mod change_constructor_path_indirectly_tuple_like {
240 use super::Enum as TheEnum;
242 use super::Enum2 as TheEnum;
246 except="FnSignature,Hir,HirBody,MirOptimized,MirValidated,\
249 #[rustc_clean(cfg="cfail3")]
250 pub fn function() -> TheEnum {
251 TheEnum::Tuple(0, 1, 2)
257 // Change constructor variant indirectly (tuple-like) ---------------------------
258 pub mod change_constructor_variant_indirectly_tuple_like {
261 use super::Enum2::Tuple as Variant;
263 use super::Enum2::Tuple2 as Variant;
265 #[rustc_clean(cfg="cfail2", except="HirBody,MirOptimized,MirValidated,TypeckTables")]
266 #[rustc_clean(cfg="cfail3")]
267 pub fn function() -> Enum2 {
285 // Change constructor path (C-like) --------------------------------------
287 pub fn change_constructor_path_c_like() {
292 #[rustc_clean(cfg="cfail2", except="HirBody,MirOptimized,MirValidated,TypeckTables")]
293 #[rustc_clean(cfg="cfail3")]
294 pub fn change_constructor_path_c_like() {
300 // Change constructor variant (C-like) --------------------------------------
302 pub fn change_constructor_variant_c_like() {
307 #[rustc_clean(cfg="cfail2", except="HirBody,MirOptimized,MirValidated")]
308 #[rustc_clean(cfg="cfail3")]
309 pub fn change_constructor_variant_c_like() {
314 // Change constructor path indirectly (C-like) ---------------------------
315 pub mod change_constructor_path_indirectly_c_like {
317 use super::Clike as TheEnum;
319 use super::Clike2 as TheEnum;
323 except="FnSignature,Hir,HirBody,MirOptimized,MirValidated,\
326 #[rustc_clean(cfg="cfail3")]
327 pub fn function() -> TheEnum {
334 // Change constructor variant indirectly (C-like) ---------------------------
335 pub mod change_constructor_variant_indirectly_c_like {
338 use super::Clike::A as Variant;
340 use super::Clike::B as Variant;
342 #[rustc_clean(cfg="cfail2", except="HirBody,MirOptimized,MirValidated")]
343 #[rustc_clean(cfg="cfail3")]
344 pub fn function() -> Clike {