]> git.proxmox.com Git - rustc.git/blame - tests/run-make-fulldeps/extern-fn-generic/test.rs
New upstream version 1.69.0+dfsg1
[rustc.git] / tests / run-make-fulldeps / extern-fn-generic / test.rs
CommitLineData
1a4d82fc
JJ
1extern crate testcrate;
2
5869c6ff
XL
3extern "C" fn bar<T>(ts: testcrate::TestStruct<T>) -> T {
4 ts.y
5}
1a4d82fc 6
476ff2be 7#[link(name = "test", kind = "static")]
5869c6ff 8extern "C" {
1a4d82fc
JJ
9 fn call(c: extern "C" fn(testcrate::TestStruct<i32>) -> i32) -> i32;
10}
11
12fn main() {
13 // Let's test calling it cross crate
5869c6ff 14 let back = unsafe { testcrate::call(testcrate::foo::<i32>) };
1a4d82fc
JJ
15 assert_eq!(3, back);
16
17 // And just within this crate
5869c6ff 18 let back = unsafe { call(bar::<i32>) };
1a4d82fc
JJ
19 assert_eq!(3, back);
20}