Use of `into()` causes `From` impl resolution ambiguity.
The following error results from having dependencies on deranged 0.4.1 and tor-consdiff and/or tor-circmgr in the same project.
A simple reproduction can be made by creating an empty project with the following in Cargo.toml:
[dependencies]
arti-client = "0.23"
deranged = "0.4.1"
error[E0283]: type annotations needed
--> /home/nuttycom/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tor-consdiff-0.23.0/src/lib.rs:371:54
|
371 | (lo, Some(RangeEnd::Num(hi))) if lo > hi.into() => {
| - ^^^^
| |
| type must be known at this point
|
= note: multiple `impl`s satisfying `usize: PartialOrd<_>` found in the following crates: `core`, `deranged`:
- impl PartialOrd for usize;
- impl<MIN, MAX> PartialOrd<deranged::RangedUsize<MIN, MAX>> for usize
where the constant `MIN` has type `usize`, the constant `MAX` has type `usize`;
help: try using a fully qualified path to specify the expected types
|
371 | (lo, Some(RangeEnd::Num(hi))) if lo > <std::num::NonZero<usize> as Into<T>>::into(hi) => {
| ++++++++++++++++++++++++++++++++++++++++++++ ~
The following patch should resolve the issue:
diff --git a/crates/tor-circmgr/src/timeouts/pareto.rs b/crates/tor-circmgr/src/timeouts/pareto.rs
index 3a44954d4..358591091 100644
--- a/crates/tor-circmgr/src/timeouts/pareto.rs
+++ b/crates/tor-circmgr/src/timeouts/pareto.rs
@@ -628,7 +628,7 @@ impl super::TimeoutEstimator for ParetoTimeoutEstimator {
}
fn learning_timeouts(&self) -> bool {
- self.p.use_estimates && self.history.n_times() < self.p.min_observations.into()
+ self.p.use_estimates && self.history.n_times() < usize::from(self.p.min_observations)
}
fn build_state(&mut self) -> Option<ParetoTimeoutState> {
diff --git a/crates/tor-consdiff/src/lib.rs b/crates/tor-consdiff/src/lib.rs
index d9db4fd91..01b782e1c 100644
--- a/crates/tor-consdiff/src/lib.rs
+++ b/crates/tor-consdiff/src/lib.rs
@@ -368,7 +368,7 @@ impl<'a> DiffCommand<'a> {
}
match (low, high) {
- (lo, Some(RangeEnd::Num(hi))) if lo > hi.into() => {
+ (lo, Some(RangeEnd::Num(hi))) if lo > usize::from(hi) => {
return Err(Error::BadDiff("mis-ordered lines in range"))
}
(_, _) => (),