Closed
Description
I tried this code:
fn f() -> i32 {
0
}
fn returns_fn_pointer() -> _ {
f
}
The resulting diagnostic suggests replacing _
with fn() -> i32 {f}
, the unique type of f()
:
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
--> src/lib.rs:5:28
|
5 | fn returns_fn_pointer() -> _ {
| ^
| |
| not allowed in type signatures
| help: replace with the correct return type: `fn() -> i32 {f}`
This, of course, doesn't work:
error: expected item, found `{`
--> src/lib.rs:5:44
|
5 | fn returns_fn_pointer() -> fn() -> i32 {f} {
| ^ expected item
I'd expect the diagnostic to suggest replacing _
with fn() -> i32
or impl Fn() -> i32
, both of which compile successfully.
Meta
rustc --version --verbose
:
rustc 1.50.0-nightly (2225ee1b6 2020-12-11)
binary: rustc
commit-hash: 2225ee1b62ff089917434aefd9b2bf509cfa087f
commit-date: 2020-12-11
host: x86_64-unknown-linux-gnu
release: 1.50.0-nightly