E3038
E3038 —type Item = ..in an impl whose trait declares noItem. Usually a misspelling: nothing reads the binding, so it would go on meaning nothing, in silence.
What the compiler reports
E3038 … binds 'Itm', which trait Counter does not declare
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
trait Counter {
type Item;
fn next(self : Self) -> Self::Item;
}
impl Counter for i32 {
type Itm = i64;
fn next(self : i32) -> i64 {
return 7;
}
}
fn main() -> i32 {
let a : i32 = 1;
print(a.next());
return 0;
}
// A misspelling reports both halves: the name that was not bound, and the one that was bound
// and means nothing.
From tests/frontend/fail/associated_type_not_declared.vx, which asserts this diagnostic on every commit.
Related
A tour of VxThe chapter covering the rule this code enforces.
All diagnosticsEvery code the compiler can emit, grouped by stage.
E3037An impl of a trait that declares an associated type does not bind it. The trait's signatures are written against
Self::Item, so with no binding there is nothing to put in their place, and the method's type becomes whatever the impl happened to write.
E3039I::Item disagrees with the impl for what I is: an argument bound it to one type and that impl binds Item to another.