Add test for public struct with private fields

This commit is contained in:
Esteban Küber 2023-11-08 21:59:10 +00:00
parent a4f47de7ff
commit e0e379b6fd
3 changed files with 19 additions and 1 deletions

View File

@ -18,6 +18,11 @@ pub enum Unit {
#[derive(Copy, Clone)]
pub struct StructWithFields {
pub foo: isize,
}
#[derive(Copy, Clone)]
pub struct StructWithPrivFields {
foo: isize,
}

View File

@ -8,5 +8,7 @@
fn main() {
let _ = xcrate_unit_struct::StructWithFields;
//~^ ERROR expected value, found struct `xcrate_unit_struct::StructWithFields`
let _ = xcrate_unit_struct::StructWithPrivFields;
//~^ ERROR expected value, found struct `xcrate_unit_struct::StructWithPrivFields`
let _ = xcrate_unit_struct::Struct;
}

View File

@ -9,6 +9,17 @@ LL | let _ = xcrate_unit_struct::StructWithFields;
LL | pub struct StructWithFields {
| --------------------------- `xcrate_unit_struct::StructWithFields` defined here
error: aborting due to previous error
error[E0423]: expected value, found struct `xcrate_unit_struct::StructWithPrivFields`
--> $DIR/xcrate-unit-struct.rs:11:13
|
LL | let _ = xcrate_unit_struct::StructWithPrivFields;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use struct literal syntax instead: `xcrate_unit_struct::StructWithPrivFields { foo: val }`
|
::: $DIR/auxiliary/xcrate_unit_struct.rs:25:1
|
LL | pub struct StructWithPrivFields {
| ------------------------------- `xcrate_unit_struct::StructWithPrivFields` defined here
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0423`.