Non-public tuple fields causes confusing error message when crossing module boundaries #52144
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
A-visibility
Area: Visibility / privacy
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
D-papercut
Diagnostics: An error or lint that needs small tweaks.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
This gave me the following error message:
It turns out the fix for this was to change my struct definition to
pub struct SomeId(pub u32);
. This was not obvious to me for several reasons:expected function, found struct SomeId
is odd because that's what I'm trying to perform, so it appears like it's erroring because it's doing what I want.constructor is not visible here due to private fields
didn't make sense to me as the rust book never gives an example of theStruct(pub fieldType)
syntax, so I assumed tuple fields had the same visibility as the struct itself.It probably needs a recommendation for tuple structs to show that all fields should be marked as
pub
The text was updated successfully, but these errors were encountered: