2019-07-27 00:54:25 +03:00
|
|
|
// run-pass
|
2015-03-17 15:22:11 -04:00
|
|
|
// Check that safe fns are not a subtype of unsafe fns.
|
|
|
|
|
2015-03-22 13:13:15 -07:00
|
|
|
|
2015-03-17 15:22:11 -04:00
|
|
|
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);
|
|
|
|
}
|