Uh oh!
There was an error while loading. Please reload this page.
Improve diagnostics and code for exhaustiveness of empty matches - #67026
Conversation
This is logically equivalent to the previous code.
Actually empty matches are still handled by a different code path
This uses the exact same code path that would be used for
`match x { _ if false => {} }`, since in both cases the resulting matrix
is empty. Since we think the behaviour in that case is ok, then we can
remove the special case and use the default code path.When the feature is on, the special casing is not needed. That way when we stabilize the feature this `if` can just be removed.
rust-highfive
commented
Dec 4, 2019
r? @varkor (rust_highfive has picked a reviewer for you, use r? to override) |
varkor
left a comment
There was a problem hiding this comment.
This change looks very good overall, thanks!
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| LL | enum Void {} | ||
| | ------------ `Void` defined here | ||
| ... | ||
| LL | let _ = match x {}; |
There was a problem hiding this comment.
I think we might want a special note for ! types.
estebank
commented
Dec 12, 2019
Letting @varkor give final stamp, but +1 from me. |
varkor
commented
Dec 13, 2019
@bors r=varkor,Centril,estebank |
bors
commented
Dec 13, 2019
📌 Commit fbd2cd0 has been approved by |
bors
commented
Dec 13, 2019
⌛ Testing commit fbd2cd0 with merge a8d1fbfe9401db1c3d3debf889f0c915b92ad61c... |
rust-highfive
commented
Dec 13, 2019
The job Click to expand the log.I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
bors
commented
Dec 13, 2019
💔 Test failed - checks-azure |
Centril
commented
Dec 13, 2019
@bors retry seems spurious cc @alexcrichton@sfackler could you take a look at what is happening with the spurious issue? |
… r=varkor,Centril,estebank Improve diagnostics and code for exhaustiveness of empty matches There was a completely separate check and diagnostics for the case of an empty match. This led to slightly different error messages and duplicated code. This improves code reuse and generally clarifies what happens for empty matches. This also clarifies the action of the `exhaustive_patterns` feature, and ensures that this feature doesn't change diagnostics in places it doesn't need to.
Rollup of 7 pull requests Successful merges: - #67026 (Improve diagnostics and code for exhaustiveness of empty matches) - #67235 (VecDeque: drop remaining items on destructor panic) - #67254 (dont ICE in case of invalid drop fn) - #67256 (Reduce allocs for validation errors) - #67274 (be explicit that mem::uninitialized is the same as MaybeUninit::uninit().assume_init()) - #67278 (`coerce_inner`: use initial `expected_ty`) - #67280 (docs: std::convert::From: Fix typo) Failed merges: r? @ghost
There was a completely separate check and diagnostics for the case of an empty match. This led to slightly different error messages and duplicated code.
This improves code reuse and generally clarifies what happens for empty matches. This also clarifies the action of the
exhaustive_patternsfeature, and ensures that this feature doesn't change diagnostics in places it doesn't need to.