Skip to content

[error message][regression] Private fields in tuple-struct give unhelpful error message #41540

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

Closed
TyOverby opened this issue Apr 25, 2017 · 1 comment

Comments

@TyOverby
Copy link
Contributor

TyOverby commented Apr 25, 2017

I had a tuple-struct defined pub Line(f32, f32, f32, f32) and tried using it from another module without remembering to put pub on the fields.

Nightly and Stable have very different error messages, and the stable message is much better.

Nightly and Beta

error: tuple struct `Line` is private
  --> testsuite/src/main.rs:44:95
   |
44 |     let lines = evaluator.get_polylines(&result, &ctx).into_iter().map(|((x1, y1), (x2, y2))| formats::lines::Line(x1, y1, x2, y2));
   |                                                                                               ^^^^^^^^^^^^^^^^^^^^

Stable

error[E0450]: cannot invoke tuple struct constructor with private fields
  --> testsuite/src/main.rs:44:95
   |
44 |     let lines = evaluator.get_polylines(&result, &ctx).into_iter().map(|((x1, y1), (x2, y2))| formats::lines::Line(x1, y1, x2, y2));
   |                                                                                               ^^^^^^^^^^^^^^^^^^^^ cannot construct with a private field
   |
  ::: testsuite/src/formats.rs
   |
72 |     pub struct Line(f32, f32, f32, f32);
   |                     ---- ---- ---- ---- private field declared here
   |                     |    |    |
   |                     |    |    private field declared here
   |                     |    private field declared here
   |                     private field declared here
@petrochenkov
Copy link
Contributor

Duplicate of #39703

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants