]> git.lizzy.rs Git - rust.git/blob - src/test/incremental/hashes/call_expressions.rs
Rollup merge of #97150 - ChrisDenton:stdio-create_pipe, r=m-ou-se
[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 cfail4 cfail5 cfail6
10 // compile-flags: -Z query-dep-graph -O
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
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
27 // Change Callee (Function)
28 #[cfg(any(cfail1,cfail4))]
29 pub fn change_callee_function() {
30     callee1(1, 2)
31 }
32
33 #[cfg(not(any(cfail1,cfail4)))]
34 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir,typeck")]
35 #[rustc_clean(cfg="cfail3")]
36 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir,typeck")]
37 #[rustc_clean(cfg="cfail6")]
38 pub fn change_callee_function() {
39     callee2(1, 2)
40 }
41
42
43
44 // Change Argument (Function)
45 #[cfg(any(cfail1,cfail4))]
46 pub fn change_argument_function() {
47     callee1(1, 2)
48 }
49
50 #[cfg(not(any(cfail1,cfail4)))]
51 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir")]
52 #[rustc_clean(cfg="cfail3")]
53 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir")]
54 #[rustc_clean(cfg="cfail6")]
55 pub fn change_argument_function() {
56     callee1(1, 3)
57 }
58
59
60
61 // Change Callee Indirectly (Function)
62 mod change_callee_indirectly_function {
63     #[cfg(any(cfail1,cfail4))]
64     use super::callee1 as callee;
65     #[cfg(not(any(cfail1,cfail4)))]
66     use super::callee2 as callee;
67
68     #[rustc_clean(except="hir_owner_nodes,typeck", cfg="cfail2")]
69     #[rustc_clean(cfg="cfail3")]
70     #[rustc_clean(except="hir_owner_nodes,typeck", cfg="cfail5")]
71     #[rustc_clean(cfg="cfail6")]
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
84 // Change Callee (Method)
85 #[cfg(any(cfail1,cfail4))]
86 pub fn change_callee_method() {
87     let s = Struct;
88     s.method1('x', true);
89 }
90
91 #[cfg(not(any(cfail1,cfail4)))]
92 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir,typeck")]
93 #[rustc_clean(cfg="cfail3")]
94 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir,typeck")]
95 #[rustc_clean(cfg="cfail6")]
96 pub fn change_callee_method() {
97     let s = Struct;
98     s.method2('x', true);
99 }
100
101
102
103 // Change Argument (Method)
104 #[cfg(any(cfail1,cfail4))]
105 pub fn change_argument_method() {
106     let s = Struct;
107     s.method1('x', true);
108 }
109
110 #[cfg(not(any(cfail1,cfail4)))]
111 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir")]
112 #[rustc_clean(cfg="cfail3")]
113 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir")]
114 #[rustc_clean(cfg="cfail6")]
115 pub fn change_argument_method() {
116     let s = Struct;
117     s.method1('y', true);
118 }
119
120
121
122 // Change Callee (Method, UFCS)
123 #[cfg(any(cfail1,cfail4))]
124 pub fn change_ufcs_callee_method() {
125     let s = Struct;
126     Struct::method1(&s, 'x', true);
127 }
128
129 #[cfg(not(any(cfail1,cfail4)))]
130 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir,typeck")]
131 #[rustc_clean(cfg="cfail3")]
132 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir,typeck")]
133 #[rustc_clean(cfg="cfail6")]
134 pub fn change_ufcs_callee_method() {
135     let s = Struct;
136     Struct::method2(&s, 'x', true);
137 }
138
139
140
141 // Change Argument (Method, UFCS)
142 #[cfg(any(cfail1,cfail4))]
143 pub fn change_argument_method_ufcs() {
144     let s = Struct;
145     Struct::method1(&s, 'x', true);
146 }
147
148 #[cfg(not(any(cfail1,cfail4)))]
149 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir")]
150 #[rustc_clean(cfg="cfail3")]
151 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir")]
152 #[rustc_clean(cfg="cfail6")]
153 pub fn change_argument_method_ufcs() {
154     let s = Struct;
155     Struct::method1(&s, 'x',false);
156 }
157
158
159
160 // Change To UFCS
161 #[cfg(any(cfail1,cfail4))]
162 pub fn change_to_ufcs() {
163     let s = Struct;
164     s.method1('x', true); // ------
165 }
166
167 #[cfg(not(any(cfail1,cfail4)))]
168 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir,typeck")]
169 #[rustc_clean(cfg="cfail3")]
170 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir,typeck")]
171 #[rustc_clean(cfg="cfail6")]
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.
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
185 // Change UFCS Callee Indirectly
186 pub mod change_ufcs_callee_indirectly {
187     #[cfg(any(cfail1,cfail4))]
188     use super::Struct as Struct;
189     #[cfg(not(any(cfail1,cfail4)))]
190     use super::Struct2 as Struct;
191
192     #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir,typeck")]
193     #[rustc_clean(cfg="cfail3")]
194     #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir,typeck")]
195     #[rustc_clean(cfg="cfail6")]
196     pub fn change_ufcs_callee_indirectly() {
197         let s = Struct;
198         Struct::method1(&s, 'q', false)
199     }
200 }