diff options
| author | bors <bors@rust-lang.org> | 2020-11-29 18:50:19 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-11-29 18:50:19 +0000 |
| commit | b776d1c3e3db8befabb123ebb1e46c3531eaed46 (patch) | |
| tree | d3c1f37d4299d77cc8f07ba017b07c4625ec492f /compiler/rustc_codegen_cranelift/src/constant.rs | |
| parent | 88b81970ba7a989a728b32039dd075dc206f1360 (diff) | |
| parent | bdd2bdb53beebe86fdfa91e845bd176bf7e55ef3 (diff) | |
| download | rust-b776d1c3e3db8befabb123ebb1e46c3531eaed46.tar.gz rust-b776d1c3e3db8befabb123ebb1e46c3531eaed46.zip | |
Auto merge of #79523 - Nadrieril:fix-usize-ranges, r=varkor
Fix overlap detection of `usize`/`isize` range patterns
`usize` and `isize` are a bit of a special case in the match usefulness algorithm, because the range of values they contain depends on the platform. Specifically, we don't want `0..usize::MAX` to count as an exhaustive match (see also [`precise_pointer_size_matching`](https://github.com/rust-lang/rust/issues/56354)). The way this was initially implemented is by treating those ranges like float ranges, i.e. with limited cleverness. This means we didn't catch the following as unreachable:
```rust
match 0usize {
0..10 => {},
10..20 => {},
5..15 => {}, // oops, should be detected as unreachable
_ => {},
}
```
This PRs fixes this oversight. Now the only difference between `usize` and `u64` range patterns is in what ranges count as exhaustive.
r? `@varkor`
`@rustbot` label +A-exhaustiveness-checking
Diffstat (limited to 'compiler/rustc_codegen_cranelift/src/constant.rs')
0 files changed, 0 insertions, 0 deletions
