]>
Commit | Line | Data |
---|---|---|
476ff2be SL |
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 | ||
416331ca | 8 | // build-pass (FIXME(62277): could be check-pass?) |
c295e0f8 | 9 | // revisions: cfail1 cfail2 cfail3 cfail4 cfail5 cfail6 |
923072b8 | 10 | // compile-flags: -Z query-dep-graph -O |
c295e0f8 XL |
11 | // [cfail1]compile-flags: -Zincremental-ignore-spans |
12 | // [cfail2]compile-flags: -Zincremental-ignore-spans | |
13 | // [cfail3]compile-flags: -Zincremental-ignore-spans | |
14 | // [cfail4]compile-flags: -Zincremental-relative-spans | |
15 | // [cfail5]compile-flags: -Zincremental-relative-spans | |
16 | // [cfail6]compile-flags: -Zincremental-relative-spans | |
476ff2be SL |
17 | |
18 | ||
19 | #![allow(warnings)] | |
20 | #![feature(rustc_attrs)] | |
21 | #![crate_type="rlib"] | |
22 | ||
23 | fn callee1(_x: u32, _y: i64) {} | |
24 | fn callee2(_x: u32, _y: i64) {} | |
25 | ||
26 | ||
e1599b0c | 27 | // Change Callee (Function) |
c295e0f8 | 28 | #[cfg(any(cfail1,cfail4))] |
476ff2be SL |
29 | pub fn change_callee_function() { |
30 | callee1(1, 2) | |
31 | } | |
32 | ||
c295e0f8 | 33 | #[cfg(not(any(cfail1,cfail4)))] |
3dfed10e | 34 | #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir,typeck")] |
abe05a73 | 35 | #[rustc_clean(cfg="cfail3")] |
c295e0f8 XL |
36 | #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir,typeck")] |
37 | #[rustc_clean(cfg="cfail6")] | |
476ff2be SL |
38 | pub fn change_callee_function() { |
39 | callee2(1, 2) | |
40 | } | |
41 | ||
42 | ||
43 | ||
e1599b0c | 44 | // Change Argument (Function) |
c295e0f8 | 45 | #[cfg(any(cfail1,cfail4))] |
476ff2be SL |
46 | pub fn change_argument_function() { |
47 | callee1(1, 2) | |
48 | } | |
49 | ||
c295e0f8 | 50 | #[cfg(not(any(cfail1,cfail4)))] |
3dfed10e | 51 | #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir")] |
abe05a73 | 52 | #[rustc_clean(cfg="cfail3")] |
c295e0f8 XL |
53 | #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir")] |
54 | #[rustc_clean(cfg="cfail6")] | |
476ff2be SL |
55 | pub fn change_argument_function() { |
56 | callee1(1, 3) | |
57 | } | |
58 | ||
59 | ||
60 | ||
e1599b0c | 61 | // Change Callee Indirectly (Function) |
476ff2be | 62 | mod change_callee_indirectly_function { |
c295e0f8 | 63 | #[cfg(any(cfail1,cfail4))] |
476ff2be | 64 | use super::callee1 as callee; |
c295e0f8 | 65 | #[cfg(not(any(cfail1,cfail4)))] |
476ff2be SL |
66 | use super::callee2 as callee; |
67 | ||
17df50a5 XL |
68 | #[rustc_clean(except="hir_owner_nodes,typeck", cfg="cfail2")] |
69 | #[rustc_clean(cfg="cfail3")] | |
c295e0f8 XL |
70 | #[rustc_clean(except="hir_owner_nodes,typeck", cfg="cfail5")] |
71 | #[rustc_clean(cfg="cfail6")] | |
476ff2be SL |
72 | pub fn change_callee_indirectly_function() { |
73 | callee(1, 2) | |
74 | } | |
75 | } | |
76 | ||
77 | ||
78 | struct Struct; | |
79 | impl Struct { | |
80 | fn method1(&self, _x: char, _y: bool) {} | |
81 | fn method2(&self, _x: char, _y: bool) {} | |
82 | } | |
83 | ||
e1599b0c | 84 | // Change Callee (Method) |
c295e0f8 | 85 | #[cfg(any(cfail1,cfail4))] |
476ff2be SL |
86 | pub fn change_callee_method() { |
87 | let s = Struct; | |
88 | s.method1('x', true); | |
89 | } | |
90 | ||
c295e0f8 | 91 | #[cfg(not(any(cfail1,cfail4)))] |
3dfed10e | 92 | #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir,typeck")] |
abe05a73 | 93 | #[rustc_clean(cfg="cfail3")] |
c295e0f8 XL |
94 | #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir,typeck")] |
95 | #[rustc_clean(cfg="cfail6")] | |
476ff2be SL |
96 | pub fn change_callee_method() { |
97 | let s = Struct; | |
98 | s.method2('x', true); | |
99 | } | |
100 | ||
101 | ||
102 | ||
e1599b0c | 103 | // Change Argument (Method) |
c295e0f8 | 104 | #[cfg(any(cfail1,cfail4))] |
476ff2be SL |
105 | pub fn change_argument_method() { |
106 | let s = Struct; | |
107 | s.method1('x', true); | |
108 | } | |
109 | ||
c295e0f8 | 110 | #[cfg(not(any(cfail1,cfail4)))] |
3dfed10e | 111 | #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir")] |
abe05a73 | 112 | #[rustc_clean(cfg="cfail3")] |
c295e0f8 XL |
113 | #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir")] |
114 | #[rustc_clean(cfg="cfail6")] | |
476ff2be SL |
115 | pub fn change_argument_method() { |
116 | let s = Struct; | |
117 | s.method1('y', true); | |
118 | } | |
119 | ||
120 | ||
121 | ||
e1599b0c | 122 | // Change Callee (Method, UFCS) |
c295e0f8 | 123 | #[cfg(any(cfail1,cfail4))] |
476ff2be SL |
124 | pub fn change_ufcs_callee_method() { |
125 | let s = Struct; | |
126 | Struct::method1(&s, 'x', true); | |
127 | } | |
128 | ||
c295e0f8 | 129 | #[cfg(not(any(cfail1,cfail4)))] |
3dfed10e | 130 | #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir,typeck")] |
abe05a73 | 131 | #[rustc_clean(cfg="cfail3")] |
c295e0f8 XL |
132 | #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir,typeck")] |
133 | #[rustc_clean(cfg="cfail6")] | |
476ff2be SL |
134 | pub fn change_ufcs_callee_method() { |
135 | let s = Struct; | |
136 | Struct::method2(&s, 'x', true); | |
137 | } | |
138 | ||
139 | ||
140 | ||
e1599b0c | 141 | // Change Argument (Method, UFCS) |
c295e0f8 | 142 | #[cfg(any(cfail1,cfail4))] |
476ff2be SL |
143 | pub fn change_argument_method_ufcs() { |
144 | let s = Struct; | |
145 | Struct::method1(&s, 'x', true); | |
146 | } | |
147 | ||
c295e0f8 | 148 | #[cfg(not(any(cfail1,cfail4)))] |
3dfed10e | 149 | #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir")] |
abe05a73 | 150 | #[rustc_clean(cfg="cfail3")] |
c295e0f8 XL |
151 | #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir")] |
152 | #[rustc_clean(cfg="cfail6")] | |
476ff2be SL |
153 | pub fn change_argument_method_ufcs() { |
154 | let s = Struct; | |
c295e0f8 | 155 | Struct::method1(&s, 'x',false); |
476ff2be SL |
156 | } |
157 | ||
158 | ||
159 | ||
e1599b0c | 160 | // Change To UFCS |
c295e0f8 | 161 | #[cfg(any(cfail1,cfail4))] |
476ff2be SL |
162 | pub fn change_to_ufcs() { |
163 | let s = Struct; | |
c295e0f8 | 164 | s.method1('x', true); // ------ |
476ff2be SL |
165 | } |
166 | ||
c295e0f8 | 167 | #[cfg(not(any(cfail1,cfail4)))] |
3dfed10e | 168 | #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir,typeck")] |
abe05a73 | 169 | #[rustc_clean(cfg="cfail3")] |
c295e0f8 XL |
170 | #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir,typeck")] |
171 | #[rustc_clean(cfg="cfail6")] | |
ba9703b0 XL |
172 | // One might think this would be expanded in the hir_owner_nodes/Mir, but it actually |
173 | // results in slightly different hir_owner/Mir. | |
476ff2be SL |
174 | pub fn change_to_ufcs() { |
175 | let s = Struct; | |
176 | Struct::method1(&s, 'x', true); | |
177 | } | |
178 | ||
179 | ||
180 | struct Struct2; | |
181 | impl Struct2 { | |
182 | fn method1(&self, _x: char, _y: bool) {} | |
183 | } | |
184 | ||
e1599b0c | 185 | // Change UFCS Callee Indirectly |
abe05a73 | 186 | pub mod change_ufcs_callee_indirectly { |
c295e0f8 | 187 | #[cfg(any(cfail1,cfail4))] |
476ff2be | 188 | use super::Struct as Struct; |
c295e0f8 | 189 | #[cfg(not(any(cfail1,cfail4)))] |
476ff2be SL |
190 | use super::Struct2 as Struct; |
191 | ||
3dfed10e | 192 | #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir,typeck")] |
abe05a73 | 193 | #[rustc_clean(cfg="cfail3")] |
c295e0f8 XL |
194 | #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir,typeck")] |
195 | #[rustc_clean(cfg="cfail6")] | |
476ff2be SL |
196 | pub fn change_ufcs_callee_indirectly() { |
197 | let s = Struct; | |
198 | Struct::method1(&s, 'q', false) | |
199 | } | |
200 | } |