Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warn/error if using struct constructor and there's at least one private field #6255

Open
asterite opened this issue Oct 9, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@asterite
Copy link
Collaborator

asterite commented Oct 9, 2024

Problem

Once #6221 is merged, this code:

mod moo {
    pub struct Foo {
        x: Field
    }
}

fn main() {
    let _ = moo::Foo { x: 1 };
}

errors saying that x is private. However, a better error message could be that Foo can't be constructed (outside of its module) because some of its fields are private.

Happy Case

The compiler gives a clearer error message.

Workaround

None

Workaround Description

No response

Additional Context

No response

Project Impact

None

Blocker Context

No response

Would you like to submit a PR for this Issue?

None

Support Needs

No response

@asterite asterite added the enhancement New feature or request label Oct 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: 📋 Backlog
Development

No branches or pull requests

1 participant