]> git.proxmox.com Git - rustc.git/blob - tests/incremental/hashes/extern_mods.rs
New upstream version 1.68.2+dfsg1
[rustc.git] / tests / incremental / hashes / extern_mods.rs
1 // This test case tests the incremental compilation hash (ICH) implementation
2 // for `extern` modules.
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
15 #![allow(warnings)]
16 #![feature(rustc_attrs)]
17 #![feature(unboxed_closures)]
18 #![crate_type = "rlib"]
19
20 // Change function name --------------------------------------------------------
21 #[cfg(any(cfail1,cfail4))]
22 extern "C" {
23 pub fn change_function_name1(c: i64) -> i32;
24 }
25
26 #[cfg(not(any(cfail1,cfail4)))]
27 #[rustc_clean(cfg = "cfail2", except = "hir_owner,hir_owner_nodes")]
28 #[rustc_clean(cfg = "cfail3")]
29 #[rustc_clean(cfg = "cfail5", except = "hir_owner,hir_owner_nodes")]
30 #[rustc_clean(cfg = "cfail6")]
31 extern "C" {
32 pub fn change_function_name2(c: i64) -> i32;
33 }
34
35 // Change parameter name -------------------------------------------------------
36 #[cfg(any(cfail1,cfail4))]
37 extern "C" {
38 pub fn change_parameter_name(c: i64) -> i32;
39 }
40
41 #[cfg(not(any(cfail1,cfail4)))]
42 #[rustc_clean(cfg = "cfail2")]
43 #[rustc_clean(cfg = "cfail3")]
44 #[rustc_clean(cfg = "cfail5")]
45 #[rustc_clean(cfg = "cfail6")]
46 extern "C" {
47 pub fn change_parameter_name(d: i64) -> i32;
48 }
49
50 // Change parameter type -------------------------------------------------------
51 #[cfg(any(cfail1,cfail4))]
52 extern "C" {
53 pub fn change_parameter_type(c: i64) -> i32;
54 }
55
56 #[cfg(not(any(cfail1,cfail4)))]
57 #[rustc_clean(cfg = "cfail2")]
58 #[rustc_clean(cfg = "cfail3")]
59 #[rustc_clean(cfg = "cfail5")]
60 #[rustc_clean(cfg = "cfail6")]
61 extern "C" {
62 pub fn change_parameter_type(c: i32) -> i32;
63 }
64
65 // Change return type ----------------------------------------------------------
66 #[cfg(any(cfail1,cfail4))]
67 extern "C" {
68 pub fn change_return_type(c: i32) -> i32;
69 }
70
71 #[cfg(not(any(cfail1,cfail4)))]
72 #[rustc_clean(cfg = "cfail2")]
73 #[rustc_clean(cfg = "cfail3")]
74 #[rustc_clean(cfg = "cfail5")]
75 #[rustc_clean(cfg = "cfail6")]
76 extern "C" {
77 pub fn change_return_type(c: i32) -> i8 ;
78 }
79
80 // Add parameter ---------------------------------------------------------------
81 #[cfg(any(cfail1,cfail4))]
82 extern "C" {
83 pub fn add_parameter(c: i32 ) -> i32;
84 }
85
86 #[cfg(not(any(cfail1,cfail4)))]
87 #[rustc_clean(cfg = "cfail2")]
88 #[rustc_clean(cfg = "cfail3")]
89 #[rustc_clean(cfg = "cfail5")]
90 #[rustc_clean(cfg = "cfail6")]
91 extern "C" {
92 pub fn add_parameter(c: i32, d: i32) -> i32;
93 }
94
95 // Add return type -------------------------------------------------------------
96 #[cfg(any(cfail1,cfail4))]
97 extern "C" {
98 pub fn add_return_type(c: i32) ;
99 }
100
101 #[cfg(not(any(cfail1,cfail4)))]
102 #[rustc_clean(cfg = "cfail2")]
103 #[rustc_clean(cfg = "cfail3")]
104 #[rustc_clean(cfg = "cfail5")]
105 #[rustc_clean(cfg = "cfail6")]
106 extern "C" {
107 pub fn add_return_type(c: i32) -> i32;
108 }
109
110 // Make function variadic ------------------------------------------------------
111 #[cfg(any(cfail1,cfail4))]
112 extern "C" {
113 pub fn make_function_variadic(c: i32 );
114 }
115
116 #[cfg(not(any(cfail1,cfail4)))]
117 #[rustc_clean(cfg = "cfail2")]
118 #[rustc_clean(cfg = "cfail3")]
119 #[rustc_clean(cfg = "cfail5")]
120 #[rustc_clean(cfg = "cfail6")]
121 extern "C" {
122 pub fn make_function_variadic(c: i32, ...);
123 }
124
125 // Change calling convention ---------------------------------------------------
126 #[cfg(any(cfail1,cfail4))]
127 extern "C" {
128 pub fn change_calling_convention(c: (i32,));
129 }
130
131 #[cfg(not(any(cfail1,cfail4)))]
132 #[rustc_clean(cfg = "cfail2", except = "hir_owner,hir_owner_nodes")]
133 #[rustc_clean(cfg = "cfail3")]
134 #[rustc_clean(cfg = "cfail5", except = "hir_owner,hir_owner_nodes")]
135 #[rustc_clean(cfg = "cfail6")]
136 extern "rust-call" {
137 pub fn change_calling_convention(c: (i32,));
138 }
139
140 // Make function public --------------------------------------------------------
141 #[cfg(any(cfail1,cfail4))]
142 extern "C" {
143 fn make_function_public(c: i32);
144 }
145
146 #[cfg(not(any(cfail1,cfail4)))]
147 #[rustc_clean(cfg = "cfail2")]
148 #[rustc_clean(cfg = "cfail3")]
149 #[rustc_clean(cfg = "cfail5")]
150 #[rustc_clean(cfg = "cfail6")]
151 extern "C" {
152 pub fn make_function_public(c: i32);
153 }
154
155 // Add function ----------------------------------------------------------------
156 #[cfg(any(cfail1,cfail4))]
157 extern "C" {
158 pub fn add_function1(c: i32);
159 }
160
161 #[cfg(not(any(cfail1,cfail4)))]
162 #[rustc_clean(cfg = "cfail2", except = "hir_owner,hir_owner_nodes")]
163 #[rustc_clean(cfg = "cfail3")]
164 #[rustc_clean(cfg = "cfail5", except = "hir_owner,hir_owner_nodes")]
165 #[rustc_clean(cfg = "cfail6")]
166 extern "C" {
167 pub fn add_function1(c: i32);
168 pub fn add_function2();
169 }
170
171 // Change link-name ------------------------------------------------------------
172 #[cfg(any(cfail1,cfail4))]
173 #[link(name = "foo")]
174 extern "C" {
175 pub fn change_link_name(c: i32);
176 }
177
178 #[cfg(not(any(cfail1,cfail4)))]
179 #[rustc_clean(cfg = "cfail2")]
180 #[rustc_clean(cfg = "cfail3")]
181 #[rustc_clean(cfg = "cfail5")]
182 #[rustc_clean(cfg = "cfail6")]
183 #[link(name = "bar")]
184 extern "C" {
185 pub fn change_link_name(c: i32);
186 }
187
188 type c_i32 = i32;
189 type c_i64 = i64;
190
191 // Indirectly change parameter type --------------------------------------------
192 mod indirectly_change_parameter_type {
193 #[cfg(any(cfail1,cfail4))]
194 use super::c_i32 as c_int;
195 #[cfg(not(any(cfail1,cfail4)))]
196 use super::c_i64 as c_int;
197
198 #[rustc_clean(cfg = "cfail2")]
199 #[rustc_clean(cfg = "cfail3")]
200 #[rustc_clean(cfg = "cfail5")]
201 #[rustc_clean(cfg = "cfail6")]
202 extern "C" {
203 pub fn indirectly_change_parameter_type(c: c_int);
204 }
205 }
206
207 // Indirectly change return type --------------------------------------------
208 mod indirectly_change_return_type {
209 #[cfg(any(cfail1,cfail4))]
210 use super::c_i32 as c_int;
211 #[cfg(not(any(cfail1,cfail4)))]
212 use super::c_i64 as c_int;
213
214 #[rustc_clean(cfg = "cfail2")]
215 #[rustc_clean(cfg = "cfail3")]
216 #[rustc_clean(cfg = "cfail5")]
217 #[rustc_clean(cfg = "cfail6")]
218 extern "C" {
219 pub fn indirectly_change_return_type() -> c_int;
220 }
221 }