Skip to content

Clippy nightly fails with result_large_err on controller::Error #1879

@doxxx93

Description

@doxxx93

Current and expected behavior

Current behavior:
Running cargo +nightly clippy --workspace fails with result_large_err errors in kube-runtime/src/controller/mod.rs:

error: the `Err`-variant returned from this closure is very large
   --> kube-runtime/src/controller/mod.rs:409:38
    |
 44 |     ObjectNotFound(ObjectRef<DynamicObject>),
    |     ---------------------------------------- the largest variant contains at least 216 bytes
 45 |     #[error("reconciler for object {1} failed")]
 46 |     ReconcilerFailed(#[source] ReconcilerErr, ObjectRef<DynamicObject>),
    |     ------------------------------------------------------------------- the variant `ReconcilerFailed` contains at least 216 bytes
...
    = help: try reducing the size of `controller::Error<...>`, for example by boxing large elements
    = note: `#[deny(clippy::result_large_err)]` implied by `#[deny(clippy::all)]`

Expected behavior:
Clippy nightly should pass without errors.

Possible solution

Two options:

  1. Box the ObjectRef<DynamicObject> (breaking change):
#[derive(Debug, Error)]
pub enum Error<ReconcilerErr: 'static, QueueErr: 'static> {
    #[error("tried to reconcile object {0} that was not found in local store")]
    ObjectNotFound(Box<ObjectRef<DynamicObject>>),
    #[error("reconciler for object {1} failed")]
    ReconcilerFailed(#[source] ReconcilerErr, Box<ObjectRef<DynamicObject>>),
    // ...
}
  1. Allow the lint (non-breaking):
#[derive(Debug, Error)]
#[allow(clippy::result_large_err)]
pub enum Error<ReconcilerErr: 'static, QueueErr: 'static> {
    // ...
}

Additional context

The ObjectRef<DynamicObject> is 216 bytes because:

  • ApiResource (DynamicType): 5 × String = ~120 bytes
  • name: String + namespace: Option<String> + extra: Extra = ~96 bytes

This also affects PR #1875's CI: https://github.com/kube-rs/kube/actions/runs/20649326753/job/59291390836

Environment

  • Clippy nightly (2026-01-02)
  • Reproducible on main branch

Configuration and features

kube = { version = "0.99.0", features = ["runtime"] }

Affected crates

  • kube-runtime

Would you like to work on fixing this bug?

maybe

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions