@@ -28,8 +28,38 @@ note: required by a bound in `require_fn`
28
28
LL | fn require_fn(_: impl Fn() -> i32) {}
29
29
| ^^^ required by this bound in `require_fn`
30
30
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
+
31
61
error[E0277]: expected a `Fn<()>` closure, found `extern "C" fn() -> i32`
32
- --> $DIR/fn-trait.rs:24 :16
62
+ --> $DIR/fn-trait.rs:26 :16
33
63
|
34
64
LL | require_fn(g as extern "C" fn() -> i32);
35
65
| ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected an `Fn<()>` closure, found `extern "C" fn() -> i32`
@@ -45,7 +75,7 @@ LL | fn require_fn(_: impl Fn() -> i32) {}
45
75
| ^^^^^^^^^^^ required by this bound in `require_fn`
46
76
47
77
error[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
49
79
|
50
80
LL | require_fn(g as extern "C" fn() -> i32);
51
81
| ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ types differ
@@ -58,7 +88,37 @@ note: required by a bound in `require_fn`
58
88
LL | fn require_fn(_: impl Fn() -> i32) {}
59
89
| ^^^ required by this bound in `require_fn`
60
90
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
62
122
63
123
Some errors have detailed explanations: E0271, E0277.
64
124
For more information about an error, try `rustc --explain E0271`.
0 commit comments