Skip to content

Confusing error message when using tuple struct constructor with private fields #45481

Closed
@jethrogb

Description

@jethrogb
mod a {
    pub struct A(u64);
}

fn main() {
    let x: fn(u64) -> a::A = a::A;
}

Error message:

error[E0603]: tuple struct `A` is private
 --> src/main.rs:6:30
  |
6 |     let x: fn(u64) -> a::A = a::A;
  |                              ^^^^

But as you can see in the code, it's not the struct that's private, it's the constructor.

Metadata

Metadata

Assignees

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