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

discriminant value on non-field-less enum should highlight variant with field #61039

Closed
pnkfelix opened this issue May 22, 2019 · 0 comments · Fixed by #61056
Closed

discriminant value on non-field-less enum should highlight variant with field #61039

pnkfelix opened this issue May 22, 2019 · 0 comments · Fixed by #61056
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@pnkfelix
Copy link
Member

pnkfelix commented May 22, 2019

While reviewing PR #60732, I noticed that both the current stderr for test cases like tag-variant-disr-non-nullary.stderr highlights a bunch of variants that all have no fields on them.

This is confusing, because the diagnostic is complaining that you can only use this feature on enums without fields, but the diagnostic is showing you only cases without fields. Ideally it would include both the explicit discriminator value and some variant of the enum that has fields on it. For example, in the case linked above, it would also highlight the variant on this line:

(Arguably if rust-lang/rfcs#2363 (#60553) gets implemented and stabilized quickly, the diagnostic being criticized here will go away, and my suggestion will be pointless. But I suspect this would be an easy change to make that would make life easier for some developers.)

@jonas-schievink jonas-schievink added A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 22, 2019
Centril added a commit to Centril/rust that referenced this issue May 23, 2019
…=estebank

tweak discriminant on non-nullary enum diagnostic

Adds notes pointing at the non-nullary variants, and uses "custom
discriminant" language to be consistent with the Reference.

Fixes rust-lang#61039.

r? @estebank
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants