Closed
Description
pub mod m {
pub struct S {
pub visible: bool,
private: (),
also_private: String,
}
}
fn main() {
let _ = m::S {
visible: true,
private: (),
};
}
The current output is:
error: cannot construct `S` with struct literal syntax due to inaccessible fields
[--> src/main.rs:10:13
](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=9f3e3c29a1dd0db9008d9683c108b330#) |
10 | let _ = m::S {
| ^^^^
Ideally, the output should
- Explain more fully that there are private fields, perhaps via
--explain
- Not occlude E0451 when some private fields are supplied (as in the above example)
In my opinion, the errors when you supply all the private fields are more understandable than those when you supply none or only some of the private fields. See also this URLO thread.
I believe the current output is a result of #87872.
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Relevant to the compiler team, which will review and decide on the PR/issue.