]> git.lizzy.rs Git - rust.git/blob - src/test/ui/unboxed-closures/unboxed-closures-wrong-arg-type-extern-fn.rs
Rollup merge of #57107 - mjbshaw:thread_local_test, r=nikomatsakis
[rust.git] / src / test / ui / unboxed-closures / unboxed-closures-wrong-arg-type-extern-fn.rs
1 // Tests that unsafe extern fn pointers do not implement any Fn traits.
2
3 use std::ops::{Fn,FnMut,FnOnce};
4
5 unsafe fn square(x: isize) -> isize { x * x }
6 // note: argument type here is `isize`, not `&isize`
7
8 fn call_it<F:Fn(&isize)->isize>(_: &F, _: isize) -> isize { 0 }
9 fn call_it_mut<F:FnMut(&isize)->isize>(_: &mut F, _: isize) -> isize { 0 }
10 fn call_it_once<F:FnOnce(&isize)->isize>(_: F, _: isize) -> isize { 0 }
11
12 fn a() {
13     let x = call_it(&square, 22);
14     //~^ ERROR E0277
15 }
16
17 fn b() {
18     let y = call_it_mut(&mut square, 22);
19     //~^ ERROR E0277
20 }
21
22 fn c() {
23     let z = call_it_once(square, 22);
24     //~^ ERROR E0277
25 }
26
27 fn main() { }