fix: mitigate impl ambiguity introduced in deranged 0.4.1

When building an application with veilid-core, I encountered a
problem when building against 0.4.4 with unlocked dependencies, caused
by a subtle change in a transitive dependency, deranged.

In the upgrade from deranged 0.4.0 -> 0.4.1, trait impls on PartialOrd
were introduced which apparently break many downstream dependents.

Examples of this:
- https://github.com/jhpratt/deranged/issues/17
- https://github.com/jhpratt/deranged/issues/18
- https://github.com/jhpratt/deranged/issues/19

The deranged author does not regard this as a breaking change and
suggests all downstream dependents should work around it. So it goes.

veilid-core is suceptible to these now-ambiguous trait impls with an
upgrade to deranged 0.4.1 -- which cargo install or publish will
automatically perform unless locked, as it is a patch version increment.

To get ahead of this, this change makes the ambiguous trait impl
explicit with a few turbofish.
This commit is contained in:
Casey Marshall 2025-03-27 22:07:27 -05:00
parent fbf169019e
commit 2bd9ad91f4
No known key found for this signature in database
GPG Key ID: 6DEC2758ACD5A973
2 changed files with 22 additions and 12 deletions

12
Cargo.lock generated
View File

@ -1570,9 +1570,9 @@ dependencies = [
[[package]]
name = "deranged"
version = "0.4.0"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c9e6a11ca8224451684bc0d7d5a7adbf8f2fd6887261a1cfc3c0432f9d4068e"
checksum = "28cfac68e08048ae1883171632c2aef3ebc555621ae56fbccce1cbf22dd7f058"
dependencies = [
"powerfmt",
]
@ -5651,9 +5651,9 @@ dependencies = [
[[package]]
name = "time"
version = "0.3.40"
version = "0.3.41"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9d9c75b47bdff86fa3334a3db91356b8d7d86a9b839dab7d0bdc5c3d3a077618"
checksum = "8a7619e19bc266e0f9c5e6686659d394bc57973859340060a69221e57dbc0c40"
dependencies = [
"deranged",
"itoa",
@ -5674,9 +5674,9 @@ checksum = "c9e9a38711f559d9e3ce1cdb06dd7c5b8ea546bc90052da6d06bb76da74bb07c"
[[package]]
name = "time-macros"
version = "0.2.21"
version = "0.2.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "29aa485584182073ed57fd5004aa09c371f021325014694e432313345865fd04"
checksum = "3526739392ec93fd8b359c8e98514cb3e8e021beb4e5f597b00a0221f8ed8a49"
dependencies = [
"num-conv",
"time-core",

View File

@ -81,20 +81,30 @@ impl AttachmentManager {
health: &RoutingTableHealth,
config: &VeilidConfigRoutingTable,
) -> AttachmentState {
if health.reliable_entry_count >= config.limit_over_attached.try_into().unwrap() {
if health.reliable_entry_count
>= TryInto::<usize>::try_into(config.limit_over_attached).unwrap()
{
return AttachmentState::OverAttached;
}
if health.reliable_entry_count >= config.limit_fully_attached.try_into().unwrap() {
if health.reliable_entry_count
>= TryInto::<usize>::try_into(config.limit_fully_attached).unwrap()
{
return AttachmentState::FullyAttached;
}
if health.reliable_entry_count >= config.limit_attached_strong.try_into().unwrap() {
if health.reliable_entry_count
>= TryInto::<usize>::try_into(config.limit_attached_strong).unwrap()
{
return AttachmentState::AttachedStrong;
}
if health.reliable_entry_count >= config.limit_attached_good.try_into().unwrap() {
if health.reliable_entry_count
>= TryInto::<usize>::try_into(config.limit_attached_good).unwrap()
{
return AttachmentState::AttachedGood;
}
if health.reliable_entry_count >= config.limit_attached_weak.try_into().unwrap()
|| health.unreliable_entry_count >= config.limit_attached_weak.try_into().unwrap()
if health.reliable_entry_count
>= TryInto::<usize>::try_into(config.limit_attached_weak).unwrap()
|| health.unreliable_entry_count
>= TryInto::<usize>::try_into(config.limit_attached_weak).unwrap()
{
return AttachmentState::AttachedWeak;
}