Saltar al contenido
TE113 · Tipos · error

El campo `using` debe embeber un struct

Un campo marcado con `using` debe embeber otro struct — son sus campos los que se promueven. Un escalar, o cualquier tipo que no sea una declaración de struct conocida, no tiene campos que promover.

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 P

2. 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 promotion

Generic 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

Véase también

Buscar en Zolo

9 resultados

en