mozilla/rust — pull request #14731 by jakub- (2014-06-07 19:16:06+00:00)
Title: Accurate witnesses for non-exhaustive pattern matching [WIP]

This PR is changing the error messages for non-exhaustive pattern matching to include a more accurate witness, i.e. a pattern that is not covered by any of the ones provided by the user. Example:

```rust
fn main() {
match (true, (Some("foo"), [true, true]), Some(42u)) {
(false, _, _) => (),
(true, (None, [true, _]), None) => (),
(true, (None, [false, _]), Some(1u)) => ()
}
}
```

```sh
/tmp/witness.rs:2:2: 6:3 error: non-exhaustive patterns: (true, (core::option::Some(_), _), _) not covered
/tmp/witness.rs:2	match (true, (Some("foo"), [true, true]), Some(42u)) {
/tmp/witness.rs:3	(false, _, _) => (),
/tmp/witness.rs:4	(true, (None, [true, _]), None) => (),
/tmp/witness.rs:5	(true, (None, [false, _]), Some(1u)) => ()
/tmp/witness.rs:6	}
```

As part of that, I refactored some of the relevant code and carried over the changes to fixed vectors from the previous PR.

I'm putting it out there for now but the tests will be red.