]> git.lizzy.rs Git - rust.git/blob - src/test/incremental/hashes/extern_mods.rs
Rollup merge of #41141 - michaelwoerister:direct-metadata-ich-final, r=nikomatsakis
[rust.git] / src / test / incremental / hashes / extern_mods.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 `extern` modules.
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 // must-compile-successfully
20 // revisions: cfail1 cfail2 cfail3
21 // compile-flags: -Z query-dep-graph
22
23 #![allow(warnings)]
24 #![feature(rustc_attrs)]
25 #![feature(unboxed_closures)]
26 #![feature(link_args)]
27 #![crate_type="rlib"]
28
29
30 // Change function name --------------------------------------------------------
31 #[cfg(cfail1)]
32 extern {
33     pub fn change_function_name1(c: i64) -> i32;
34 }
35
36 #[cfg(not(cfail1))]
37 #[rustc_dirty(label="Hir", cfg="cfail2")]
38 #[rustc_clean(label="Hir", cfg="cfail3")]
39 #[rustc_metadata_dirty(cfg="cfail2")]
40 #[rustc_metadata_clean(cfg="cfail3")]
41 extern {
42     pub fn change_function_name2(c: i64) -> i32;
43 }
44
45
46
47 // Change parameter name -------------------------------------------------------
48 #[cfg(cfail1)]
49 extern {
50     pub fn change_parameter_name(c: i64) -> i32;
51 }
52
53 #[cfg(not(cfail1))]
54 #[rustc_dirty(label="Hir", cfg="cfail2")]
55 #[rustc_clean(label="Hir", cfg="cfail3")]
56 #[rustc_metadata_clean(cfg="cfail2")]
57 #[rustc_metadata_clean(cfg="cfail3")]
58 extern {
59     #[rustc_metadata_dirty(cfg="cfail2")]
60     #[rustc_metadata_clean(cfg="cfail3")]
61     pub fn change_parameter_name(d: i64) -> i32;
62 }
63
64
65
66 // Change parameter type -------------------------------------------------------
67 #[cfg(cfail1)]
68 extern {
69     pub fn change_parameter_type(c: i64) -> i32;
70 }
71
72 #[cfg(not(cfail1))]
73 #[rustc_dirty(label="Hir", cfg="cfail2")]
74 #[rustc_clean(label="Hir", cfg="cfail3")]
75 #[rustc_metadata_clean(cfg="cfail2")]
76 #[rustc_metadata_clean(cfg="cfail3")]
77 extern {
78     #[rustc_metadata_dirty(cfg="cfail2")]
79     #[rustc_metadata_clean(cfg="cfail3")]
80     pub fn change_parameter_type(c: i32) -> i32;
81 }
82
83
84
85 // Change return type ----------------------------------------------------------
86 #[cfg(cfail1)]
87 extern {
88     pub fn change_return_type(c: i32) -> i32;
89 }
90
91 #[cfg(not(cfail1))]
92 #[rustc_dirty(label="Hir", cfg="cfail2")]
93 #[rustc_clean(label="Hir", cfg="cfail3")]
94 #[rustc_metadata_clean(cfg="cfail2")]
95 #[rustc_metadata_clean(cfg="cfail3")]
96 extern {
97     #[rustc_metadata_dirty(cfg="cfail2")]
98     #[rustc_metadata_clean(cfg="cfail3")]
99     pub fn change_return_type(c: i32) -> i8;
100 }
101
102
103
104 // Add parameter ---------------------------------------------------------------
105 #[cfg(cfail1)]
106 extern {
107     pub fn add_parameter(c: i32) -> i32;
108 }
109
110 #[cfg(not(cfail1))]
111 #[rustc_dirty(label="Hir", cfg="cfail2")]
112 #[rustc_clean(label="Hir", cfg="cfail3")]
113 #[rustc_metadata_clean(cfg="cfail2")]
114 #[rustc_metadata_clean(cfg="cfail3")]
115 extern {
116     #[rustc_metadata_dirty(cfg="cfail2")]
117     #[rustc_metadata_clean(cfg="cfail3")]
118     pub fn add_parameter(c: i32, d: i32) -> i32;
119 }
120
121
122
123 // Add return type -------------------------------------------------------------
124 #[cfg(cfail1)]
125 extern {
126     pub fn add_return_type(c: i32);
127 }
128
129 #[cfg(not(cfail1))]
130 #[rustc_dirty(label="Hir", cfg="cfail2")]
131 #[rustc_clean(label="Hir", cfg="cfail3")]
132 #[rustc_metadata_clean(cfg="cfail2")]
133 #[rustc_metadata_clean(cfg="cfail3")]
134 extern {
135     #[rustc_metadata_dirty(cfg="cfail2")]
136     #[rustc_metadata_clean(cfg="cfail3")]
137     pub fn add_return_type(c: i32) -> i32;
138 }
139
140
141
142 // Make function variadic ------------------------------------------------------
143 #[cfg(cfail1)]
144 extern {
145     pub fn make_function_variadic(c: i32);
146 }
147
148 #[cfg(not(cfail1))]
149 #[rustc_dirty(label="Hir", cfg="cfail2")]
150 #[rustc_clean(label="Hir", cfg="cfail3")]
151 #[rustc_metadata_clean(cfg="cfail2")]
152 #[rustc_metadata_clean(cfg="cfail3")]
153 extern {
154     #[rustc_metadata_dirty(cfg="cfail2")]
155     #[rustc_metadata_clean(cfg="cfail3")]
156     pub fn make_function_variadic(c: i32, ...);
157 }
158
159
160
161 // Change calling convention ---------------------------------------------------
162 #[cfg(cfail1)]
163 extern "C" {
164     pub fn change_calling_convention(c: i32);
165 }
166
167 #[cfg(not(cfail1))]
168 #[rustc_dirty(label="Hir", cfg="cfail2")]
169 #[rustc_clean(label="Hir", cfg="cfail3")]
170 #[rustc_metadata_clean(cfg="cfail2")]
171 #[rustc_metadata_clean(cfg="cfail3")]
172 extern "rust-call" {
173     #[rustc_metadata_dirty(cfg="cfail2")]
174     #[rustc_metadata_clean(cfg="cfail3")]
175     pub fn change_calling_convention(c: i32);
176 }
177
178
179
180 // Make function public --------------------------------------------------------
181 #[cfg(cfail1)]
182 extern {
183     fn make_function_public(c: i32);
184 }
185
186 #[cfg(not(cfail1))]
187 #[rustc_dirty(label="Hir", cfg="cfail2")]
188 #[rustc_clean(label="Hir", cfg="cfail3")]
189 #[rustc_metadata_clean(cfg="cfail2")]
190 #[rustc_metadata_clean(cfg="cfail3")]
191 extern {
192     #[rustc_metadata_dirty(cfg="cfail2")]
193     #[rustc_metadata_clean(cfg="cfail3")]
194     pub fn make_function_public(c: i32);
195 }
196
197
198
199 // Add function ----------------------------------------------------------------
200 #[cfg(cfail1)]
201 extern {
202     pub fn add_function1(c: i32);
203 }
204
205 #[cfg(not(cfail1))]
206 #[rustc_dirty(label="Hir", cfg="cfail2")]
207 #[rustc_clean(label="Hir", cfg="cfail3")]
208 #[rustc_metadata_dirty(cfg="cfail2")]
209 #[rustc_metadata_clean(cfg="cfail3")]
210 extern {
211     pub fn add_function1(c: i32);
212     pub fn add_function2();
213 }
214
215
216
217 // Change link-args ------------------------------------------------------------
218 #[cfg(cfail1)]
219 #[link_args = "-foo -bar"]
220 extern {
221     pub fn change_link_args(c: i32);
222 }
223
224 #[cfg(not(cfail1))]
225 #[rustc_dirty(label="Hir", cfg="cfail2")]
226 #[rustc_clean(label="Hir", cfg="cfail3")]
227 #[rustc_metadata_dirty(cfg="cfail2")]
228 #[rustc_metadata_clean(cfg="cfail3")]
229 #[link_args = "-foo -bar -baz"]
230 extern {
231     pub fn change_link_args(c: i32);
232 }
233
234
235
236 // Change link-name ------------------------------------------------------------
237 #[cfg(cfail1)]
238 #[link(name = "foo")]
239 extern {
240     pub fn change_link_name(c: i32);
241 }
242
243 #[cfg(not(cfail1))]
244 #[rustc_dirty(label="Hir", cfg="cfail2")]
245 #[rustc_clean(label="Hir", cfg="cfail3")]
246 #[rustc_metadata_dirty(cfg="cfail2")]
247 #[rustc_metadata_clean(cfg="cfail3")]
248 #[link(name = "bar")]
249 extern {
250     pub fn change_link_name(c: i32);
251 }
252
253 type c_i32 = i32;
254 type c_i64 = i64;
255
256 // Indirectly change parameter type --------------------------------------------
257 mod indirectly_change_parameter_type {
258     #[cfg(cfail1)]
259     use super::c_i32 as c_int;
260     #[cfg(not(cfail1))]
261     use super::c_i64 as c_int;
262
263     #[rustc_dirty(label="Hir", cfg="cfail2")]
264     #[rustc_clean(label="Hir", cfg="cfail3")]
265     #[rustc_metadata_clean(cfg="cfail2")]
266     #[rustc_metadata_clean(cfg="cfail3")]
267     extern {
268         #[rustc_metadata_dirty(cfg="cfail2")]
269         #[rustc_metadata_clean(cfg="cfail3")]
270         pub fn indirectly_change_parameter_type(c: c_int);
271     }
272 }
273
274
275
276 // Indirectly change return type --------------------------------------------
277 mod indirectly_change_return_type {
278     #[cfg(cfail1)]
279     use super::c_i32 as c_int;
280     #[cfg(not(cfail1))]
281     use super::c_i64 as c_int;
282
283     #[rustc_dirty(label="Hir", cfg="cfail2")]
284     #[rustc_clean(label="Hir", cfg="cfail3")]
285     #[rustc_metadata_clean(cfg="cfail2")]
286     #[rustc_metadata_clean(cfg="cfail3")]
287     extern {
288         #[rustc_metadata_dirty(cfg="cfail2")]
289         #[rustc_metadata_clean(cfg="cfail3")]
290         pub fn indirectly_change_return_type() -> c_int;
291     }
292 }