Skip to content

Deranged 0.4.1 breaks build of other crates (PartialEq with empty slices) #21

Closed as not planned
@chifflier

Description

@chifflier

Hi,

After a cargo update from 0.4.0 to 0.4.1, building unit tests breaks in unrelated parts of my crate (asn1-rs) due to a conflicting implementation of PartialEq. Building with 0.4.0 works fine

I know this has already been reported, however I think this is not a duplicate:

  • I have updated all dependencies using a global cargo update (including time and deranged), problem is still here
  • cargo outdated shows to crate to upgrade
  • this seems to happen only with empty slices
  • this happens in code not importing time nor deranged

I tried to pin the problem to a minimal test case
The errors are related to comparisons of empty &[u8] (non-empty comparison work). For ex, the following fails:

fn build_failure() {
    let b1 = &[0_u8, 1];
    assert_eq!(b1, &[]);
}

Edit: the minimal crate I created to show the problem fails for another reason
Edit 2:
I have tried to isolate the problem in a minimal crate here
Adding use time::OffsetDateTime is enough to trigger the problem:
The first function build_ok builds, while the second fails with error:

error[E0283]: type annotations needed
  --> src/lib.rs:10:5
   |
10 |     assert_eq!(b1, &[]);
   |     ^^^^^^^^^^^^^^^^^^^ cannot infer type
   |
   = note: multiple `impl`s satisfying `u8: PartialEq<_>` found in the following crates: `core`, `deranged`:
           - impl PartialEq for u8;
           - impl<MIN, MAX> PartialEq<deranged::RangedU8<MIN, MAX>> for u8
             where the constant `MIN` has type `u8`, the constant `MAX` has type `u8`;
   = note: required for `[u8]` to implement `PartialEq<[_; 0]>`
   = note: 1 redundant requirement hidden
   = note: required for `&[u8]` to implement `PartialEq<&[_; 0]>`
   = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions