Can't publish crate with dashu dependency
mthom opened this issue · 7 comments
I'm trying to publish a crate that depends on the forked dashu at github.com/coasys/dashu but cargo publish --dry-run
complains that it can't find the functions associated with the ToPrimitive
trait of num_traits
. Is there a workaround for this? Thanks.
What did you mean by "depends on the forked dashu at github.com/coasys/dashu" please? Can you elaborate on your Cargo.toml and error information?
Yes. I'm using the dashu at the named repo like this in my Cargo.toml file:
dashu = { git = "https://github.com/coasys/dashu.git", version = 0.3.1 }
Ordinarily this works fine, but when I try to compile the crate for publishing on crates.io (using cargo publish --dry-run
) I get:
error[E0599]: no method named `to_i64` found for struct `arena::TypedArenaPtr<IBig>` in the current scope
--> src/arithmetic.rs:373:32
|
373 | if let Some(n) = i.to_i64() {
| ^^^^^^
|
::: src/arena.rs:188:1
and similar errors, all related to the ToPrimitive
trait not being found. Some recommend to add use num_traits::cast::ToPrimitive;
but this doesn't work.
IIRC, you can't publish a crate with git dependency, because cargo will try to pull dashu
from crates.io, which is the version published by me. If you want to publish your crate with dashu
, please use the official repo.
I noticed that the fork you are using added conversion functionalities like the to_i64()
in your code, this conversion is implemented as impl TryFrom<IBig>
in the main branch, so you can use i.try_into()
instead with the official dashu
crate.
The issue should be solved by now.
I'm afraid it's not. The latest publish dry run produces this batch of errors:
error[E0277]: the trait bound `IBig: NumOrd<RBig>` is not satisfied
--> src/arithmetic.rs:542:100
|
542 | ...er::from(n1.get_num()).num_eq(&**n2),
| ------ ^^^^^ the trait `NumOrd<RBig>` is not implemented for `IBig`
| |
| required by a bound introduced by this call
|
= help: the following other types implement trait `NumOrd<Other>`:
<IBig as NumOrd<isize>>
<IBig as NumOrd<i8>>
<IBig as NumOrd<i16>>
<IBig as NumOrd<i32>>
<IBig as NumOrd<i64>>
<IBig as NumOrd<i128>>
<IBig as NumOrd<usize>>
<IBig as NumOrd<u8>>
and 6 others
error[E0599]: no method named `num_eq` found for reference `&RBig` in the current scope
--> src/arithmetic.rs:543:73
|
543 | ...(n2)) => (&**n1).num_eq(&Integer::from(n2.get_num())),
| ^^^^^^ method not found in `&RBig`
error[E0277]: the trait bound `IBig: NumOrd<RBig>` is not satisfied
--> src/arithmetic.rs:560:36
|
560 | (&**n1).num_eq(&**n2)
| ------ ^^^^^ the trait `NumOrd<RBig>` is not implemented for `IBig`
| |
| required by a bound introduced by this call
|
= help: the following other types implement trait `NumOrd<Other>`:
<IBig as NumOrd<isize>>
<IBig as NumOrd<i8>>
<IBig as NumOrd<i16>>
<IBig as NumOrd<i32>>
<IBig as NumOrd<i64>>
<IBig as NumOrd<i128>>
<IBig as NumOrd<usize>>
<IBig as NumOrd<u8>>
and 6 others
error[E0599]: no method named `num_eq` found for reference `&RBig` in the current scope
--> src/arithmetic.rs:570:29
|
570 | (&**n1).num_eq(&**n2)
| ^^^^^^ method not found in `&RBig`
error[E0599]: no method named `num_cmp` found for reference `&RBig` in the current scope
--> src/arithmetic.rs:601:48
|
601 | ... => Some((&**r).num_cmp(&Integer::from(*rhs))),
| ^^^^^^^ method not found in `&RBig`
error[E0599]: no method named `num_eq` found for reference `&RBig` in the current scope
--> src/arithmetic.rs:621:43
|
621 | Number::Rational(r) => (&**r).num_eq(&Integer::from(*rhs)),
| ^^^^^^ method not found in `&RBig`
error[E0277]: the trait bound `IBig: NumOrd<RBig>` is not satisfied
--> src/arithmetic.rs:657:44
|
657 | (&*n1).num_partial_cmp(&*n2).unwrap_or(Ordering::Less)
| --------------- ^^^^ the trait `NumOrd<RBig>` is not implemented for `IBig`
| |
| required by a bound introduced by this call
|
= help: the following other types implement trait `NumOrd<Other>`:
<IBig as NumOrd<isize>>
<IBig as NumOrd<i8>>
<IBig as NumOrd<i16>>
<IBig as NumOrd<i32>>
<IBig as NumOrd<i64>>
<IBig as NumOrd<i128>>
<IBig as NumOrd<usize>>
<IBig as NumOrd<u8>>
and 6 others
error[E0599]: no method named `num_partial_cmp` found for reference `&RBig` in the current scope
--> src/arithmetic.rs:667:28
|
667 | (&*n1).num_partial_cmp(&*n2).unwrap_or(Ordering::Less)
| ^^^^^^^^^^^^^^^ method not found in `&RBig`
error[E0599]: no method named `num_eq` found for struct `RBig` in the current scope
--> src/machine/unify.rs:431:47
|
431 | ...nal(n2) if (*n2).num_eq(&Integer::from(n1.get_num())) => {}
| ^^^^^^ method not found in `RBig`
error[E0277]: the trait bound `IBig: NumOrd<IBig>` is not satisfied
--> src/machine/unify.rs:475:53
|
475 | Number::Integer(n2) if (*n1).num_eq(&*n2) => {}
| ------ ^^^^ the trait `NumOrd<IBig>` is not implemented for `IBig`
| |
| required by a bound introduced by this call
|
= help: the following other types implement trait `NumOrd<Other>`:
<IBig as NumOrd<isize>>
<IBig as NumOrd<i8>>
<IBig as NumOrd<i16>>
<IBig as NumOrd<i32>>
<IBig as NumOrd<i64>>
<IBig as NumOrd<i128>>
<IBig as NumOrd<usize>>
<IBig as NumOrd<u8>>
and 6 others
error[E0599]: no method named `num_eq` found for struct `RBig` in the current scope
--> src/machine/unify.rs:476:47
|
476 | Number::Rational(n2) if (*n2).num_eq(&*n1) => {}
| ^^^^^^ method not found in `RBig`
error[E0599]: no method named `num_eq` found for struct `RBig` in the current scope
--> src/machine/unify.rs:495:45
|
495 | ... Number::Fixnum(n2) if (*n1).num_eq(&Integer::from(n2.get_num())) ...
| ^^^^^^ method not found in `RBig`
error[E0599]: no method named `num_eq` found for struct `RBig` in the current scope
--> src/machine/unify.rs:496:46
|
496 | Number::Integer(n2) if (*n1).num_eq(&*n2) => {}
| ^^^^^^ method not found in `RBig`
I think someone (maybe @fayeed) need to create a PR to modify the Cargo.toml to use dashu v0.4. I can give a try if I get some spare time this week.
I tried locally and the crate can be published with dashu
v0.4. I will create a PR tomorrow with additional modifications about more idiomatic usage of dashu
.