Skip to content

enum struct variants can mask regular struct constructors #5792

Closed
@erickt

Description

@erickt

@thestinger found this odd bug. This code:

enum Foo { C { a: int, b: int } }
struct C { a: int, b: int }
fn main() { }

properly errors out with:

test.rs:2:0: 2:27 error: duplicate definition of type C
test.rs:2 struct C { a: int, b: int }
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~
test.rs:1:11: 1:31 note: first definition of type C here:
test.rs:1 enum Foo { C { a: int, b: int } }
                     ^~~~~~~~~~~~~~~~~~~~

However, if you swap the enum and struct definition, it compiles fine with rust HEAD:

struct C { a: int, b: int }
enum Foo { C { a: int, b: int } }
fn main() { }

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-resolveArea: Name/path resolution done by `rustc_resolve` specifically

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions