Skip to content

E0063 should not suggest adding inaccessible private fields #76077

Closed
@kornelski

Description

@kornelski

This error message could be more helpful:

pub mod foo {
    pub struct Foo {
        you_cant_use_this_field: bool,
    }
}

fn main() {
    foo::Foo {};
}

error[E0063]: missing field you_cant_use_this_field in initializer of foo::Foo

It complains about lack of a private field in the initializer, but this problem can't be solved by adding the field. The implied solution is impossible, and will only lead to another dead-end error.

It would be better to explain in general that this struct can't be constructed from a literal syntax here, because it contains private fields. Bonus points for finding methods that return Self and suggesting them.

related forum thread

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.D-newcomer-roadblockDiagnostics: Confusing error or lint; hard to understand for new users.T-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