]> git.lizzy.rs Git - rust.git/blob - src/test/incremental/hashes/call_expressions.rs
Merge pull request #2 from rust-lang/master
[rust.git] / src / test / incremental / hashes / call_expressions.rs
1 // This test case tests the incremental compilation hash (ICH) implementation
2 // for function and method call 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
10 // compile-flags: -Z query-dep-graph -Zincremental-ignore-spans
11
12
13 #![allow(warnings)]
14 #![feature(rustc_attrs)]
15 #![crate_type="rlib"]
16
17 fn callee1(_x: u32, _y: i64) {}
18 fn callee2(_x: u32, _y: i64) {}
19
20
21 // Change Callee (Function)
22 #[cfg(cfail1)]
23 pub fn change_callee_function() {
24     callee1(1, 2)
25 }
26
27 #[cfg(not(cfail1))]
28 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,mir_built,optimized_mir,typeck_tables_of")]
29 #[rustc_clean(cfg="cfail3")]
30 pub fn change_callee_function() {
31     callee2(1, 2)
32 }
33
34
35
36 // Change Argument (Function)
37 #[cfg(cfail1)]
38 pub fn change_argument_function() {
39     callee1(1, 2)
40 }
41
42 #[cfg(not(cfail1))]
43 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,mir_built,optimized_mir")]
44 #[rustc_clean(cfg="cfail3")]
45 pub fn change_argument_function() {
46     callee1(1, 3)
47 }
48
49
50
51 // Change Callee Indirectly (Function)
52 mod change_callee_indirectly_function {
53     #[cfg(cfail1)]
54     use super::callee1 as callee;
55     #[cfg(not(cfail1))]
56     use super::callee2 as callee;
57
58     #[rustc_clean(label="hir_owner", cfg="cfail2")]
59     #[rustc_clean(label="hir_owner", cfg="cfail3")]
60     #[rustc_dirty(label="hir_owner_nodes", cfg="cfail2")]
61     #[rustc_clean(label="hir_owner_nodes", cfg="cfail3")]
62
63
64     pub fn change_callee_indirectly_function() {
65         callee(1, 2)
66     }
67 }
68
69
70 struct Struct;
71 impl Struct {
72     fn method1(&self, _x: char, _y: bool) {}
73     fn method2(&self, _x: char, _y: bool) {}
74 }
75
76 // Change Callee (Method)
77 #[cfg(cfail1)]
78 pub fn change_callee_method() {
79     let s = Struct;
80     s.method1('x', true);
81 }
82
83 #[cfg(not(cfail1))]
84 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,mir_built,optimized_mir,typeck_tables_of")]
85 #[rustc_clean(cfg="cfail3")]
86 pub fn change_callee_method() {
87     let s = Struct;
88     s.method2('x', true);
89 }
90
91
92
93 // Change Argument (Method)
94 #[cfg(cfail1)]
95 pub fn change_argument_method() {
96     let s = Struct;
97     s.method1('x', true);
98 }
99
100 #[cfg(not(cfail1))]
101 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,mir_built,optimized_mir")]
102 #[rustc_clean(cfg="cfail3")]
103 pub fn change_argument_method() {
104     let s = Struct;
105     s.method1('y', true);
106 }
107
108
109
110 // Change Callee (Method, UFCS)
111 #[cfg(cfail1)]
112 pub fn change_ufcs_callee_method() {
113     let s = Struct;
114     Struct::method1(&s, 'x', true);
115 }
116
117 #[cfg(not(cfail1))]
118 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,mir_built,optimized_mir,typeck_tables_of")]
119 #[rustc_clean(cfg="cfail3")]
120 pub fn change_ufcs_callee_method() {
121     let s = Struct;
122     Struct::method2(&s, 'x', true);
123 }
124
125
126
127 // Change Argument (Method, UFCS)
128 #[cfg(cfail1)]
129 pub fn change_argument_method_ufcs() {
130     let s = Struct;
131     Struct::method1(&s, 'x', true);
132 }
133
134 #[cfg(not(cfail1))]
135 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,mir_built,optimized_mir")]
136 #[rustc_clean(cfg="cfail3")]
137 pub fn change_argument_method_ufcs() {
138     let s = Struct;
139     Struct::method1(&s, 'x', false);
140 }
141
142
143
144 // Change To UFCS
145 #[cfg(cfail1)]
146 pub fn change_to_ufcs() {
147     let s = Struct;
148     s.method1('x', true);
149 }
150
151 #[cfg(not(cfail1))]
152 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,mir_built,optimized_mir,typeck_tables_of")]
153 #[rustc_clean(cfg="cfail3")]
154 // One might think this would be expanded in the hir_owner_nodes/Mir, but it actually
155 // results in slightly different hir_owner/Mir.
156 pub fn change_to_ufcs() {
157     let s = Struct;
158     Struct::method1(&s, 'x', true);
159 }
160
161
162 struct Struct2;
163 impl Struct2 {
164     fn method1(&self, _x: char, _y: bool) {}
165 }
166
167 // Change UFCS Callee Indirectly
168 pub mod change_ufcs_callee_indirectly {
169     #[cfg(cfail1)]
170     use super::Struct as Struct;
171     #[cfg(not(cfail1))]
172     use super::Struct2 as Struct;
173
174     #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,mir_built,optimized_mir,typeck_tables_of")]
175     #[rustc_clean(cfg="cfail3")]
176
177
178     pub fn change_ufcs_callee_indirectly() {
179         let s = Struct;
180         Struct::method1(&s, 'q', false)
181     }
182 }