rust/src/test/ui/match
Esteban Küber 0081ef2548 Point at enum definition when match patterns are not exhaustive
```
error[E0004]: non-exhaustive patterns: type `X` is non-empty
 --> file.rs:9:11
  |
1 | / enum X {
2 | |     A,
  | |     - variant not covered
3 | |     B,
  | |     - variant not covered
4 | |     C,
  | |     - variant not covered
5 | | }
  | |_- `X` defined here
...
9 |       match x {
  |             ^
  |
  = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms

error[E0004]: non-exhaustive patterns: `B` and `C` not covered
  --> file.rs:11:11
   |
1  | / enum X {
2  | |     A,
3  | |     B,
4  | |     C,
   | |     - not covered
5  | | }
   | |_- `X` defined here
...
11 |       match x {
   |             ^ patterns `C` not covered
```

When a match expression doesn't have patterns covering every variant,
point at the enum's definition span. On a best effort basis, point at the
variant(s) that are missing. This does not handle the case when the missing
pattern is due to a field's enum variants:

```
enum E1 {
    A,
    B,
    C,
}
enum E2 {
    A(E1),
    B,
}
fn foo() {
    match E2::A(E1::A) {
        E2::A(E1::B) => {}
        E2::B => {}
    }
    //~^ ERROR `E2::A(E1::A)` and `E2::A(E1::C)` not handled
}
```

Unify look between match with no arms and match with some missing patterns.

Fix #37518.
2019-03-02 16:45:23 -08:00
..
match-argm-statics-2.rs Remove licenses 2018-12-25 21:08:33 -07:00
match-argm-statics-2.stderr Point at enum definition when match patterns are not exhaustive 2019-03-02 16:45:23 -08:00
match-arm-statics.rs Remove licenses 2018-12-25 21:08:33 -07:00
match-arm-statics.stderr Remove licenses 2018-12-25 21:08:33 -07:00
match-byte-array-patterns-2.rs Remove licenses 2018-12-25 21:08:33 -07:00
match-byte-array-patterns-2.stderr Point at enum definition when match patterns are not exhaustive 2019-03-02 16:45:23 -08:00
match-byte-array-patterns.rs Remove licenses 2018-12-25 21:08:33 -07:00
match-byte-array-patterns.stderr Remove licenses 2018-12-25 21:08:33 -07:00
match-fn-call.rs fix ICE 2018-11-07 22:17:32 +08:00
match-fn-call.stderr fix ICE 2018-11-07 22:17:32 +08:00
match-ill-type2.rs Remove licenses 2018-12-25 21:08:33 -07:00
match-ill-type2.stderr Remove licenses 2018-12-25 21:08:33 -07:00
match-join.rs Remove licenses 2018-12-25 21:08:33 -07:00
match-join.stderr Remove licenses 2018-12-25 21:08:33 -07:00
match-no-arms-unreachable-after.rs Remove licenses 2018-12-25 21:08:33 -07:00
match-no-arms-unreachable-after.stderr Remove licenses 2018-12-25 21:08:33 -07:00
match-non-exhaustive.rs Remove licenses 2018-12-25 21:08:33 -07:00
match-non-exhaustive.stderr Point at enum definition when match patterns are not exhaustive 2019-03-02 16:45:23 -08:00
match-pattern-field-mismatch-2.rs Remove licenses 2018-12-25 21:08:33 -07:00
match-pattern-field-mismatch-2.stderr Remove licenses 2018-12-25 21:08:33 -07:00
match-pattern-field-mismatch.rs Remove licenses 2018-12-25 21:08:33 -07:00
match-pattern-field-mismatch.stderr Remove licenses 2018-12-25 21:08:33 -07:00
match-privately-empty.rs Remove licenses 2018-12-25 21:08:33 -07:00
match-privately-empty.stderr Point at enum definition when match patterns are not exhaustive 2019-03-02 16:45:23 -08:00
match-range-fail-2.rs Remove licenses 2018-12-25 21:08:33 -07:00
match-range-fail-2.stderr Remove licenses 2018-12-25 21:08:33 -07:00
match-range-fail-dominate.rs Remove licenses 2018-12-25 21:08:33 -07:00
match-range-fail-dominate.stderr Remove licenses 2018-12-25 21:08:33 -07:00
match-range-fail.rs Remove licenses 2018-12-25 21:08:33 -07:00
match-range-fail.stderr Don't add label to the match expr when the type is not fully realized 2019-01-12 19:36:28 -08:00
match-ref-ice.rs Remove licenses 2018-12-25 21:08:33 -07:00
match-ref-ice.stderr Remove licenses 2018-12-25 21:08:33 -07:00
match-ref-mut-invariance.rs Remove licenses 2018-12-25 21:08:33 -07:00
match-ref-mut-invariance.stderr Remove licenses 2018-12-25 21:08:33 -07:00
match-ref-mut-let-invariance.rs Remove licenses 2018-12-25 21:08:33 -07:00
match-ref-mut-let-invariance.stderr Remove licenses 2018-12-25 21:08:33 -07:00
match-ref-mut-stability.rs Add address stability test for matches 2019-02-21 19:03:34 +00:00
match-slice-patterns.rs Remove licenses 2018-12-25 21:08:33 -07:00
match-slice-patterns.stderr Point at enum definition when match patterns are not exhaustive 2019-03-02 16:45:23 -08:00
match-struct.rs Remove licenses 2018-12-25 21:08:33 -07:00
match-struct.stderr Reword label as per review comment 2019-01-12 19:36:28 -08:00
match-tag-nullary.rs Remove licenses 2018-12-25 21:08:33 -07:00
match-tag-nullary.stderr Remove licenses 2018-12-25 21:08:33 -07:00
match-tag-unary.rs Remove licenses 2018-12-25 21:08:33 -07:00
match-tag-unary.stderr Reword label as per review comment 2019-01-12 19:36:28 -08:00
match-type-err-first-arm.rs review comments: (marginally) reduce memory consumtion 2019-02-08 06:37:29 -08:00
match-type-err-first-arm.stderr review comments: (marginally) reduce memory consumtion 2019-02-08 06:37:29 -08:00
match-unresolved-one-arm.rs Remove licenses 2018-12-25 21:08:33 -07:00
match-unresolved-one-arm.stderr Remove licenses 2018-12-25 21:08:33 -07:00
match-vec-fixed.rs Remove licenses 2018-12-25 21:08:33 -07:00
match-vec-fixed.stderr Remove licenses 2018-12-25 21:08:33 -07:00
match-vec-mismatch-2.rs Remove licenses 2018-12-25 21:08:33 -07:00
match-vec-mismatch-2.stderr Remove licenses 2018-12-25 21:08:33 -07:00
match-vec-mismatch.rs Remove licenses 2018-12-25 21:08:33 -07:00
match-vec-mismatch.stderr Remove licenses 2018-12-25 21:08:33 -07:00
match-vec-unreachable.rs Remove licenses 2018-12-25 21:08:33 -07:00
match-vec-unreachable.stderr Remove licenses 2018-12-25 21:08:33 -07:00