Parse and reject "typescript-style" anonymous enums #100741
Open
Description
opened on Aug 19, 2022
Given
fn foo() -> i32 | &str { 42 }
we currently point at the |
and complain about it not being expected.
Ideally, this should parse and explicitly state that anonymous enums are not supported, and provide a structured suggestion for
enum Name<'a> {
VariantI32(i32),
VariantStr(&'a str),
}
fn foo() -> Name<'_> {
Name::VariantI32(42)
}
At least, we should emit a note suggesting the above in text without a structured suggestion (which will be easier to produce).
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsArea: The parsing of Rust source code to an ASTDiagnostics: Confusing error or lint; hard to understand for new users.Diagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that doesn't give enough information about the problem at hand.Low priorityRelevant to the compiler team, which will review and decide on the PR/issue.
Activity