Conversation
|
r? @pnkfelix (rust_highfive has picked a reviewer for you, use r? to override) |
src/librustc_typeck/diagnostics.rs
Outdated
There was a problem hiding this comment.
Maybe "Attempted to access a non-existent field in a struct" reads better?
There was a problem hiding this comment.
What about "An attempt to access a non-existent field in a struct"?
src/librustc_typeck/diagnostics.rs
Outdated
There was a problem hiding this comment.
"misspell"
Remove the "if" as well.
|
Updated. |
|
I really don't like the phrasing "An attempt ... was performed". It reads awkwardly. I think using "Attempted to ..." reads better overall. Additionally it appears that this error covers two situations: One where they improperly use field syntax on a type (currently non-structs-or-tuples) and another error when the struct does not contain the given field. And my understanding is that error is separate from when that field is private as well. I think these errors would be more clear if E0609 was split into two errors: one for when it's invalid for the type to have field access performed on it and another for when a struct or tuple doesn't have the field being referenced. |
|
I splitted the error into two. |
src/librustc_typeck/diagnostics.rs
Outdated
There was a problem hiding this comment.
"check that you didn't misspell the field's name or that the field actually exists"
src/librustc_typeck/diagnostics.rs
Outdated
src/librustc_typeck/diagnostics.rs
Outdated
There was a problem hiding this comment.
I don't know how the user would accidentally access a field of a variable when coding. I would think the most likely reason would be they a) didn't know the datatype of the variable they used or b) accidentally used the wrong variable. I don't know if suggesting the user looks at structs will be helpful in them resolving this error. I think this extra description may be unnecessary.
In case you want to keep it, I'd reword the second sentence as it reads as being very informal. Maybe instead "To access data via named fields, struct types are used."?
src/librustc_typeck/diagnostics.rs
Outdated
There was a problem hiding this comment.
"call" is usually reserved for use with functions/methods. I'd suggest "access" instead.
src/librustc_typeck/diagnostics.rs
Outdated
There was a problem hiding this comment.
"go read" sounds like a derogatory command. I'd suggest "see" instead (and drop the comma).
src/librustc_typeck/check/mod.rs
Outdated
There was a problem hiding this comment.
I'd suggest replacing the comma with "and"
|
Updated. |
src/librustc_typeck/diagnostics.rs
Outdated
There was a problem hiding this comment.
Remove the comma as it's unnecessary.
src/librustc_typeck/diagnostics.rs
Outdated
There was a problem hiding this comment.
Remove "was performed", the sentence doesn't make sense given that it now starts with "Attempted"
|
Updated. |
|
LGTM 👍 |
|
@bors: r=Susurrus |
|
📌 Commit 2f37894 has been approved by |
|
☀️ Test successful - status-appveyor, status-travis |
Part of #42229.
cc @Susurrus