Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ndarray >=0.15.2 compilation issue #1051

Closed
nbigaouette opened this issue Aug 2, 2021 · 2 comments
Closed

ndarray >=0.15.2 compilation issue #1051

nbigaouette opened this issue Aug 2, 2021 · 2 comments

Comments

@nbigaouette
Copy link

nbigaouette commented Aug 2, 2021

I use ndarray in a project of mine that I unfortunately don't have much time to keep up to date.

I've revisited it today and my CI builds now fail.

After investigation it seems that the issue is caused by an update to ndarray 0.15.2 (0.15.1 worked fine).

See for example the latest CI failure here: https://github.com/nbigaouette/onnxruntime-rs/pull/90/checks?check_run_id=3216000008

In this commit I force ndarray's max version to 0.15.1 and the build succeeds.

So it seems there was a breaking change in ndarray 0.15.2 :(

I'm not sure that was expected? And not sure what exactly the issue is since it's a project I rarely touch...

Edit: The compilation error is as follow:

error[E0271]: type mismatch resolving `<ndarray::iterators::into_iter::IntoIter<f32, Dim<IxDynImpl>> as Iterator>::Item == &_`
   --> onnxruntime/tests/integration_tests.rs:107:14
    |
107 |             .copied()
    |              ^^^^^^ expected `f32`, found reference
    |
    = note:   expected type `f32`
            found reference `&_`

error[E0599]: the method `enumerate` exists for struct `Copied<ndarray::iterators::into_iter::IntoIter<f32, Dim<IxDynImpl>>>`, but its trait bounds were not satisfied
   --> onnxruntime/tests/integration_tests.rs:108:14
    |
108 |               .enumerate()
    |                ^^^^^^^^^ method cannot be called on `Copied<ndarray::iterators::into_iter::IntoIter<f32, Dim<IxDynImpl>>>` due to unsatisfied trait bounds
    | 
   ::: /Users/runner/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/ndarray-0.15.3/src/iterators/into_iter.rs:20:1
    |
20  | / pub struct IntoIter<A, D>
21  | | where
22  | |     D: Dimension,
23  | | {
...   |
31  | |     has_unreachable_elements: bool,
32  | | }
    | |_- doesn't satisfy `<_ as Iterator>::Item = &_`
    |
    = note: the following trait bounds were not satisfied:
            `<ndarray::iterators::into_iter::IntoIter<f32, Dim<IxDynImpl>> as Iterator>::Item = &_`
            which is required by `Copied<ndarray::iterators::into_iter::IntoIter<f32, Dim<IxDynImpl>>>: Iterator`
            `Copied<ndarray::iterators::into_iter::IntoIter<f32, Dim<IxDynImpl>>>: Iterator`
            which is required by `&mut Copied<ndarray::iterators::into_iter::IntoIter<f32, Dim<IxDynImpl>>>: Iterator`
jturner314 added a commit to jturner314/onnxruntime-rs that referenced this issue Aug 2, 2021
See rust-ndarray/ndarray#1051. I think these changes will fix the errors, but I haven't tested them.
@jturner314
Copy link
Member

jturner314 commented Aug 2, 2021

I think this is caused by the addition of the IntoIterator implementation for Array in ndarray 0.15.2 (#986). Before, array.into_iterator() would end up calling the IntoIterator implementation for &Array; now, it calls the IntoIterator implementation for Array. This kind of breakage (i.e. breakage due to adding an implementation of a non-fundamental trait) is considered acceptable in minor releases. (See RFC 1105.) For your convenience, I've created nbigaouette/onnxruntime-rs#91, which I think will fix the errors.

@nbigaouette
Copy link
Author

Thank you for not only identifying the issue but also providing a PR. It's greatly appreciated! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants