rust/tests/ui/structs/default-field-values
许杰友 Jieyou Xu (Joe) 6db2d1aae5
Rollup merge of #135700 - estebank:priv-field-dfv, r=wesleywiser
Emit single privacy error for struct literal with multiple private fields and add test for `default_field_values` privacy

Add test ensuring that struct with default field values is not constructable if the fields are not accessible.

Collect all unreachable fields in a single struct literal struct and emit a single error, instead of one error per private field.

```
error[E0451]: fields `beta` and `gamma` of struct `Alpha` are private
  --> $DIR/visibility.rs:18:13
   |
LL |     let _x = Alpha {
   |              ----- in this type
LL |         beta: 0,
   |         ^^^^^^^ private field
LL |         ..
   |         ^^ field `gamma` is private
```
2025-01-20 12:37:54 +08:00
..
auxiliary
empty-struct.rs Disallow A { .. } if A has no fields 2025-01-18 21:05:09 +00:00
empty-struct.stderr Disallow A { .. } if A has no fields 2025-01-18 21:05:09 +00:00
failures.rs
failures.stderr
invalid-const.rs
invalid-const.stderr
support.rs
use-normalized-ty-for-default-struct-value.rs Make sure to use normalized ty for unevaluated const for default struct value 2024-12-14 18:05:19 +00:00
visibility.rs Emit a single privacy error for multiple fields on the same struct expression 2025-01-18 20:33:15 +00:00
visibility.stderr Emit a single privacy error for multiple fields on the same struct expression 2025-01-18 20:33:15 +00:00