num-integer icon indicating copy to clipboard operation
num-integer copied to clipboard

tests fail to compile with Rust 1.87

Open decathorpe opened this issue 5 months ago • 1 comments

It looks like the stabilization of https://doc.rust-lang.org/stable/std/primitive.u8.html#method.is_multiple_of causes the tests to fail to compile due to a type mismatch:

error[E0308]: mismatched types
    --> src/lib.rs:1021:50
     |
1021 |                 assert!((0 as $T).is_multiple_of(&(0 as $T)));
     |                                   -------------- ^^^^^^^^^^ expected `u8`, found `&u8`
     |                                   |
     |                                   arguments to this method are incorrect
...
1052 | impl_integer_for_usize!(u8, test_integer_u8);
     | -------------------------------------------- in this macro invocation
     |
note: method defined here
    --> /builddir/build/BUILD/rust-1.87.0-build/rustc-1.87.0-src/library/core/src/num/mod.rs:436:5
     = note: this error originates in the macro `impl_integer_for_usize` which comes from the expansion of the macro `uint_impl` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider using clone here
     |
1021 |                 assert!((0 as $T).is_multiple_of(&(0 as $T).clone()));
     |                                                            ++++++++

(and many more errors like this one)

It looks like the method definitions in this crate and the one in std aren't compatible: https://docs.rs/num-integer/latest/num_integer/trait.Integer.html#tymethod.is_multiple_of

→ one uses &Self for the "other" type, one uses Self for the "rhs" type.

decathorpe avatar Jun 02 '25 15:06 decathorpe