cmpute / dashu

A library set of arbitrary precision numbers implemented in Rust.
Apache License 2.0
76 stars 9 forks source link

Issues with `ibig!` macro #6

Closed eduardosm closed 1 year ago

eduardosm commented 2 years ago

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;
    |                            +++
cmpute commented 2 years ago

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?

cmpute commented 2 years ago

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.

eduardosm commented 2 years ago

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
cmpute commented 2 years ago

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!

cmpute commented 1 year ago

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

eduardosm commented 1 year ago

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`
cmpute commented 1 year ago

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

cmpute commented 1 year ago

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!

eduardosm commented 1 year ago

It is fixed now. Thanks you!