-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Update the wording for E0063. This will truncate the fields to 3. #35691
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @nrc (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
let truncated_fields = match remaining_fields.len() { | ||
len if len <= 3 => (remaining_fields.keys().take(len), "".to_string()), | ||
len => { | ||
let x = len - 3; |
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.
Not super happy about this arm. Suggestions welcome!
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'd be tempted to use an if-expression instead.
let len = remaining_fields.len();
let truncated_fields = if len <= 3 {
(remaining_fields.keys().take(len), "".to_string())
} else {
(remaining_fields.keys().take(3), format!(", and {} other field{}",
(len-3), if x == (len-3) {""} else {"s"}))
};
There are probably are slicker fixes, but maybe that's an idea
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 looks much cleaner :) Re compiling and merging master.
Added the r? late :( Can't remove the assignee. Sorry about that @nrc |
It looks pretty good. I commented on the spot you were wondering about. Feel free to ping me again when you want me to take another look. |
7a5e9a7
to
65b8be7
Compare
@jonathandturner updated. |
Great! @bors r+ rollup |
📌 Commit 65b8be7 has been approved by |
Well that is certainly interesting. @jonathandturner can i use a regex in these error strings? |
@jaredwy - Instead of regex, since the label testing is substring matching, you could look for labels like "and 1 other field" |
…dturner Update the wording for E0063. This will truncate the fields to 3. Instead of listing every field it will now show missing `a`, `z`, `b`, and 1 other field This is for rust-lang#35218 as part of rust-lang#35233 r? @jonathandturner
@jaredwy: (I'm assuming you're referring to the travis failure) The order of keys in a However from what I can tell However, even sorting by the original keys would probably not work, since the keys are names, which are just newtyped To get a deterministic sort order for the fields, the easiest solution would probably be to collect the string representation of the keys into a Vec and sort that. (Something like Alternately do as @jonathandturner suggested and just not mention the actual field names in the error messages. |
65b8be7
to
7cb1557
Compare
@jonathandturner I went the path of just using substring matching in the tests. The idea of using a sort meant that if anything on the type upstream to introduce stable keys changed we would lose that. The first two tests check that the keys are being outputted so i am confident we will catch a problem. |
📌 Commit 7cb1557 has been approved by |
…dturner Update the wording for E0063. This will truncate the fields to 3. Instead of listing every field it will now show missing `a`, `z`, `b`, and 1 other field This is for rust-lang#35218 as part of rust-lang#35233 r? @jonathandturner
Looks like this has to remove all the fields. I am not in front of my computer for the weekend. I can fix up the test on monday. Might have to pull it out from the rollup. Sorry about that! |
@jonathandturner as per the other issue :) Been a little... preoccupied of late. This issue isn't forgotten just probably don't want code written under the influence of pain meds :D Will have the time today or over the weekend to get to this. |
☔ The latest upstream changes (presumably #36016) made this pull request unmergeable. Please resolve the merge conflicts. |
7cb1557
to
e496fc7
Compare
I am alive and back from bed rest 👯 I went with the sort method. I wasn't happy having such a large chunk of code untested :) Alphabetical order kind of grew on me in the error output as well. |
Instead of listing every field it will now show missing `a`, `z`, `b`, and 1 other field
e496fc7
to
0e32d11
Compare
@jaredwy - welcome back! If you think the PR is good to go, I can reapprove. |
If you are happy with the alpha sorting of fields then I think it's good to go. |
📌 Commit 0e32d11 has been approved by |
…dturner Update the wording for E0063. This will truncate the fields to 3. Instead of listing every field it will now show missing `a`, `z`, `b`, and 1 other field This is for rust-lang#35218 as part of rust-lang#35233 r? @jonathandturner
…dturner Update the wording for E0063. This will truncate the fields to 3. Instead of listing every field it will now show missing `a`, `z`, `b`, and 1 other field This is for rust-lang#35218 as part of rust-lang#35233 r? @jonathandturner
Instead of listing every field it will now show missing
a
,z
,b
, and 1 other fieldThis is for #35218 as part of #35233
r? @jonathandturner