1
Fork 0

Emit a single privacy error for multiple fields on the same struct expression

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
```
This commit is contained in:
Esteban Küber 2025-01-18 20:07:05 +00:00
parent bbcf26fc33
commit deef3ebaec
13 changed files with 199 additions and 82 deletions

View file

@ -1,6 +1,19 @@
privacy_field_is_private = field `{$field_name}` of {$variant_descr} `{$def_path_str}` is private
privacy_field_is_private =
{$len ->
[1] field
*[other] fields
} {$field_names} of {$variant_descr} `{$def_path_str}` {$len ->
[1] is
*[other] are
} private
.label = in this type
privacy_field_is_private_is_update_syntax_label = field `{$field_name}` is private
privacy_field_is_private_is_update_syntax_label = {$rest_len ->
[1] field
*[other] fields
} {$rest_field_names} {$rest_len ->
[1] is
*[other] are
} private
privacy_field_is_private_label = private field
privacy_from_private_dep_in_public_interface =