-
Couldn't load subscription status.
- Fork 13.9k
Closed
Closed
Copy link
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Code
mod m {
pub struct S(crate::P);
}
use m::S;
struct P;
impl P {
fn foo(self) {
// S(P); // OK, "cannot initialize a tuple struct which contains private fields"
S(self);
}
}Current output
error[E0423]: expected function, tuple struct or tuple variant, found struct `S`
--> src/main.rs:13:9
|
13 | S(self);
| ^------
| |
| help: try calling `S` as a method: `self.S()`Desired output
error[E0423]: cannot initialize a tuple struct which contains private fields
note: constructor is not visible here due to private fieldsRationale and extra context
No response
Other cases
let s = self;
S(s); // cannot initialize a tuple struct which contains private fieldsRust Version
rustc 1.91.0-beta.3 (bb624dcb4 2025-09-20)
binary: rustc
commit-hash: bb624dcb4c8ab987e10c0808d92d76f3b84dd117
commit-date: 2025-09-20
host: x86_64-unknown-linux-gnu
release: 1.91.0-beta.3
LLVM version: 21.1.1Anything else?
No response
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.