rust/src/test/ui/structs
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
..
auxiliary Remove licenses 2018-12-25 21:08:33 -07:00
struct-base-wrong-type-2.rs Improve type mismatch error messages 2018-12-31 20:43:08 -05:00
struct-base-wrong-type-2.stderr Improve type mismatch error messages 2018-12-31 20:43:08 -05:00
struct-base-wrong-type.rs Improve type mismatch error messages 2018-12-31 20:43:08 -05:00
struct-base-wrong-type.stderr Improve type mismatch error messages 2018-12-31 20:43:08 -05:00
struct-duplicate-comma.rs tests: Do not use -Z parse-only, continue compilation to test recovery 2019-01-06 22:20:46 +03:00
struct-duplicate-comma.stderr tests: Do not use -Z parse-only, continue compilation to test recovery 2019-01-06 22:20:46 +03:00
struct-field-cfg.rs Remove licenses 2018-12-25 21:08:33 -07:00
struct-field-cfg.stderr Remove licenses 2018-12-25 21:08:33 -07:00
struct-field-init-syntax.rs tests: Do not use -Z parse-only, continue compilation to test recovery 2019-01-06 22:20:46 +03:00
struct-field-init-syntax.stderr tests: Do not use -Z parse-only, continue compilation to test recovery 2019-01-06 22:20:46 +03:00
struct-field-privacy.rs Remove licenses 2018-12-25 21:08:33 -07:00
struct-field-privacy.stderr Remove licenses 2018-12-25 21:08:33 -07:00
struct-fields-decl-dupe.rs Remove licenses 2018-12-25 21:08:33 -07:00
struct-fields-decl-dupe.stderr Remove licenses 2018-12-25 21:08:33 -07:00
struct-fields-dupe.rs Remove licenses 2018-12-25 21:08:33 -07:00
struct-fields-dupe.stderr Remove licenses 2018-12-25 21:08:33 -07:00
struct-fields-hints-no-dupe.rs Remove licenses 2018-12-25 21:08:33 -07:00
struct-fields-hints-no-dupe.stderr use structured suggestions for nonexistent fields 2018-12-31 12:52:30 -05:00
struct-fields-hints.rs Remove licenses 2018-12-25 21:08:33 -07:00
struct-fields-hints.stderr use structured suggestions for nonexistent fields 2018-12-31 12:52:30 -05:00
struct-fields-missing.rs Remove licenses 2018-12-25 21:08:33 -07:00
struct-fields-missing.stderr Remove licenses 2018-12-25 21:08:33 -07:00
struct-fields-shorthand-unresolved.rs Remove licenses 2018-12-25 21:08:33 -07:00
struct-fields-shorthand-unresolved.stderr clarify resolve typo suggestion 2019-01-09 14:11:00 -05:00
struct-fields-shorthand.rs Remove licenses 2018-12-25 21:08:33 -07:00
struct-fields-shorthand.stderr Remove licenses 2018-12-25 21:08:33 -07:00
struct-fields-too-many.rs Remove licenses 2018-12-25 21:08:33 -07:00
struct-fields-too-many.stderr Remove licenses 2018-12-25 21:08:33 -07:00
struct-fields-typo.rs use structured suggestions for nonexistent fields 2018-12-31 12:52:30 -05:00
struct-fields-typo.stderr use structured suggestions for nonexistent fields 2018-12-31 12:52:30 -05:00
struct-like-enum-nonexhaustive.rs Remove licenses 2018-12-25 21:08:33 -07:00
struct-like-enum-nonexhaustive.stderr Point at enum definition when match patterns are not exhaustive 2019-03-02 16:45:23 -08:00
struct-missing-comma.rs tests: Do not use -Z parse-only, continue compilation to test recovery 2019-01-06 22:20:46 +03:00
struct-missing-comma.stderr tests: Do not use -Z parse-only, continue compilation to test recovery 2019-01-06 22:20:46 +03:00
struct-pat-derived-error.rs Remove licenses 2018-12-25 21:08:33 -07:00
struct-pat-derived-error.stderr Remove licenses 2018-12-25 21:08:33 -07:00
struct-path-alias-bounds.rs Remove licenses 2018-12-25 21:08:33 -07:00
struct-path-alias-bounds.stderr Remove licenses 2018-12-25 21:08:33 -07:00
struct-path-associated-type.rs Added regression test for using generic parameters on modules. 2018-12-26 21:54:18 +00:00
struct-path-associated-type.stderr Added regression test for using generic parameters on modules. 2018-12-26 21:54:18 +00:00
struct-path-self-type-mismatch.rs Remove licenses 2018-12-25 21:08:33 -07:00
struct-path-self-type-mismatch.stderr Remove licenses 2018-12-25 21:08:33 -07:00
struct-path-self.rs Added regression test for using generic parameters on modules. 2018-12-26 21:54:18 +00:00
struct-path-self.stderr Added regression test for using generic parameters on modules. 2018-12-26 21:54:18 +00:00
struct-pattern-match-useless.rs Remove licenses 2018-12-25 21:08:33 -07:00
struct-pattern-match-useless.stderr Remove licenses 2018-12-25 21:08:33 -07:00
struct-variant-privacy-xc.rs Remove licenses 2018-12-25 21:08:33 -07:00
struct-variant-privacy-xc.stderr Remove licenses 2018-12-25 21:08:33 -07:00
struct-variant-privacy.rs Remove licenses 2018-12-25 21:08:33 -07:00
struct-variant-privacy.stderr Remove licenses 2018-12-25 21:08:33 -07:00
structure-constructor-type-mismatch.rs Improve type mismatch error messages 2018-12-31 20:43:08 -05:00
structure-constructor-type-mismatch.stderr Reword label as per review comment 2019-01-12 19:36:28 -08:00