summaryrefslogtreecommitdiffstats
path: root/src/test/ui/coercion/unsafe-coercion.rs
blob: 2478deeab0d4fa43212f36b796349f6fc4a9af02 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// run-pass
// Check that safe fns are not a subtype of unsafe fns.


fn foo(x: i32) -> i32 {
    x * 22
}

fn bar(x: fn(i32) -> i32) -> unsafe fn(i32) -> i32 {
    x // OK, coercion!
}

fn main() {
    let f = bar(foo);
    let x = unsafe { f(2) };
    assert_eq!(x, 44);
}