1 // allow(const_err) to work around a bug in warnings
3 static FOO: fn() = || { assert_ne!(42, 43) };
5 static BAR: fn(i32, i32) = |a, b| { assert_ne!(a, b) };
7 // use to first make the closure FnOnce() before making it fn()
8 fn magic0<R, F: FnOnce() -> R>(f: F) -> F { f }
9 fn magic1<T, R, F: FnOnce(T) -> R>(f: F) -> F { f }
14 let bar: unsafe fn(i32, i32) = BAR;
15 unsafe { bar(46, 47) };
16 let boo: &dyn Fn(i32, i32) = &BAR;
21 let f = magic0(||{}) as fn();
24 let g: fn(i32) = |i| assert_eq!(i, 2);
26 let g = magic1(|i| assert_eq!(i, 2)) as fn(i32);
29 // FIXME: This fails with "invalid use of NULL pointer"
30 //let h: fn() -> ! = || std::process::exit(0);
32 // FIXME: This does not even compile?!?
33 //let h = magic0(|| std::process::exit(0)) as fn() -> !;