Closed
Description
Code
I tried this code: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=7f3bdb07bcc3a0a30d2ef80cf0adfd22
let closure = |f: fn(&f32) -> f32| MyStruct { x: f(&y) };
This code should compile.
Instead of compiling, the compiler generates the following error:
error: anonymous enums are not supported
--> src/main.rs:8:38
|
8 | let closure = |f: fn(&f32) -> f32| MyStruct { x: f(&y) };
| ---^ --------
|
= help: create a named `enum` and use it here instead:
enum Name {
Variant1(f32),
Variant2(MyStruct),
}
error: expected one of `!`, `(`, `,`, `::`, `<`, or `|`, found `{`
--> src/main.rs:8:49
|
8 | let closure = |f: fn(&f32) -> f32| MyStruct { x: f(&y) };
| ^ expected one of `!`, `(`, `,`, `::`, `<`, or `|`
error: could not compile `playground` due to 2 previous errors
Version it worked on
It most recently worked on: (1.67)
Version with regression
Breaks in latest nightly 1.69.0-nightly (2023-01-29 e972bc8)
Related: