summaryrefslogtreecommitdiffstats
path: root/src/test/run-make-fulldeps/extern-fn-generic/test.rs
blob: c9baa489881b1b3a6d6e90571a162fa89233315b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
extern crate testcrate;

extern "C" fn bar<T>(ts: testcrate::TestStruct<T>) -> T {
    ts.y
}

#[link(name = "test", kind = "static")]
extern "C" {
    fn call(c: extern "C" fn(testcrate::TestStruct<i32>) -> i32) -> i32;
}

fn main() {
    // Let's test calling it cross crate
    let back = unsafe { testcrate::call(testcrate::foo::<i32>) };
    assert_eq!(3, back);

    // And just within this crate
    let back = unsafe { call(bar::<i32>) };
    assert_eq!(3, back);
}