diff options
| -rw-r--r-- | tests/ui/structs/default-field-values/visibility.rs | 29 | ||||
| -rw-r--r-- | tests/ui/structs/default-field-values/visibility.stderr | 27 |
2 files changed, 56 insertions, 0 deletions
diff --git a/tests/ui/structs/default-field-values/visibility.rs b/tests/ui/structs/default-field-values/visibility.rs new file mode 100644 index 00000000000..e1f76a5fe24 --- /dev/null +++ b/tests/ui/structs/default-field-values/visibility.rs @@ -0,0 +1,29 @@ +#![feature(default_field_values)] +pub mod foo { + pub struct Alpha { + beta: u8 = 42, + gamma: bool = true, + } +} + +mod bar { + fn baz() { + let x = crate::foo::Alpha { .. }; + //~^ ERROR field `beta` of struct `Alpha` is private + //~| ERROR field `gamma` of struct `Alpha` is private + } +} + +pub mod baz { + pub struct S { + x: i32 = 1, + } +} +fn main() { + let a = baz::S { + .. //~ ERROR field `x` of struct `S` is private + }; + let b = baz::S { + x: 0, //~ ERROR field `x` of struct `S` is private + }; +} diff --git a/tests/ui/structs/default-field-values/visibility.stderr b/tests/ui/structs/default-field-values/visibility.stderr new file mode 100644 index 00000000000..63721d79be5 --- /dev/null +++ b/tests/ui/structs/default-field-values/visibility.stderr @@ -0,0 +1,27 @@ +error[E0451]: field `x` of struct `S` is private + --> $DIR/visibility.rs:24:9 + | +LL | .. + | ^^ field `x` is private + +error[E0451]: field `x` of struct `S` is private + --> $DIR/visibility.rs:27:9 + | +LL | x: 0, + | ^^^^ private field + +error[E0451]: field `beta` of struct `Alpha` is private + --> $DIR/visibility.rs:11:37 + | +LL | let x = crate::foo::Alpha { .. }; + | ^^ field `beta` is private + +error[E0451]: field `gamma` of struct `Alpha` is private + --> $DIR/visibility.rs:11:37 + | +LL | let x = crate::foo::Alpha { .. }; + | ^^ field `gamma` is private + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0451`. |
