Skip to content

Parse and reject "typescript-style" anonymous enums #100741

Open
@estebank

Description

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).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-parserArea: The parsing of Rust source code to an ASTD-newcomer-roadblockDiagnostics: Confusing error or lint; hard to understand for new users.D-papercutDiagnostics: An error or lint that needs small tweaks.D-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.P-lowLow priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions