]> git.lizzy.rs Git - rust.git/blob - tests/run-make-fulldeps/extern-fn-generic/test.rs
Rollup merge of #106441 - mllken:abstract-socket-noref, r=joshtriplett
[rust.git] / tests / run-make-fulldeps / extern-fn-generic / test.rs
1 extern crate testcrate;
2
3 extern "C" fn bar<T>(ts: testcrate::TestStruct<T>) -> T {
4     ts.y
5 }
6
7 #[link(name = "test", kind = "static")]
8 extern "C" {
9     fn call(c: extern "C" fn(testcrate::TestStruct<i32>) -> i32) -> i32;
10 }
11
12 fn main() {
13     // Let's test calling it cross crate
14     let back = unsafe { testcrate::call(testcrate::foo::<i32>) };
15     assert_eq!(3, back);
16
17     // And just within this crate
18     let back = unsafe { call(bar::<i32>) };
19     assert_eq!(3, back);
20 }