-
Notifications
You must be signed in to change notification settings - Fork 14k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsI-prioritizeIssue: Indicates that prioritization has been requested for this issue.Issue: Indicates that prioritization has been requested for this issue.T-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.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.Performance or correctness regression from stable to nightly.
Description
Code
struct Foo {}
struct Bar {}
impl Foo {
fn into_bar(self) -> Bar {
Bar(self)
}
}Current output
error[E0423]: cannot initialize a tuple struct which contains private fields
--> src/lib.rs:6:9
|
6 | Bar(self)
| ^^^
|
= note: constructor is not visible here due to private fieldsDesired output
error[E0423]: expected function, tuple struct or tuple variant, found struct `Bar`
--> src/lib.rs:6:9
|
6 | Bar(self)
| ^^^Rationale and extra context
The message is incorrect in two ways:
Baris not a tuple structBarhas no private fields
It appears that something is making too many assumptions about why a tuple struct constructor might not be visible at a specific call site.
Other cases
The incorrect diagnostic only occurs for Bar(self), and not when a normal variable is used in place of self. It also seems like sometimes the correct error is printed, nondeterministically, but I have not found consistent reproduction conditions.
Rust Version
rustc 1.93.0-nightly (01867557c 2025-11-12)
binary: rustc
commit-hash: 01867557cd7dbe256a031a7b8e28d05daecd75ab
commit-date: 2025-11-12
host: aarch64-apple-darwin
release: 1.93.0-nightly
LLVM version: 21.1.5Anything else?
@rustbot label +regression-from-stable-to-nightly
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsI-prioritizeIssue: Indicates that prioritization has been requested for this issue.Issue: Indicates that prioritization has been requested for this issue.T-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.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.Performance or correctness regression from stable to nightly.