Skip to content
TE119 · Type · error

`@flags` enum must be flat and non-generic

An `@flags` enum is generic or has a payload-carrying variant. `@flags` models a bitmask over a fixed, flat set of unit variants — there's no room for type parameters or payloads.

Why this fires

An @flags enum is generic, or has a variant that carries a payload. @flags enums represent a bitmask over a fixed, flat set of unit variants — there's no room for type parameters or per-variant payloads in that model.

@flags
enum Perm: u8 {
    Read,
    Write(int),
    //    ^^^ error[TE119]: @flags enum `Perm` requires all-unit variants;
    //        `Write` has a payload
}

Fix it

Drop the payload (and any type parameters):

@flags
enum Perm: u8 { Read, Write, Exec }   // ok — all unit variants

See also

  • TE120 — a flag value isn't a power of two or a known composite.
  • TE121 — a flag value doesn't fit the backing type.
  • TE122 — two flags occupy the same bit.
  • /docs/data-structures#enums@flags bit-flag enums.

See also

Search Zolo

9 results

en