When trying to construct a struct that has a public field of a private type, suggest using `..` if that field has a default value.
```
error[E0603]: struct `Priv1` is private
--> $DIR/non-exhaustive-ctor.rs:25:39
|
LL | let _ = S { field: (), field1: m::Priv1 {} };
| ------ ^^^^^ private struct
| |
| while setting this field
|
note: the struct `Priv1` is defined here
--> $DIR/non-exhaustive-ctor.rs:14:4
|
LL | struct Priv1 {}
| ^^^^^^^^^^^^
help: the field `field1` you're trying to set has a default value, you can use `..` to use it
|
LL | let _ = S { field: (), .. };
| ~~
```
16 lines
166 B
Rust
16 lines
166 B
Rust
#![feature(default_field_values)]
|
|
|
|
pub struct A {
|
|
pub a: isize = 42,
|
|
}
|
|
|
|
struct Priv;
|
|
|
|
pub struct B {
|
|
pub a: Priv = Priv,
|
|
}
|
|
|
|
pub struct C {
|
|
pub a: Priv,
|
|
}
|