Skip to content

Tuple struct associated constants can't be initialized with Self() #44846

Closed
@jsgf

Description

@jsgf

There's an inconsistency when initializing tuple structs as associated constants with Self:

struct Foo(i32);

impl Foo {
const A: Self = Self(1); // Fails with "did you mean `Self { /* fields */ }`?"
const B: Self = Self { 0: 2 }; // succeeds
}

I'd expect Self(1) to work if Self { 0: 2 } works.

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