]> git.proxmox.com Git - rustc.git/blame - src/test/ui/unsafe-coercion.rs
New upstream version 1.49.0+dfsg1
[rustc.git] / src / test / ui / unsafe-coercion.rs
CommitLineData
416331ca 1// run-pass
c34b1796 2// Check that safe fns are not a subtype of unsafe fns.
223e47cc 3
c34b1796
AL
4
5fn foo(x: i32) -> i32 {
6 x * 22
223e47cc
LB
7}
8
c34b1796
AL
9fn bar(x: fn(i32) -> i32) -> unsafe fn(i32) -> i32 {
10 x // OK, coercion!
223e47cc
LB
11}
12
13fn main() {
c34b1796
AL
14 let f = bar(foo);
15 let x = unsafe { f(2) };
16 assert_eq!(x, 44);
223e47cc 17}