-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
E0608 #42568
E0608 #42568
Conversation
r? @arielb1 (rust_highfive has picked a reviewer for you, use r? to override) |
src/librustc_typeck/diagnostics.rs
Outdated
@@ -4095,6 +4095,27 @@ assert_eq!(!Question::No, true); | |||
``` | |||
"##, | |||
|
|||
E0608: r##" | |||
An attempt to get an index from a type which doesn't implement the `Index` was |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't really getting an index, at least in the eyes of the user, is it? It's more trying to index into the type. Maybe rephrase this as "An attempt to index into a type which doesn't implement the Index
trait was performed." Maybe it actually makes sense to use std::ops::Index
instead of Index
as well.
src/librustc_typeck/check/mod.rs
Outdated
}, | ||
base_t); | ||
let mut err = struct_span_err!(tcx.sess, expr.span, E0608, | ||
"cannot index a value of type `{}`", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would use "cannot index into a value of type {}
" instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's not the into the problem, that's the index. I think switching the message to this would make the error lose its meaning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is separate than the Into
trait stuff. I've always heard indexing described as being into something, like you "index into an array", you don't "index an array". The latter sounds weird to me. With the current PR you use "index into" in the detailed explanation, but the short error title is still "index a value". This should at least be consistent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, let me rewrite this then.
Updated. |
src/librustc_typeck/check/mod.rs
Outdated
}, | ||
base_t); | ||
let mut err = struct_span_err!(tcx.sess, expr.span, E0608, | ||
"cannot index a value of type `{}`", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is separate than the Into
trait stuff. I've always heard indexing described as being into something, like you "index into an array", you don't "index an array". The latter sounds weird to me. With the current PR you use "index into" in the detailed explanation, but the short error title is still "index a value". This should at least be consistent.
Updated. |
☔ The latest upstream changes (presumably #42585) made this pull request unmergeable. Please resolve the merge conflicts. |
Updated as well. cc @Susurrus |
src/librustc_typeck/diagnostics.rs
Outdated
0u8[2]; // error: cannot index into a value of type `u8` | ||
``` | ||
|
||
To be able to index a value from a type, it needs to implement the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead "To be able to index into a type it needs to implement ..."
And updated. |
Looks good! @bors r+ |
📌 Commit b6e9ed1 has been approved by |
☀️ Test successful - status-appveyor, status-travis |
Part of #42229.
cc @Susurrus