From deef3ebaec2ff0ff818161f3b9b86a42bed5fe36 Mon Sep 17 00:00:00 2001 From: Esteban Küber Date: Sat, 18 Jan 2025 20:07:05 +0000 Subject: 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 ``` --- tests/ui/error-codes/E0451.stderr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/ui/error-codes') diff --git a/tests/ui/error-codes/E0451.stderr b/tests/ui/error-codes/E0451.stderr index 419cf117efe..2cd30095c80 100644 --- a/tests/ui/error-codes/E0451.stderr +++ b/tests/ui/error-codes/E0451.stderr @@ -8,7 +8,7 @@ error[E0451]: field `b` of struct `Foo` is private --> $DIR/E0451.rs:18:29 | LL | let f = bar::Foo{ a: 0, b: 0 }; - | ^^^^ private field + | ^ private field error: aborting due to 2 previous errors -- cgit 1.4.1-3-g733a5