E3039

E3039 — I::Item disagrees with the impl for what I is: an argument bound it to one type and that impl binds Item to another.

What the compiler reports

E3039 … `I::Item` is i32 here, but `Range` binds `Item` to i64

The fragments the test suite holds the compiler to. An ellipsis marks text the test does not constrain; the emitted message also carries a source location.

A program that triggers it

import core::iter;

fn apply<I : Iterator, U>(it : I, f : Closure1<I::Item, U>) -> U {
  let mut i = it;
  let p = f.func;
  return p(f.env, i.next().unwrap());
}

fn main() -> i32 {
  let m = apply(range(0i64, 5i64), | x : i32 | x * 2);
  return 0;
}

// The closure says the items are i32; `Range` says they are i64.

From tests/frontend/fail/projection_disagrees_with_the_impl.vx, which asserts this diagnostic on every commit.

Related