Type annotations needed error

⚓ Rust    📅 2026-01-27    👤 surdeus    👁️ 1      

surdeus

I have been away from Rust for a couple of years, and have got "rusty", and am at a bit of loss to understand what has happened here.

I am running nightly. On my pstd crate when I run

cargo test -F stdtests

I get a load of errors, all of this form

error[E0283]: type annotations needed
   --> src/collections/btree_map/stdtests.rs:460:5
    |
460 |     assert_eq!(range_keys(&map, (Included(size + 1), Unbounded)), vec![]);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type
    |
    = note: multiple `impl`s satisfying `i32: PartialEq<_>` found in the following crates: `core`, `serde_json`:
            - impl PartialEq for i32;
            - impl PartialEq<serde_json::Value> for i32;
    = note: required for `Vec<i32>` to implement `PartialEq<Vec<_>>`
    = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)

Some errors have detailed explanations: E0282, E0283, E0432.
For more information about an error, try `rustc --explain E0282`.
error: could not compile `pstd` (lib test) due to 27 previous errors

I am not sure, but I think it used to compile two years ago, so I think something changed.
It seems it is seeing PartialEq from the serde crate, but I don't know why.
So I am feeling stupid. Help!

3 posts - 2 participants

Read full topic

🏷️ Rust_feed