Uh oh!
There was an error while loading. Please reload this page.
check_match: refactor + improve non-exhaustive diagnostics for default binding modes - #64271
Conversation
There was a problem hiding this comment.
E0005 seem to not be pointing at the uncovered variants. This should also have at least a note about if let. I'll take a look at the code tomorrow.
There was a problem hiding this comment.
Yes, I wondered if that was by-design or not. If not, this would actually simplify the code and I think I know how to fix it. There's a good argument for why it should be by-design without full or-patterns but we will have those on nightly soon so that argument is probably invalid now.
There was a problem hiding this comment.
I think it should be ok to unify both, maybe with some extra help about how to write or-patterns (only if all variants have the currently covered field types), otherwise talk about if let. But this could be done as follow up work.
There was a problem hiding this comment.
I've unified them a bit but I'd like to punt on the extra help or referring to if let. A follow up issue might be good to file however.
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.
There was a problem hiding this comment.
I think it should be ok to unify both, maybe with some extra help about how to write or-patterns (only if all variants have the currently covered field types), otherwise talk about if let. But this could be done as follow up work.
335b855 to
eeca6eeCompareestebank
commented
Sep 11, 2019
@bors r+ |
bors
commented
Sep 11, 2019
📌 Commit 20a2605 has been approved by |
bors
commented
Sep 11, 2019
check_match: refactor + improve non-exhaustive diagnostics for default binding modes
Refactor `check_match` a bit with more code-reuse and improve the diagnostics for a non-exhaustive pattern match by peeling off any references from the scrutinee type so that the "defined here" label is added in more cases. For example:
```rust
error[E0004]: non-exhaustive patterns: `&mut &B` not covered
--> foo.rs:4:11
|
1 | enum E { A, B }
| ---------------
| | |
| | not covered
| `E` defined here
...
4 | match x {
| ^ pattern `&mut &B` not covered
|
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
```
Moreover, wrt. "defined here", we give irrefutable pattern matching (i.e. in `let`, `for`, and `fn` parameters) a more consistent treatment in line with `match`.
r? @estebankbors
commented
Sep 11, 2019
☀️ Test successful - checks-azure |
rust-highfive
commented
Sep 11, 2019
Tested on commit rust-lang/rust@f0b58fc. Direct link to PR: <rust-lang/rust#64271> 🎉 rls on linux: test-fail → test-pass (cc @Xanewok, @rust-lang/infra).
Refactor
check_matcha bit with more code-reuse and improve the diagnostics for a non-exhaustive pattern match by peeling off any references from the scrutinee type so that the "defined here" label is added in more cases. For example:Moreover, wrt. "defined here", we give irrefutable pattern matching (i.e. in
let,for, andfnparameters) a more consistent treatment in line withmatch.r? @estebank