@@ -28,8 +28,38 @@ note: required by a bound in `require_fn`
2828LL | fn require_fn(_: impl Fn() -> i32) {}
2929 | ^^^ required by this bound in `require_fn`
3030
31+ error[E0277]: expected a `Fn<()>` closure, found `extern "C" fn() -> i32 {g}`
32+ --> $DIR/fn-trait.rs:23:16
33+ |
34+ LL | require_fn(g);
35+ | ---------- ^ expected an `Fn<()>` closure, found `extern "C" fn() -> i32 {g}`
36+ | |
37+ | required by a bound introduced by this call
38+ |
39+ = help: the trait `Fn<()>` is not implemented for fn item `extern "C" fn() -> i32 {g}`
40+ = note: wrap the `extern "C" fn() -> i32 {g}` in a closure with no arguments: `|| { /* code */ }`
41+ note: required by a bound in `require_fn`
42+ --> $DIR/fn-trait.rs:3:23
43+ |
44+ LL | fn require_fn(_: impl Fn() -> i32) {}
45+ | ^^^^^^^^^^^ required by this bound in `require_fn`
46+
47+ error[E0271]: type mismatch resolving `<extern "C" fn() -> i32 {g} as FnOnce<()>>::Output == i32`
48+ --> $DIR/fn-trait.rs:23:16
49+ |
50+ LL | require_fn(g);
51+ | ---------- ^ types differ
52+ | |
53+ | required by a bound introduced by this call
54+ |
55+ note: required by a bound in `require_fn`
56+ --> $DIR/fn-trait.rs:3:31
57+ |
58+ LL | fn require_fn(_: impl Fn() -> i32) {}
59+ | ^^^ required by this bound in `require_fn`
60+
3161error[E0277]: expected a `Fn<()>` closure, found `extern "C" fn() -> i32`
32- --> $DIR/fn-trait.rs:24 :16
62+ --> $DIR/fn-trait.rs:26 :16
3363 |
3464LL | require_fn(g as extern "C" fn() -> i32);
3565 | ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected an `Fn<()>` closure, found `extern "C" fn() -> i32`
@@ -45,7 +75,7 @@ LL | fn require_fn(_: impl Fn() -> i32) {}
4575 | ^^^^^^^^^^^ required by this bound in `require_fn`
4676
4777error[E0271]: type mismatch resolving `<extern "C" fn() -> i32 as FnOnce<()>>::Output == i32`
48- --> $DIR/fn-trait.rs:24 :16
78+ --> $DIR/fn-trait.rs:26 :16
4979 |
5080LL | require_fn(g as extern "C" fn() -> i32);
5181 | ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ types differ
@@ -58,7 +88,37 @@ note: required by a bound in `require_fn`
5888LL | fn require_fn(_: impl Fn() -> i32) {}
5989 | ^^^ required by this bound in `require_fn`
6090
61- error: aborting due to 4 previous errors
91+ error[E0277]: expected a `Fn<()>` closure, found `unsafe fn() -> i32 {h}`
92+ --> $DIR/fn-trait.rs:29:16
93+ |
94+ LL | require_fn(h);
95+ | ---------- ^ call the function in a closure: `|| unsafe { /* code */ }`
96+ | |
97+ | required by a bound introduced by this call
98+ |
99+ = help: the trait `Fn<()>` is not implemented for fn item `unsafe fn() -> i32 {h}`
100+ = note: wrap the `unsafe fn() -> i32 {h}` in a closure with no arguments: `|| { /* code */ }`
101+ note: required by a bound in `require_fn`
102+ --> $DIR/fn-trait.rs:3:23
103+ |
104+ LL | fn require_fn(_: impl Fn() -> i32) {}
105+ | ^^^^^^^^^^^ required by this bound in `require_fn`
106+
107+ error[E0271]: type mismatch resolving `<unsafe fn() -> i32 {h} as FnOnce<()>>::Output == i32`
108+ --> $DIR/fn-trait.rs:29:16
109+ |
110+ LL | require_fn(h);
111+ | ---------- ^ types differ
112+ | |
113+ | required by a bound introduced by this call
114+ |
115+ note: required by a bound in `require_fn`
116+ --> $DIR/fn-trait.rs:3:31
117+ |
118+ LL | fn require_fn(_: impl Fn() -> i32) {}
119+ | ^^^ required by this bound in `require_fn`
120+
121+ error: aborting due to 8 previous errors
62122
63123Some errors have detailed explanations: E0271, E0277.
64124For more information about an error, try `rustc --explain E0271`.
0 commit comments