]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_error_codes/src/error_codes/E0579.md
Rollup merge of #76088 - hbina:add_example, r=LukasKalbertodt
[rust.git] / compiler / rustc_error_codes / src / error_codes / E0579.md
1 A lower range wasn't less than the upper range.
2
3 Erroneous code example:
4
5 ```compile_fail,E0579
6 #![feature(exclusive_range_pattern)]
7
8 fn main() {
9     match 5u32 {
10         // This range is ok, albeit pointless.
11         1 .. 2 => {}
12         // This range is empty, and the compiler can tell.
13         5 .. 5 => {} // error!
14     }
15 }
16 ```
17
18 When matching against an exclusive range, the compiler verifies that the range
19 is non-empty. Exclusive range patterns include the start point but not the end
20 point, so this is equivalent to requiring the start of the range to be less
21 than the end of the range.