Precise range exhaustiveness check for match on integer patterns #1550
|
The following will then error due to match x {
0x00...0xFF => {},
_ => {},
} |
|
@oli-obk We could just warn in that case (and make it a lint so people can |
|
Are there any new discussion/plans on this? Adding a warning which can be turned off for legacy code seems like the most elegant solution to me. If that aligns with the consensus, I'd try and take a shot at this during my spring vacation and send a pull request |
|
It's another issue, and likely unsolvable, but this also fails the range exhaustiveness check:
|
|
@igor-krawczuk Unreachable patterns have already been downgraded from errors to warnings in rust-lang/rust#38069 I believe, so that sounds reasonable to me. |
In theory the compiler should be able to detect that the following range is exhaustive and not error about non-exaustive match:
Proposed (as a side-portion) in #880
Discussed in rust-lang/rust#12483 and rust-lang/rust#32381