E3041

E3041 — A struct field that names I::Item. Fields are laid out from the struct's parameters alone, so the projection is made a parameter instead, as Map<I, F> does with its closure.

What the compiler reports

E3041 … field 'last' of struct 'Holder' names `I::Item`

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;

struct Holder<I> {
  it : I,
  last : I::Item,
}

fn main() -> i32 {
  return 0;
}

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

Related