Skip to content

confusing compiler error for dotting a reference with a non-reference #1534

@imyxh

Description

@imyxh

Consider:

let a = array![
    [1., 2.],
    [3., 4.],
];
dbg!((&a).dot(a));

yielding

error[E0275]: overflow evaluating the requirement `&ArrayBase<_, _>: Not`
  --> src/main.rs:22:15
   |
22 |     dbg!((&a).dot(a));
   |               ^^^
   |
   = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate
   = note: required for `&ArrayBase<_, _>` to implement `Not`
   = note: 127 redundant requirements hidden
   = note: required for `&ArrayBase<OwnedRepr<{float}>, Dim<[usize; 2]>>` to implement `Not`

I find this error confusing—it took me a while (in real code) to realize that I just forgot to take a reference of the second matrix.

Possibly related to #1439?

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