-
Notifications
You must be signed in to change notification settings - Fork 13.7k
match exhaustiveness diagnostics: show a trailing comma on singleton tuple consructors in witness patterns (and clean up a little) #145234
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
Conversation
By construction, `subpatterns` contains all fields in order. Witness patterns are constructed with all fields in order by `WitnessPat::wild_from_ctor` and `WitnessStack::apply_constructor`, and the order is preserved at `write_struct_like`'s call-site in `print_witness_pat`. It's thus no longer necessary to go looking for fields or handle missing fields.
Some changes occurred in exhaustiveness checking cc @Nadrieril |
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 haven't added a test specifically for singleton tuple witnesses since this test included them. I could add a separate test if it would be preferable, though, to make sure it's still tested even if this test changes.
@bors r+ rollup |
match exhaustiveness diagnostics: show a trailing comma on singleton tuple consructors in witness patterns (and clean up a little) Constructor patterns of type `(T,)` are written `(pat,)`, not `(pat)`. However, exhaustiveness/usefulness diagnostics would print them as `(pat)` when e.g. providing a witness of non-exhaustiveness and suggesting adding arms to make matches exhaustive; this would result in an error when applied. rust-analyzer already prints the trailing comma, so it doesn't need changing. This also includes some cleanup in the second commit, with justification in the commit message.
match exhaustiveness diagnostics: show a trailing comma on singleton tuple consructors in witness patterns (and clean up a little) Constructor patterns of type `(T,)` are written `(pat,)`, not `(pat)`. However, exhaustiveness/usefulness diagnostics would print them as `(pat)` when e.g. providing a witness of non-exhaustiveness and suggesting adding arms to make matches exhaustive; this would result in an error when applied. rust-analyzer already prints the trailing comma, so it doesn't need changing. This also includes some cleanup in the second commit, with justification in the commit message.
Rollup of 14 pull requests Successful merges: - #143898 (opt-dist: rebuild rustc when doing static LLVM builds) - #144452 (std/sys/fd: Relax `READ_LIMIT` on Darwin) - #145234 (match exhaustiveness diagnostics: show a trailing comma on singleton tuple consructors in witness patterns (and clean up a little)) - #145515 (Optimize `char::encode_utf8`) - #145540 (interpret/allocation: get_range on ProvenanceMap) - #145670 (port `sanitize` attribute to the new parsing infrastructure) - #145713 (next-solver: fix `feature(const_trait_impl)` bootstrap) - #145729 (Remove two duplicated crates) - #145744 (miri: also detect aliasing of in-place argument and return place) - #145774 (Remove default opts from config) - #145781 (Remove profile section from Clippy) - #145782 (rustdoc: make attributes render consistently) - #145787 (citool: cleanup `mismatched_lifetime_syntaxes` warnings) - #145791 (Fix ICE when validating transmuting ZST to inhabited enum) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of #145234 - dianne:1-tuple-witnesses, r=jackh726 match exhaustiveness diagnostics: show a trailing comma on singleton tuple consructors in witness patterns (and clean up a little) Constructor patterns of type `(T,)` are written `(pat,)`, not `(pat)`. However, exhaustiveness/usefulness diagnostics would print them as `(pat)` when e.g. providing a witness of non-exhaustiveness and suggesting adding arms to make matches exhaustive; this would result in an error when applied. rust-analyzer already prints the trailing comma, so it doesn't need changing. This also includes some cleanup in the second commit, with justification in the commit message.
still in queue @bors r- |
Rollup of 14 pull requests Successful merges: - rust-lang/rust#143898 (opt-dist: rebuild rustc when doing static LLVM builds) - rust-lang/rust#144452 (std/sys/fd: Relax `READ_LIMIT` on Darwin) - rust-lang/rust#145234 (match exhaustiveness diagnostics: show a trailing comma on singleton tuple consructors in witness patterns (and clean up a little)) - rust-lang/rust#145515 (Optimize `char::encode_utf8`) - rust-lang/rust#145540 (interpret/allocation: get_range on ProvenanceMap) - rust-lang/rust#145670 (port `sanitize` attribute to the new parsing infrastructure) - rust-lang/rust#145713 (next-solver: fix `feature(const_trait_impl)` bootstrap) - rust-lang/rust#145729 (Remove two duplicated crates) - rust-lang/rust#145744 (miri: also detect aliasing of in-place argument and return place) - rust-lang/rust#145774 (Remove default opts from config) - rust-lang/rust#145781 (Remove profile section from Clippy) - rust-lang/rust#145782 (rustdoc: make attributes render consistently) - rust-lang/rust#145787 (citool: cleanup `mismatched_lifetime_syntaxes` warnings) - rust-lang/rust#145791 (Fix ICE when validating transmuting ZST to inhabited enum) r? `@ghost` `@rustbot` modify labels: rollup
Constructor patterns of type
(T,)
are written(pat,)
, not(pat)
. However, exhaustiveness/usefulness diagnostics would print them as(pat)
when e.g. providing a witness of non-exhaustiveness and suggesting adding arms to make matches exhaustive; this would result in an error when applied.rust-analyzer already prints the trailing comma, so it doesn't need changing.
This also includes some cleanup in the second commit, with justification in the commit message.