Skip to content

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

Closed
@TyOverby

Description

@TyOverby

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions