Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resolve: private fields in tuple struct ctor diag #78401

Merged

Conversation

davidtwco
Copy link
Member

Fixes #75906.

This PR improves the diagnostic emitted when a tuple struct is being constructed which has private fields so that private fields are labelled and the message is improved.

r? @estebank

This commit improves the diagnostic emitted when a tuple struct is being
constructed which has private fields so that private fields are
labelled and the message is improved.

Signed-off-by: David Wood <david@davidtw.co>
@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 26, 2020
Comment on lines +972 to +974
non_visible_spans
.into_iter()
.for_each(|s| m.push_span_label(s, "private field".to_string()));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh! I hadn't thought about doing this this way! neat.

@estebank
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Oct 26, 2020

📌 Commit 27bb27f has been approved by estebank

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 26, 2020
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 28, 2020
Rollup of 10 pull requests

Successful merges:

 - rust-lang#78152 (Separate unsized locals)
 - rust-lang#78297 (Suggest calling await on method call and field access)
 - rust-lang#78351 (Move "mutable thing in const" check from interning to validity)
 - rust-lang#78365 (check object safety of generic constants)
 - rust-lang#78379 (Tweak invalid `fn` header and body parsing)
 - rust-lang#78391 (Add const_fn in generics test)
 - rust-lang#78401 (resolve: private fields in tuple struct ctor diag)
 - rust-lang#78408 (Remove tokens from foreign items in `TokenStripper`)
 - rust-lang#78447 (Fix typo in  comment)
 - rust-lang#78453 (Fix typo in comments)

Failed merges:

r? `@ghost`
@bors bors merged commit c9279c8 into rust-lang:master Oct 28, 2020
@rustbot rustbot added this to the 1.49.0 milestone Oct 28, 2020
@davidtwco davidtwco deleted the issue-75906-tuple-construct-private-field branch October 28, 2020 09:02
Copy link
Contributor

@guswynn guswynn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe for both constructor and pattern cases we need to still extend this to work across crate boundaries (see src/test/ui/issues/issue-75907_b.rs not having the private_field spans)

should we create a follow up issue?

@davidtwco
Copy link
Member Author

I believe for both constructor and pattern cases we need to still extend this to work across crate boundaries (see src/test/ui/issues/issue-75907_b.rs not having the private_field spans)

should we create a follow up issue?

I think that would make sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[diagnostics] Attempting to initialize a private field in a public tuple struct yields confusing error message
6 participants