Skip to content

clippy: box the Value::Closure payload (large_enum_variant, currently allowed) #360

Description

@hyperpolymath

Surfaced by PR #358, which revived Rust CI after it had failed 60/60 runs at 0s without
ever being parsed by GitHub. With the gate running again, clippy -D warnings reports:

error: large size difference between variants
   --> src/ephapax-interp/src/lib.rs:110:1
    | Closure { param, param_ty, body, env }  -- largest variant, >= 264 bytes
    | String  { data, region }                -- second largest, >= 48 bytes

Value::Closure is roughly 5.5x the next largest variant, so every Value — every
Unit, Bool, I32 — costs 264 bytes in the interpreter's hot path.

Why it is currently #[allow]ed

The fix is to box the closure payload. That changes every construction site and every
match arm for Value::Closure across the interpreter — the semantics-bearing component
of the language. Bundling that refactor into a CI-infrastructure PR would have hidden a
real behavioural-risk change inside an unrelated diff, so PR #358 instead added a narrow,
commented #[allow(clippy::large_enum_variant)] at the enum.

This issue tracks doing it properly.

Suggested approach

Box the payload, e.g.:

Closure(Box<ClosureData>),

pub struct ClosureData {
    pub param: Var,
    pub param_ty: Ty,
    pub body: Expr,
    pub env: Environment,
}

Then remove the #[allow] at src/ephapax-interp/src/lib.rs.

Acceptance

  • cargo clippy --all-targets -- -D warnings passes with the #[allow] removed.
  • Interpreter tests pass unchanged — this must be a pure representation change with no
    observable semantic difference.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions