rust/compiler
bors 21a19c297d Auto merge of #135846 - estebank:non-exhaustive-dfv-ctor-2, r=BoxyUwU
Detect struct construction with private field in field with default

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-2.rs:19: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-2.rs:14:4
   |
LL |    struct Priv1 {}
   |    ^^^^^^^^^^^^
help: the type `Priv1` of field `field1` is private, but you can construct the default value defined for it in `S` using `..` in the struct initializer expression
   |
LL |     let _ = S { field: (), .. };
   |                            ~~
```
2025-08-10 23:47:25 +00:00
..
2025-08-09 15:47:01 +08:00
2025-08-09 15:47:01 +08:00
2025-08-09 15:47:01 +08:00
2025-08-09 15:47:01 +08:00
2025-08-09 15:47:01 +08:00
2025-08-10 19:15:20 +00:00
2025-08-10 19:15:20 +00:00