improve diagnostic suggestion when matching struct variants with tuple#158748
Conversation
|
Thanks for the pull request, and welcome! The Rust Project is excited to review your changes, and you should hear from @hanna-kruppe (or someone else) some time within the next two weeks. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Thanks, this new suggestion is a big improvement.
I have some concerns about adding even more case distinctions and parameters to report_unexpected_variant_res as it's already very unwieldy. But I don't see a way to avoid that without a much larger refactoring, so I've limited my suggestions to the code this PR adds/touches.
There's also one more thing to improve about the suggestion and some more tests I'd like to see.
|
Reminder, once the PR becomes ready for a review, use |
This comment has been minimized.
This comment has been minimized.
…e syntax - update `report_unexpected_variant_res` to suggest using proper struct usage instead of stating that fields are being ignored. - add edge test cases in `tests/ui/parser/recover/recover-from-bad-variant.rs`
0ab4103 to
e8ddb78
Compare
|
@bors r+ rollup |
…uwer Rollup of 5 pull requests Successful merges: - #158544 (Move `std::io::Read` to `alloc::io`) - #158668 (`DeeplyNormalize` and `normalize_with_depth_to` take `Unnormalized<T>` as input) - #157514 ([tiny] Use multipart suggestion for finding ident when literal was expected in attr) - #158748 (improve diagnostic suggestion when matching struct variants with tuple) - #159463 (triagebot: tweak wording for miri changes message) Failed merges: - #158916 (Emit all borrowck errors at the end of borrowck)
Rollup merge of #158748 - Snxhit:fix-struct-variant-suggestion, r=hanna-kruppe improve diagnostic suggestion when matching struct variants with tuple fixes #158641 changes: passed `sub_pats` from `resolve_pat_tuple_struct` into `report_unexpected_variant_res`, match user's variable names to struct fields, fix suggestion name.
fixes #158641
changes:
passed
sub_patsfromresolve_pat_tuple_structintoreport_unexpected_variant_res, match user's variable names to struct fields, fix suggestion name.