]> git.lizzy.rs Git - rust.git/blob - src/test/ui/unsafe-coercion.rs
Auto merge of #75936 - sdroege:chunks-exact-construction-bounds-check, r=nagisa
[rust.git] / src / test / ui / unsafe-coercion.rs
1 // run-pass
2 // Check that safe fns are not a subtype of unsafe fns.
3
4
5 fn foo(x: i32) -> i32 {
6     x * 22
7 }
8
9 fn bar(x: fn(i32) -> i32) -> unsafe fn(i32) -> i32 {
10     x // OK, coercion!
11 }
12
13 fn main() {
14     let f = bar(foo);
15     let x = unsafe { f(2) };
16     assert_eq!(x, 44);
17 }