Skip to content

Reconsider PartialEq and PartialOrd with primitives #150

@cuviper

Description

@cuviper

This afternoon I tried updating some of my numerical code (Project Euler stuff) to use the master branch of num-bigint for pre-release testing. Some of the changes needed are expected, but the one that's really killing me is the expanded PartialEq and PartialOrd (#105/#136). This broke type inference in many places, even where num-bigint wasn't used at all!

I have a common euler crate with utility stuff, which does pull in num-bigint. However, this problem p082 doesn't use anything with bigint, yet it's affected:

error[E0283]: type annotations needed for `&ndarray::ArrayBase<ndarray::data_repr::OwnedRepr<u32>, ndarray::dimension::dim::Dim<[usize; 2]>>`
  --> problems/p082/src/main.rs:44:29
   |
37 |     let weights = &euler::square_from_iter(
   |         ------- consider giving `weights` the explicit type `&ndarray::ArrayBase<ndarray::data_repr::OwnedRepr<u32>, ndarray::dimension::dim::Dim<[usize; 2]>>`, where the type parameter `usize` is specified
...
44 |     assert!(weights.nrows() < MAX.into());
   |                             ^ cannot infer type for type `usize`
   |
   = note: cannot resolve `usize: std::cmp::PartialOrd<_>`

That's a bad error about weights -- the problem is really in the MAX.into() type, which previously inferred correctly from u8 to usize. I may try to reduce a test case of that bad message for a rustc bug. But I'm really concerned that we've affected type inference from afar.

cc @hansihe @birkenfeld -- have you tried using master num-bigint on any big projects?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions