Skip to content

Parser does not stop early enough if keyword is found instead of ident #28439

Closed
@nagisa

Description

@nagisa

For

enum A {
    enum A
}

and for

struct A {
    mod A
}

2 errors are emitted for each

test.rs:2:5: 2:9 error: expected identifier, found keyword `enum`
test.rs:2     enum A
              ^~~~
test.rs:2:10: 2:11 error: expected one of `(`, `,`, `=`, `{`, or `}`, found `A`
test.rs:2     enum A
                   ^

and

test.rs:2:5: 2:8 error: expected identifier, found keyword `mod`
test.rs:2     mod A
              ^~~
test.rs:2:9: 2:10 error: expected `:`, found `A`
test.rs:2     mod A
                  ^

2nd error should not happen.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions