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)]
28 pub struct RegularStruct {
34 // Change field value (regular struct) -----------------------------------------
36 pub fn change_field_value_regular_struct() -> RegularStruct {
45 #[rustc_clean(cfg="cfail2", except="HirBody,MirOptimized,MirValidated")]
46 #[rustc_clean(cfg="cfail3")]
47 pub fn change_field_value_regular_struct() -> RegularStruct {
57 // Change field order (regular struct) -----------------------------------------
59 pub fn change_field_order_regular_struct() -> RegularStruct {
68 #[rustc_clean(cfg="cfail2", except="HirBody,TypeckTables")]
69 #[rustc_clean(cfg="cfail3")]
70 pub fn change_field_order_regular_struct() -> RegularStruct {
80 // Add field (regular struct) --------------------------------------------------
82 pub fn add_field_regular_struct() -> RegularStruct {
83 let struct1 = RegularStruct {
96 #[rustc_clean(cfg="cfail2", except="HirBody,MirOptimized,MirValidated,TypeckTables")]
97 #[rustc_clean(cfg="cfail3")]
98 pub fn add_field_regular_struct() -> RegularStruct {
99 let struct1 = RegularStruct {
114 // Change field label (regular struct) -----------------------------------------
116 pub fn change_field_label_regular_struct() -> RegularStruct {
117 let struct1 = RegularStruct {
131 #[rustc_clean(cfg="cfail2", except="HirBody,MirOptimized,MirValidated,TypeckTables")]
132 #[rustc_clean(cfg="cfail3")]
133 pub fn change_field_label_regular_struct() -> RegularStruct {
134 let struct1 = RegularStruct {
149 pub struct RegularStruct2 {
155 // Change constructor path (regular struct) ------------------------------------
157 pub fn change_constructor_path_regular_struct() {
158 let _ = RegularStruct {
166 #[rustc_clean(cfg="cfail2", except="HirBody,MirOptimized,MirValidated,TypeckTables")]
167 #[rustc_clean(cfg="cfail3")]
168 pub fn change_constructor_path_regular_struct() {
169 let _ = RegularStruct2 {
178 // Change constructor path indirectly (regular struct) -------------------------
179 pub mod change_constructor_path_indirectly_regular_struct {
181 use super::RegularStruct as Struct;
183 use super::RegularStruct2 as Struct;
187 except="FnSignature,Hir,HirBody,MirOptimized,MirValidated,TypeckTables"
189 #[rustc_clean(cfg="cfail3")]
190 pub fn function() -> Struct {
201 pub struct TupleStruct(i32, i64, i16);
203 // Change field value (tuple struct) -------------------------------------------
205 pub fn change_field_value_tuple_struct() -> TupleStruct {
210 #[rustc_clean(cfg="cfail2", except="HirBody,MirOptimized,MirValidated")]
211 #[rustc_clean(cfg="cfail3")]
212 pub fn change_field_value_tuple_struct() -> TupleStruct {
218 pub struct TupleStruct2(u16, u16, u16);
220 // Change constructor path (tuple struct) --------------------------------------
222 pub fn change_constructor_path_tuple_struct() {
223 let _ = TupleStruct(0, 1, 2);
227 #[rustc_clean(cfg="cfail2", except="HirBody,MirOptimized,MirValidated,TypeckTables")]
228 #[rustc_clean(cfg="cfail3")]
229 pub fn change_constructor_path_tuple_struct() {
230 let _ = TupleStruct2(0, 1, 2);
235 // Change constructor path indirectly (tuple struct) ---------------------------
236 pub mod change_constructor_path_indirectly_tuple_struct {
238 use super::TupleStruct as Struct;
240 use super::TupleStruct2 as Struct;
244 except="FnSignature,Hir,HirBody,MirOptimized,MirValidated,TypeckTables"
246 #[rustc_clean(cfg="cfail3")]
247 pub fn function() -> Struct {