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

E0613 needs to be merged into E0609 now #42945

Closed
est31 opened this issue Jun 28, 2017 · 9 comments
Closed

E0613 needs to be merged into E0609 now #42945

est31 opened this issue Jun 28, 2017 · 9 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.

Comments

@est31
Copy link
Member

est31 commented Jun 28, 2017

With RFC 1506 merged and stabilized, handling E0613 separate from E0609 is not the correct behaviour any more.

For context, you get E0613 when doing something like let _ = "hi".0;:

error[E0613]: attempted to access tuple index `0` on type `&'static str`, but the type was not a tuple or tuple struct

And you get E0609 when doing something like let _ = "hi".foo;:

error[E0609]: no field `foo` on type `&'static str`

RFC 1506 "clarified ADT kinds" (Rendered, tracking issue) allowed all structs to contain fields with integral names like 0 or 1, etc. This makes the error message for E0613 outdated, as the type may be a non tuple struct, and calling 0 a "tuple index" sounds wrong as well.

So I propose E0613 to be merged into E0609, as E0609 is now better suiting, and also because its "in the spirit" of the RFC.

The proposed new output for let _ = "hi".0; is:

error[E0609]: no field `0` on type `&'static str`
@Mark-Simulacrum Mark-Simulacrum added the A-diagnostics Area: Messages for errors, warnings, and lints label Jun 28, 2017
@nikomatsakis
Copy link
Contributor

Makes sense to me!

@nikomatsakis nikomatsakis added the E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. label Jun 28, 2017
@nikomatsakis
Copy link
Contributor

Here are some brief mentoring instructions:

  • E0613 is issued here, in librustc_typeck.
  • E0609 is issued here.
  • We basically need to introduce a common helper function and call it from both places. A helper is needed because you can't have more than one place in the source code that uses a single error code (in this case, E0609).

@nikomatsakis nikomatsakis added the E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. label Jun 28, 2017
@strangeglyph
Copy link
Contributor

Hi! I'd like to take this issue, if no one minds?

@Mark-Simulacrum
Copy link
Member

Go right ahead! Let us know if you'd like additional instructions and we'll try to connect you with @nikomatsakis or someone else from the compiler team.

@GuillaumeGomez
Copy link
Member

Or I can as well since I'm the one who added these two error codes.

@strangeglyph
Copy link
Contributor

While I'm at it, E0612 looks like it could be folded into E0609 too. Should I go ahead and do that?

@est31
Copy link
Member Author

est31 commented Jun 30, 2017

While I'm at it, E0612 looks like it could be folded into E0609 too.

I can be, not sure whether it should. It seems we can actually recognize when we have a tuple struct, so we won't generate the error if it is wrongly placed. However it might be against the spirit of the RFC. @petrochenkov as author of the RFC, what do you think, should E0612 be merged into E0609?

@petrochenkov
Copy link
Contributor

@est31
I'd say yes, because I'm generally for removing code and special cases in case of doubt, but people managing diagnostics often hold the opposite position.

@strangeglyph
Copy link
Contributor

strangeglyph commented Jun 30, 2017

Should unused diagnostic codes just be removed, or commented out with a reference that the diagnostic has been folded into another?

EDIT: For now, left a comment that they have been merged into E0609

strangeglyph pushed a commit to strangeglyph/rust that referenced this issue Jul 7, 2017
bors added a commit that referenced this issue Jul 8, 2017
Fold E0612, E0613 into E0609

As discussed in #42945, with PR 1506 tuple indices are no longer considered a separate case from normal field. This PR folds E06012 ("tuple index out of bounds") and E0613 ("type is not a tuple") into E0609 ("type does not have field with that name")

Resolves #42945
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 E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.
Projects
None yet
Development

No branches or pull requests

6 participants