Skip to content

Error for instantiating tuple struct with private field has regressed on nightly #39703

Closed
@jonas-schievink

Description

@jonas-schievink
fn main() {
    module::TupleStruct(0);
}

pub mod module {
    pub struct TupleStruct(u8);
}

On stable/beta, the error message is very good:

error[E0450]: cannot invoke tuple struct constructor with private fields
 --> <anon>:2:5
  |
2 |     module::TupleStruct(0);
  |     ^^^^^^^^^^^^^^^^^^^ cannot construct with a private field
...
6 |     pub struct TupleStruct(u8);
  |                            --- private field declared here

error: aborting due to previous error

On nightly, it's flat out lying to the user:

error: tuple struct `TupleStruct` is private
 --> <anon>:2:5
  |
2 |     module::TupleStruct(0);
  |     ^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsA-resolveArea: Name/path resolution done by `rustc_resolve` specificallyC-enhancementCategory: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions