Why this fires¶
A struct has two or more using-embedded fields whose types declare a field with the same name, and a .field access on the outer struct can't tell which embed to promote it from.
struct A { x: int }
struct B { x: int }
struct P { using a: A, using b: B }
fn go(p: P) -> int {
return p.x
// ^ error[TE112]: field 'x' is ambiguous between `using` embeds;
// qualify it, e.g. `<recv>.<embed>.x`
}Both A and B embed a field named x, so p.x alone doesn't say which one is meant.
Fix it¶
Qualify the access through the embed you want:
fn go(p: P) -> int {
return p.a.x // ok — explicitly through embed `a`
}See also¶
TE113— ausingfield's type isn't a struct at all.- /docs/data-structures#structs —
usingfield embedding.