-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
libsyntax: Forbid type parameters in tuple indices #19211
Conversation
Some questions:
|
@aochagavia Thanks for the PR! I think it would be nice if the error message was more targeted. For example see this PR: https://github.com/rust-lang/rust/pull/18879/files, which made an equivalent change to field expressions. |
@aochagavia To answer your first question, yes, you're right, feel free to remove them. :) |
@jakub- I have some questions regarding the error message. To get a more targeted one, there are two approaches I can think of:
|
I have implemented the second approach... But it is not a perfect solution and it can be confusing as well:
Do you have any ideas on how to produce a better error message? |
By the way... Who would ever try to pass type parameters to tuple indexing? Do we really want to have a special case for this? It could make the error message even more confusing in most cases. The only case in which this could make sense is when a generic function is saved in a tuple. However, rust requires the type parameters to be specified when the function is stored in the tuple, not when it is called. For example:
|
@aochagavia Yeah, I think you're right! Feel free to push your current changes and I'm happy. |
This breaks code like ``` let t = (42i, 42i); ... t.0::<int> ...; ``` Change this code to not contain an unused type parameter. For example: ``` let t = (42i, 42i); ... t.0 ...; ``` Closes #19096 [breaking-change]
Done! |
I have added the error message ;) |
This breaks code like
Change this code to not contain an unused type parameter. For example:
Closes #19096
[breaking-change]
r? @aturon