-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Open
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-visibilityArea: Visibility / privacyArea: Visibility / privacyC-bugCategory: This is a bug.Category: This is a bug.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
mod foo {
pub struct Foo {
private: i32,
}
}
use foo::Foo;
fn main() {
let mut foo = Foo { private: 0_usize };
}
Errors:
Compiling playground v0.0.1 (/playground)
error[E0308]: mismatched types
--> src/main.rs:11:34
|
11 | let mut foo = Foo { private: 0_usize } ;
| ^^^^^^^ expected i32, found usize
error: aborting due to previous error
For more information about this error, try `rustc --explain E0308`.
error: Could not compile `playground`.
To learn more, run the command again with --verbose.
The error message here is incorrect. Whether the types match or not is irrelevant, because the field is private. The error should say something like this instead (playground):
error[E0451]: field `private` of struct `foo::Foo` is private
--> src/main.rs:10:25
|
10 | let mut foo = Foo { private: 0_i32 };
| ^^^^^^^^^^^^^^ field `private` is private
error: aborting due to previous error
kleimkuhler
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-visibilityArea: Visibility / privacyArea: Visibility / privacyC-bugCategory: This is a bug.Category: This is a bug.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.