]> git.lizzy.rs Git - rust.git/blob - src/test/incremental/hashes/extern_mods.rs
Rollup merge of #49858 - dmizuk:unique-doc-hidden, r=steveklabnik
[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 // compile-pass
20 // revisions: cfail1 cfail2 cfail3
21 // compile-flags: -Z query-dep-graph -Zincremental-ignore-spans
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(cfg="cfail2")]
38 #[rustc_clean(cfg="cfail3")]
39 extern {
40     pub fn change_function_name2(c: i64) -> i32;
41 }
42
43
44
45 // Change parameter name -------------------------------------------------------
46 #[cfg(cfail1)]
47 extern {
48     pub fn change_parameter_name(c: i64) -> i32;
49 }
50
51 #[cfg(not(cfail1))]
52 #[rustc_dirty(cfg="cfail2")]
53 #[rustc_clean(cfg="cfail3")]
54 extern {
55     pub fn change_parameter_name(d: i64) -> i32;
56 }
57
58
59
60 // Change parameter type -------------------------------------------------------
61 #[cfg(cfail1)]
62 extern {
63     pub fn change_parameter_type(c: i64) -> i32;
64 }
65
66 #[cfg(not(cfail1))]
67 #[rustc_dirty(cfg="cfail2")]
68 #[rustc_clean(cfg="cfail3")]
69 extern {
70     pub fn change_parameter_type(c: i32) -> i32;
71 }
72
73
74
75 // Change return type ----------------------------------------------------------
76 #[cfg(cfail1)]
77 extern {
78     pub fn change_return_type(c: i32) -> i32;
79 }
80
81 #[cfg(not(cfail1))]
82 #[rustc_dirty(cfg="cfail2")]
83 #[rustc_clean(cfg="cfail3")]
84 extern {
85     pub fn change_return_type(c: i32) -> i8;
86 }
87
88
89
90 // Add parameter ---------------------------------------------------------------
91 #[cfg(cfail1)]
92 extern {
93     pub fn add_parameter(c: i32) -> i32;
94 }
95
96 #[cfg(not(cfail1))]
97 #[rustc_dirty(cfg="cfail2")]
98 #[rustc_clean(cfg="cfail3")]
99 extern {
100     pub fn add_parameter(c: i32, d: i32) -> i32;
101 }
102
103
104
105 // Add return type -------------------------------------------------------------
106 #[cfg(cfail1)]
107 extern {
108     pub fn add_return_type(c: i32);
109 }
110
111 #[cfg(not(cfail1))]
112 #[rustc_dirty(cfg="cfail2")]
113 #[rustc_clean(cfg="cfail3")]
114 extern {
115     pub fn add_return_type(c: i32) -> i32;
116 }
117
118
119
120 // Make function variadic ------------------------------------------------------
121 #[cfg(cfail1)]
122 extern {
123     pub fn make_function_variadic(c: i32);
124 }
125
126 #[cfg(not(cfail1))]
127 #[rustc_dirty(cfg="cfail2")]
128 #[rustc_clean(cfg="cfail3")]
129 extern {
130     pub fn make_function_variadic(c: i32, ...);
131 }
132
133
134
135 // Change calling convention ---------------------------------------------------
136 #[cfg(cfail1)]
137 extern "C" {
138     pub fn change_calling_convention(c: i32);
139 }
140
141 #[cfg(not(cfail1))]
142 #[rustc_dirty(cfg="cfail2")]
143 #[rustc_clean(cfg="cfail3")]
144 extern "rust-call" {
145     pub fn change_calling_convention(c: i32);
146 }
147
148
149
150 // Make function public --------------------------------------------------------
151 #[cfg(cfail1)]
152 extern {
153     fn make_function_public(c: i32);
154 }
155
156 #[cfg(not(cfail1))]
157 #[rustc_dirty(cfg="cfail2")]
158 #[rustc_clean(cfg="cfail3")]
159 extern {
160     pub fn make_function_public(c: i32);
161 }
162
163
164
165 // Add function ----------------------------------------------------------------
166 #[cfg(cfail1)]
167 extern {
168     pub fn add_function1(c: i32);
169 }
170
171 #[cfg(not(cfail1))]
172 #[rustc_dirty(cfg="cfail2")]
173 #[rustc_clean(cfg="cfail3")]
174 extern {
175     pub fn add_function1(c: i32);
176     pub fn add_function2();
177 }
178
179
180
181 // Change link-args ------------------------------------------------------------
182 #[cfg(cfail1)]
183 #[link_args = "-foo -bar"]
184 extern {
185     pub fn change_link_args(c: i32);
186 }
187
188 #[cfg(not(cfail1))]
189 #[rustc_dirty(cfg="cfail2")]
190 #[rustc_clean(cfg="cfail3")]
191 #[link_args = "-foo -bar -baz"]
192 extern {
193     pub fn change_link_args(c: i32);
194 }
195
196
197
198 // Change link-name ------------------------------------------------------------
199 #[cfg(cfail1)]
200 #[link(name = "foo")]
201 extern {
202     pub fn change_link_name(c: i32);
203 }
204
205 #[cfg(not(cfail1))]
206 #[rustc_dirty(cfg="cfail2")]
207 #[rustc_clean(cfg="cfail3")]
208 #[link(name = "bar")]
209 extern {
210     pub fn change_link_name(c: i32);
211 }
212
213 type c_i32 = i32;
214 type c_i64 = i64;
215
216 // Indirectly change parameter type --------------------------------------------
217 mod indirectly_change_parameter_type {
218     #[cfg(cfail1)]
219     use super::c_i32 as c_int;
220     #[cfg(not(cfail1))]
221     use super::c_i64 as c_int;
222
223     #[rustc_dirty(cfg="cfail2")]
224     #[rustc_clean(cfg="cfail3")]
225     extern {
226         pub fn indirectly_change_parameter_type(c: c_int);
227     }
228 }
229
230
231
232 // Indirectly change return type --------------------------------------------
233 mod indirectly_change_return_type {
234     #[cfg(cfail1)]
235     use super::c_i32 as c_int;
236     #[cfg(not(cfail1))]
237     use super::c_i64 as c_int;
238
239     #[rustc_dirty(cfg="cfail2")]
240     #[rustc_clean(cfg="cfail3")]
241     extern {
242         pub fn indirectly_change_return_type() -> c_int;
243     }
244 }