cmpute/dashu

Issues with `ibig!` macro

Closed this issue · 9 comments

Minimal example:

fn main() {
    let _ = dashu::ibig!(0);
}

fails to build:

error[E0433]: failed to resolve: could not find `dashu_int` in the list of imported crates
 --> src/main.rs:2:13
  |
2 |     let _ = dashu::ibig!(0);
  |             ^^^^^^^^^^^^^^^ could not find `dashu_int` in the list of imported crates
  |
  = note: this error originates in the macro `dashu::ibig` (in Nightly builds, run with -Z macro-backtrace for more info)

Builds fine if I add dashu-int = "0.2.0" to Cargo.toml. However, when I try to cross-compile for i686 from x86_64:

error[E0308]: mismatched types
   --> src/main.rs:2:13
    |
2   |     let _ = dashu::ibig!(0);
    |             ^^^^^^^^^^^^^^^
    |             |
    |             expected `u64`, found `u128`
    |             arguments to this function are incorrect
    |
note: associated function defined here
   --> dashu-int-0.2.0/src/ibig.rs:156:18
    |
156 |     pub const fn from_parts_const(sign: Sign, dword: crate::DoubleWord) -> Self {
    |                  ^^^^^^^^^^^^^^^^
    = note: this error originates in the macro `dashu::ibig` (in Nightly builds, run with -Z macro-backtrace for more info)
help: change the type of the numeric literal from `u128` to `u64`
    |
2   |     let _ = dashu::ibig!(0)u64;
    |                            +++

Sorry, but I can't reproduce the two problems locally, could you share with me your Cargo.toml and how you cross compile for i686?

I can confirm the first issue now, the fix will be pushed in the next release, by then you should be able to use dashu::ibig out of the box. But I still need some details to reproduce the second issue, thanks.

You can cross-compile with

cargo build --target i686-unknown-linux-gnu

You might need to install the target's support for rust. If you use rustup, you can install it with

rustup target add i686-unknown-linux-gnu

I have reproduced the second issue locally, unfortunately the fix requires a break change. The fix to the second issue will be pushed to v0.3. Thanks for reporting this!

The version v0.3 has been released, please have a check to see if the issue has been fixed, thanks!

For large values, it still fails to compile:

error[E0433]: failed to resolve: could not find `int` in `dashu`
 --> src/main.rs:2:13
  |
2 |     let _ = dashu::ibig!(999999999999);
  |             ^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in `dashu::int`

Okay I got the reason, I will release a fix soon.

I just pushed a new version dashu-macros v0.3.1, it should be able to solve the problem if you clean and recompile dashu dependencies again. Please let me know if the problem persists, thanks!

It is fixed now. Thanks you!