-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
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.
compiler-errors, estebank and TaKO8Ki
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.