diff options
| author | bors <bors@rust-lang.org> | 2019-07-13 20:45:40 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-07-13 20:45:40 +0000 |
| commit | d32a7250dbf797c9a89f56de0842d7ad43bfe85f (patch) | |
| tree | 5a5cffe20a744ad2cb71ea31b9397f5e744c7bf9 /src/libsyntax/parse/parser | |
| parent | 69656fa4cbafc378fd63f9186d93b0df3cdd9320 (diff) | |
| parent | c063057beb96cd4901ab300eed2267c9b73ed589 (diff) | |
| download | rust-d32a7250dbf797c9a89f56de0842d7ad43bfe85f.tar.gz rust-d32a7250dbf797c9a89f56de0842d7ad43bfe85f.zip | |
Auto merge of #62584 - eddyb:circular-math-is-hard, r=pnkfelix
rustc_codegen_ssa: fix range check in codegen_get_discr.
Fixes #61696, see https://github.com/rust-lang/rust/issues/61696#issuecomment-505473018 for more details.
In short, I had wanted to use `x - a <= b - a` to check whether `x` is in `a..=b` (as it's 1 comparison instead of 2 *and* `b - a` is guaranteed to fit in the same data type, while `b` itself might not), but I ended up with `x - a + c <= b - a + c` instead, because `x - a + c` was the final value needed.
That latter comparison is equivalent to checking that `x` is in `(a - c)..=b`, i.e. it also includes `(a - c)..a`, not just `a..=b`, so if `c` is not `0`, it will cause false positives.
This presented itself as the non-niche ("dataful") variant sometimes being treated like a niche variant, in the presence of uninhabited variants (which made `c`, aka the index of the first niche variant, arbitrarily large).
r? @nagisa, @rkruppe or @oli-obk
Diffstat (limited to 'src/libsyntax/parse/parser')
0 files changed, 0 insertions, 0 deletions
