]> git.proxmox.com Git - rustc.git/blob - src/test/incremental/hashes/call_expressions.rs
New upstream version 1.27.1+dfsg1
[rustc.git] / src / test / incremental / hashes / call_expressions.rs
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.
4 //
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.
10
11
12 // This test case tests the incremental compilation hash (ICH) implementation
13 // for function and method call expressions.
14
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.
18
19 // compile-pass
20 // revisions: cfail1 cfail2 cfail3
21 // compile-flags: -Z query-dep-graph -Zincremental-ignore-spans
22
23
24 #![allow(warnings)]
25 #![feature(rustc_attrs)]
26 #![crate_type="rlib"]
27
28 fn callee1(_x: u32, _y: i64) {}
29 fn callee2(_x: u32, _y: i64) {}
30
31
32 // Change Callee (Function) ----------------------------------------------------
33 #[cfg(cfail1)]
34 pub fn change_callee_function() {
35 callee1(1, 2)
36 }
37
38 #[cfg(not(cfail1))]
39 #[rustc_clean(cfg="cfail2", except="HirBody,MirValidated,MirOptimized,TypeckTables")]
40 #[rustc_clean(cfg="cfail3")]
41 pub fn change_callee_function() {
42 callee2(1, 2)
43 }
44
45
46
47 // Change Argument (Function) --------------------------------------------------
48 #[cfg(cfail1)]
49 pub fn change_argument_function() {
50 callee1(1, 2)
51 }
52
53 #[cfg(not(cfail1))]
54 #[rustc_clean(cfg="cfail2", except="HirBody,MirValidated,MirOptimized")]
55 #[rustc_clean(cfg="cfail3")]
56 pub fn change_argument_function() {
57 callee1(1, 3)
58 }
59
60
61
62 // Change Callee Indirectly (Function) -----------------------------------------
63 mod change_callee_indirectly_function {
64 #[cfg(cfail1)]
65 use super::callee1 as callee;
66 #[cfg(not(cfail1))]
67 use super::callee2 as callee;
68
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")]
73
74
75 pub fn change_callee_indirectly_function() {
76 callee(1, 2)
77 }
78 }
79
80
81 struct Struct;
82 impl Struct {
83 fn method1(&self, _x: char, _y: bool) {}
84 fn method2(&self, _x: char, _y: bool) {}
85 }
86
87 // Change Callee (Method) ------------------------------------------------------
88 #[cfg(cfail1)]
89 pub fn change_callee_method() {
90 let s = Struct;
91 s.method1('x', true);
92 }
93
94 #[cfg(not(cfail1))]
95 #[rustc_clean(cfg="cfail2", except="HirBody,MirValidated,MirOptimized,TypeckTables")]
96 #[rustc_clean(cfg="cfail3")]
97 pub fn change_callee_method() {
98 let s = Struct;
99 s.method2('x', true);
100 }
101
102
103
104 // Change Argument (Method) ----------------------------------------------------
105 #[cfg(cfail1)]
106 pub fn change_argument_method() {
107 let s = Struct;
108 s.method1('x', true);
109 }
110
111 #[cfg(not(cfail1))]
112 #[rustc_clean(cfg="cfail2", except="HirBody,MirValidated,MirOptimized")]
113 #[rustc_clean(cfg="cfail3")]
114 pub fn change_argument_method() {
115 let s = Struct;
116 s.method1('y', true);
117 }
118
119
120
121 // Change Callee (Method, UFCS) ------------------------------------------------
122 #[cfg(cfail1)]
123 pub fn change_ufcs_callee_method() {
124 let s = Struct;
125 Struct::method1(&s, 'x', true);
126 }
127
128 #[cfg(not(cfail1))]
129 #[rustc_clean(cfg="cfail2", except="HirBody,MirValidated,MirOptimized,TypeckTables")]
130 #[rustc_clean(cfg="cfail3")]
131 pub fn change_ufcs_callee_method() {
132 let s = Struct;
133 Struct::method2(&s, 'x', true);
134 }
135
136
137
138 // Change Argument (Method, UFCS) ----------------------------------------------
139 #[cfg(cfail1)]
140 pub fn change_argument_method_ufcs() {
141 let s = Struct;
142 Struct::method1(&s, 'x', true);
143 }
144
145 #[cfg(not(cfail1))]
146 #[rustc_clean(cfg="cfail2", except="HirBody,MirValidated,MirOptimized")]
147 #[rustc_clean(cfg="cfail3")]
148 pub fn change_argument_method_ufcs() {
149 let s = Struct;
150 Struct::method1(&s, 'x', false);
151 }
152
153
154
155 // Change To UFCS --------------------------------------------------------------
156 #[cfg(cfail1)]
157 pub fn change_to_ufcs() {
158 let s = Struct;
159 s.method1('x', true);
160 }
161
162 #[cfg(not(cfail1))]
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() {
168 let s = Struct;
169 Struct::method1(&s, 'x', true);
170 }
171
172
173 struct Struct2;
174 impl Struct2 {
175 fn method1(&self, _x: char, _y: bool) {}
176 }
177
178 // Change UFCS Callee Indirectly -----------------------------------------------
179 pub mod change_ufcs_callee_indirectly {
180 #[cfg(cfail1)]
181 use super::Struct as Struct;
182 #[cfg(not(cfail1))]
183 use super::Struct2 as Struct;
184
185 #[rustc_clean(cfg="cfail2", except="HirBody,MirValidated,MirOptimized,TypeckTables")]
186 #[rustc_clean(cfg="cfail3")]
187
188
189 pub fn change_ufcs_callee_indirectly() {
190 let s = Struct;
191 Struct::method1(&s, 'q', false)
192 }
193 }