Skip to content

Fix private fields diagnostics and improve error messages#154867

Open
chenyukang wants to merge 1 commit intorust-lang:mainfrom
chenyukang:yukang-fix-151408-private-fields-diagnostic
Open

Fix private fields diagnostics and improve error messages#154867
chenyukang wants to merge 1 commit intorust-lang:mainfrom
chenyukang:yukang-fix-151408-private-fields-diagnostic

Conversation

@chenyukang
Copy link
Copy Markdown
Member

@chenyukang chenyukang commented Apr 6, 2026

Fixes #151408

while the best solution may be check whether the code is under user's control, e.g. in the same workspace. but if user does not provide some fields, mention other private fields seems weird, see the test case:

LL |     let _ = std::collections::HashMap {};
   |             ^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: private field `base` that was not provided

since we already suggested to use associated function to construct, it's better to remove the note.

this fix only provide note on private fields when did.is_local() or user have already provide some fields.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 6, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 6, 2026

r? @dingxiangfei2009

rustbot has assigned @dingxiangfei2009.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 69 candidates
  • Random selection from 10 candidates

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Private fields are displayed in the error message for using struct or tuple struct literal syntax

3 participants