Missing field error in initializer for struct with inaccessible fields #87872
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Given the following code:
Using
rustc a.rs
followed byrustc -L . b.rs
, the current output is:Ideally the output should look like:
The rationale is the same as for #76077. Following the suggestion provided by the compiler will lead to another error. This can be frustrating with structs that have a large number of fields or fields with complex types, since the effort of adding those fields to the struct literal is in vain.
By removing the field f from the struct, the compiler is reporting that X cannot be constructed, as expected.
Tested on both
rustc 1.56.0-nightly (574d37568 2021-08-07)
andrustc 1.52.0-nightly (4a8b6f708 2021-03-11)
.The text was updated successfully, but these errors were encountered: