Why this fires¶
A field marked using must embed another struct — its fields are what get promoted onto the outer struct. A scalar (int, str, bool, ...), or any other type that isn't a known struct declaration, has no fields to promote and can't be embedded this way.
struct P {
using base: int,
// ^^^ error[TE113]: `using` field 'base' must embed a struct type,
// found non-struct 'int'
}Fix it¶
1. Embed a struct instead¶
struct Base { id: int }
struct P { using base: Base } // ok — Base's fields promote onto P2. Drop using if you just want a plain field¶
If the field was never meant to promote its contents, remove using:
struct P { base: int } // ok — a regular field, no promotionGeneric type parameters are exempt from this check — struct Wrapper<T> { using inner: T } is valid even though T isn't a concrete struct name, since the embed is resolved once T is instantiated.
See also¶
TE112— ambiguous field between twousingembeds.- /docs/data-structures#structs —
usingfield embedding.