rust/src/librustc_mir
bors a79cffb8b8 Auto merge of #50912 - varkor:exhaustive-integer-matching, r=arielb1
Exhaustive integer matching

This adds a new feature flag `exhaustive_integer_patterns` that enables exhaustive matching of integer types by their values. For example, the following is now accepted:
```rust
#![feature(exhaustive_integer_patterns)]
#![feature(exclusive_range_pattern)]

fn matcher(x: u8) {
  match x { // ok
    0 .. 32 => { /* foo */ }
    32 => { /* bar */ }
    33 ..= 255 => { /* baz */ }
  }
}
```
This matching is permitted on all integer (signed/unsigned and char) types. Sensible error messages are also provided. For example:
```rust
fn matcher(x: u8) {
  match x { //~ ERROR
    0 .. 32 => { /* foo */ }
  }
}
```
results in:
```
error[E0004]: non-exhaustive patterns: `32u8...255u8` not covered
 --> matches.rs:3:9
  |
6 |   match x {
  |         ^ pattern `32u8...255u8` not covered
```

This implements https://github.com/rust-lang/rfcs/issues/1550 for https://github.com/rust-lang/rust/issues/50907. While there hasn't been a full RFC for this feature, it was suggested that this might be a feature that obviously complements the existing exhaustiveness checks (e.g. for `bool`) and so a feature gate would be sufficient for now.
2018-08-22 00:57:00 +00:00
..
borrow_check Rollup merge of #53551 - nnethercote:access_place_error_reported, r=varkor 2018-08-21 22:09:35 +08:00
build mv codemap() source_map() 2018-08-19 23:01:01 +02:00
dataflow Fix typos found by codespell. 2018-08-19 17:41:28 +02:00
hair Add some extra edge case tests 2018-08-21 23:55:57 +01:00
interpret Rollup merge of #53496 - matthiaskrgr:codespell_08_2018, r=varkor 2018-08-21 17:51:49 +08:00
monomorphize mv (mod) codemap source_map 2018-08-19 23:01:00 +02:00
transform Rollup merge of #53496 - matthiaskrgr:codespell_08_2018, r=varkor 2018-08-21 17:51:49 +08:00
util Rollup merge of #53496 - matthiaskrgr:codespell_08_2018, r=varkor 2018-08-21 17:51:49 +08:00
Cargo.toml Allow choosing Polonius algorithm via environment variable POLONIUS_ALGORITHM. 2018-06-02 14:17:12 +02:00
diagnostics.rs Auto merge of #53131 - davidtwco:issue-52663-thread-local-static, r=nikomatsakis 2018-08-10 06:54:11 +00:00
lib.rs Auto merge of #50912 - varkor:exhaustive-integer-matching, r=arielb1 2018-08-22 00:57:00 +00:00
shim.rs Promoteds are statics and statics have a place, not just a value 2018-07-23 09:51:30 +02:00