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 function and method call 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
25 #![feature(rustc_attrs)]
28 fn callee1(_x
: u32, _y
: i64) {}
29 fn callee2(_x
: u32, _y
: i64) {}
32 // Change Callee (Function) ----------------------------------------------------
34 pub fn change_callee_function() {
39 #[rustc_clean(cfg="cfail2", except="HirBody,MirValidated,MirOptimized,TypeckTables")]
40 #[rustc_clean(cfg="cfail3")]
41 pub fn change_callee_function() {
47 // Change Argument (Function) --------------------------------------------------
49 pub fn change_argument_function() {
54 #[rustc_clean(cfg="cfail2", except="HirBody,MirValidated,MirOptimized")]
55 #[rustc_clean(cfg="cfail3")]
56 pub fn change_argument_function() {
62 // Change Callee Indirectly (Function) -----------------------------------------
63 mod change_callee_indirectly_function
{
65 use super::callee1
as callee
;
67 use super::callee2
as callee
;
69 #[rustc_clean(label="Hir", cfg="cfail2")]
70 #[rustc_clean(label="Hir", cfg="cfail3")]
71 #[rustc_dirty(label="HirBody", cfg="cfail2")]
72 #[rustc_clean(label="HirBody", cfg="cfail3")]
75 pub fn change_callee_indirectly_function() {
83 fn method1(&self, _x
: char, _y
: bool
) {}
84 fn method2(&self, _x
: char, _y
: bool
) {}
87 // Change Callee (Method) ------------------------------------------------------
89 pub fn change_callee_method() {
95 #[rustc_clean(cfg="cfail2", except="HirBody,MirValidated,MirOptimized,TypeckTables")]
96 #[rustc_clean(cfg="cfail3")]
97 pub fn change_callee_method() {
104 // Change Argument (Method) ----------------------------------------------------
106 pub fn change_argument_method() {
108 s
.method1('x'
, true);
112 #[rustc_clean(cfg="cfail2", except="HirBody,MirValidated,MirOptimized")]
113 #[rustc_clean(cfg="cfail3")]
114 pub fn change_argument_method() {
116 s
.method1('y'
, true);
121 // Change Callee (Method, UFCS) ------------------------------------------------
123 pub fn change_ufcs_callee_method() {
125 Struct
::method1(&s
, 'x'
, true);
129 #[rustc_clean(cfg="cfail2", except="HirBody,MirValidated,MirOptimized,TypeckTables")]
130 #[rustc_clean(cfg="cfail3")]
131 pub fn change_ufcs_callee_method() {
133 Struct
::method2(&s
, 'x'
, true);
138 // Change Argument (Method, UFCS) ----------------------------------------------
140 pub fn change_argument_method_ufcs() {
142 Struct
::method1(&s
, 'x'
, true);
146 #[rustc_clean(cfg="cfail2", except="HirBody,MirValidated,MirOptimized")]
147 #[rustc_clean(cfg="cfail3")]
148 pub fn change_argument_method_ufcs() {
150 Struct
::method1(&s
, 'x'
, false);
155 // Change To UFCS --------------------------------------------------------------
157 pub fn change_to_ufcs() {
159 s
.method1('x'
, true);
163 #[rustc_clean(cfg="cfail2", except="HirBody,MirValidated,MirOptimized,TypeckTables")]
164 #[rustc_clean(cfg="cfail3")]
165 // One might think this would be expanded in the HirBody/Mir, but it actually
166 // results in slightly different Hir/Mir.
167 pub fn change_to_ufcs() {
169 Struct
::method1(&s
, 'x'
, true);
175 fn method1(&self, _x
: char, _y
: bool
) {}
178 // Change UFCS Callee Indirectly -----------------------------------------------
179 pub mod change_ufcs_callee_indirectly
{
181 use super::Struct
as Struct
;
183 use super::Struct2
as Struct
;
185 #[rustc_clean(cfg="cfail2", except="HirBody,MirValidated,MirOptimized,TypeckTables")]
186 #[rustc_clean(cfg="cfail3")]
189 pub fn change_ufcs_callee_indirectly() {
191 Struct
::method1(&s
, 'q'
, false)