Uh oh!
There was an error while loading. Please reload this page.
Miri: convert to/from apfloat instead of host floats - #61673
Conversation
rust-highfive
commented
Jun 8, 2019
r? @varkor (rust_highfive has picked a reviewer for you, use r? to override) |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com>
RalfJung
commented
Jun 9, 2019
Interesting that this passed... seems like we are missing a case from our test suite, namely casting a multivariant integer enum to an integer. |
RalfJung
commented
Jun 9, 2019
I opened #61702 for the missing test; this PR here is good to go I think. |
| Div => (l / r).value.into(), | ||
| Rem => (l % r).value.into(), | ||
| _ => bug!("invalid float op: `{:?}`", bin_op), | ||
| }; |
There was a problem hiding this comment.
Yeah, I love this. :) If only we had a similar trait for integers.
There was a problem hiding this comment.
All integer operations can be implemented with a runtime bitwidth n and an u128 to hold the value, though (maybe i128 for signed).
There was a problem hiding this comment.
Like, LLVM also has an APInt, not just APFloat, and APFloat uses APInt for the significand, but I didn't port APInt as its own thing, just added a bunch of functions, because of how relatively simple it is:
rust/src/librustc_apfloat/ieee.rs
Lines 2287 to 2777 in ad3829f
There was a problem hiding this comment.
Hm, I feel like at least for the signed/unsigned distinction this will become ugly when done "untyped".
That "simple" thing you pointed to is still way more complicated than what we currently do for integers ops in CTFE.
There was a problem hiding this comment.
@RalfJung Yes, because it handles arbitrary-size integers, while you have only one "limb".
What you do is more or less what I mean.
eddyb
commented
Jun 10, 2019
@oli-obk r=me unless you have miri-specific comments |
oli-obk
commented
Jun 11, 2019
@bors r=eddyb,oli-obk |
bors
commented
Jun 11, 2019
📌 Commit 8dfc8db has been approved by |
RalfJung
commented
Jun 11, 2019
Let's make Miri work again. @bors p=1 |
bors
commented
Jun 11, 2019
bors
commented
Jun 11, 2019
☀️ Test successful - checks-travis, status-appveyor |
rust-highfive
commented
Jun 11, 2019
Tested on commit rust-lang/rust@912d22e. Direct link to PR: <rust-lang/rust#61673> 🎉 rls on linux: test-fail → test-pass (cc @Xanewok, @rust-lang/infra).
test more variants of enum-int-casting As I learned in rust-lang#61673 (comment), there is a code path we are not testing yet. Looks like enum-int-casting with and without an intermediate let-binding is totally different. EDIT: The reason for this is to get rid of the cycle in definitions such as: ```rust enum Foo { A = 0, B = Foo::A as isize + 2, } ``` This has historically been supported, so a hack adding special treatment to `Enum::Variant as _` was added to keep supporting it.
Cc @oli-obk@eddyb