Uh oh!
There was an error while loading. Please reload this page.
fix Miri discriminant handling - #63448
Conversation
eddyb
commented
Aug 10, 2019
I'd prefer to block this on #63450. |
90d692b to
bc8cde5CompareRalfJung
commented
Aug 17, 2019
I factored out the parts that are not blocked into a separate PR: #63658. |
bc8cde5 to
43b52abCompareJohnCSimon
commented
Aug 24, 2019
RalfJung
commented
Aug 24, 2019
RalfJung
commented
Aug 30, 2019
JohnCSimon
commented
Sep 7, 2019
43b52ab to
8c0f601CompareRalfJung
commented
Sep 16, 2019
@eddyb noticed that doing all arithmetic using machine operations at discriminant type is also not correct, so now this does the variant idx computations on the host (checked so they do not overflow). |
RalfJung
commented
Sep 16, 2019
I should also mention, tests will be added to Miri. My naive attempt at turning that into CTFE tests failed. @oli-obk is it possible to test this with current CTFE so that we have an in-tree test? |
oli-obk
commented
Sep 16, 2019
Make it a |
RalfJung
commented
Sep 16, 2019
I think that actually worked :D |
5530722 to
b21622cCompare| // Then computing the absolute variant idx should not overflow any more. | ||
| let variant_index = variants_start | ||
| .checked_add(variant_index_relative) | ||
| .expect("oveflow computing absolute variant idx"); |
There was a problem hiding this comment.
I wonder if this can overflow when it's the dataful variant. Still, ICE > silently doing the wrong thing.
| .checked_add(variant_index_relative) | ||
| .expect("oveflow computing absolute variant idx"); | ||
| // Check if this is in the range that indicates an actual discriminant. | ||
| if variants_start <= variant_index && variant_index <= variants_end { |
There was a problem hiding this comment.
Oh wait you can just compare variant_index_relative against variants_end - variants_start, and then you can move the addition inside the "niche" side of the if.
There was a problem hiding this comment.
So the if should change to variant_index_relative <= variants_end - variants_start you say?
What is the "niche side of the if"?
| let variants_start = niche_variants.start().as_u32(); | ||
| let variant_index_relative = variant_index.as_u32() | ||
| .checked_sub(variants_start) | ||
| .expect("overflow computing relative variant idx"); |
There was a problem hiding this comment.
I think this is fine because this is a "niche" variant.
There was a problem hiding this comment.
Sure but is there any reason not to ICE if this overflows anyway?
| mir::BinOp::Add, | ||
| variant_index_relative_val, | ||
| niche_start_val, | ||
| )?; |
There was a problem hiding this comment.
I wonder how much this matters - you just need to truncate the result, I think? Either way, the symmetry with reading is probably fine.
eddyb
commented
Sep 18, 2019
r=me with #63448 (comment) fixed. |
Uh oh!
There was an error while loading. Please reload this page.
RalfJung
commented
Sep 19, 2019
bors
commented
Sep 19, 2019
📌 Commit 1de533a has been approved by |
bors
commented
Sep 19, 2019
⌛ Testing commit 1de533a with merge b480f068c8efc171da04e5e132310df0778ff4b1... |
bors
commented
Sep 19, 2019
💥 Test timed out |
mati865
commented
Sep 19, 2019
cc @pietroalbini ^^ many jobs were stared very late and some still are waiting for the agent |
RalfJung
commented
Sep 19, 2019
@bors retry |
fix Miri discriminant handling This can be reviewed commit-by-commit fairly well. The Miri side is at rust-lang/miri#903. Fixesrust-lang#62138 r? @eddyb@oli-obk
Rollup of 6 pull requests Successful merges: - #63448 (fix Miri discriminant handling) - #64592 (Point at original span when emitting unreachable lint) - #64601 (Fix backticks in documentation) - #64606 (Remove unnecessary `mut` in doc example) - #64611 (rustbuild: Don't package libstd twice) - #64613 (rustbuild: Copy crate doc files fewer times) Failed merges: r? @ghost
Rollup of 6 pull requests Successful merges: - #63448 (fix Miri discriminant handling) - #64592 (Point at original span when emitting unreachable lint) - #64601 (Fix backticks in documentation) - #64606 (Remove unnecessary `mut` in doc example) - #64611 (rustbuild: Don't package libstd twice) - #64613 (rustbuild: Copy crate doc files fewer times) Failed merges: r? @ghost
fix discriminant handling The Miri side of rust-lang/rust#63448
This can be reviewed commit-by-commit fairly well.
The Miri side is at rust-lang/miri#903.
Fixes#62138
r? @eddyb@oli-obk