Skip to content

Tweak message on ADT with private fields building #118453

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion compiler/rustc_hir_typeck/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2090,7 +2090,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
[] => unreachable!(),
};
err.note(format!(
"... and other private field{s} {names}that {were} not provided",
"{}private field{s} {names}that {were} not provided",
if used_fields.is_empty() { "" } else { "...and other " },
s = pluralize!(remaining_private_fields_len),
were = pluralize!("was", remaining_private_fields_len),
));
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/issues/issue-76077.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ error: cannot construct `Foo` with struct literal syntax due to private fields
LL | foo::Foo {};
| ^^^^^^^^
|
= note: ... and other private field `you_cant_use_this_field` that was not provided
= note: private field `you_cant_use_this_field` that was not provided

error: aborting due to 1 previous error

2 changes: 1 addition & 1 deletion tests/ui/privacy/issue-79593.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ error: cannot construct `Pub` with struct literal syntax due to private fields
LL | foo::Pub {};
| ^^^^^^^^
|
= note: ... and other private field `private` that was not provided
= note: private field `private` that was not provided

error[E0063]: missing field `y` in initializer of `Enum`
--> $DIR/issue-79593.rs:23:5
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/privacy/suggest-box-new.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ error: cannot construct `HashMap<_, _, _>` with struct literal syntax due to pri
LL | let _ = std::collections::HashMap {};
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: ... and other private field `base` that was not provided
= note: private field `base` that was not provided
help: you might have meant to use an associated function to build this type
|
LL | let _ = std::collections::HashMap::new();
Expand All @@ -78,7 +78,7 @@ error: cannot construct `Box<_, _>` with struct literal syntax due to private fi
LL | let _ = Box {};
| ^^^
|
= note: ... and other private fields `0` and `1` that were not provided
= note: private fields `0` and `1` that were not provided
help: you might have meant to use an associated function to build this type
|
LL | let _ = Box::new(_);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ error: cannot construct `Foo` with struct literal syntax due to private fields
LL | foo::Foo {};
| ^^^^^^^^
|
= note: ... and other private field `you_cant_use_this_field` that was not provided
= note: private field `you_cant_use_this_field` that was not provided

error: aborting due to 1 previous error

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ LL | a: (),
LL | b: (),
| ----- private field
|
= note: ... and other private fields `c`, `d` and `e` that were not provided
= note: ...and other private fields `c`, `d` and `e` that were not provided

error: aborting due to 1 previous error