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

Elide use of "non-existing" fields for enum variant with parse errors #57361

Closed
estebank opened this issue Jan 5, 2019 · 0 comments
Closed
Labels
A-diagnostics Area: Messages for errors, warnings, and lints

Comments

@estebank
Copy link
Contributor

estebank commented Jan 5, 2019

On parse error of the fields of an enum variant, we also emit an error about "non-existing" fields when using the variant. We have no way of actually knowing wether those fields exist, we should elide the second error:

error: expected `:`, found `,`
   --> src/librustc/traits/mod.rs:228:37
    |
228 |     MatchExpressionArmPattern { span, ty: Ty<'tcx> },
    |                                     ^ expected `:`

error[E0026]: variant `traits::ObligationCauseCode::MatchExpressionArmPattern` does not have fields named `span`, `ty`
   --> src/librustc/infer/error_reporting/mod.rs:464:62
    |
464 |             ObligationCauseCode::MatchExpressionArmPattern { span, ty } => {
    |                                                              ^^^^  ^^ variant `traits::ObligationCauseCode::MatchExpressionArmPattern` does not have these fields
@estebank estebank added the A-diagnostics Area: Messages for errors, warnings, and lints label Jan 5, 2019
Centril added a commit to Centril/rust that referenced this issue Mar 19, 2019
…etrochenkov

Do not complain about non-existing fields after parse recovery

When failing to parse struct-like enum variants, the ADT gets recorded
as having no fields. Record that we have actually recovered during
parsing of this variant to avoid complaing about non-existing fields
when actually using it.

Fix rust-lang#57361.
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this issue Mar 22, 2019
…etrochenkov

Do not complain about non-existing fields after parse recovery

When failing to parse struct-like enum variants, the ADT gets recorded
as having no fields. Record that we have actually recovered during
parsing of this variant to avoid complaing about non-existing fields
when actually using it.

Fix rust-lang#57361.
Centril added a commit to Centril/rust that referenced this issue Mar 22, 2019
…etrochenkov

Do not complain about non-existing fields after parse recovery

When failing to parse struct-like enum variants, the ADT gets recorded
as having no fields. Record that we have actually recovered during
parsing of this variant to avoid complaing about non-existing fields
when actually using it.

Fix rust-lang#57361.
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
Projects
None yet
Development

No branches or pull requests

1 participant