Given the following code:
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.
Given the following code:
The current output is:
Ideally, the output should
--explainIn 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.