RS.CLIPPY.BOXED_LOCAL

Using `Box<T>` where unnecessary

This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: boxed_local. Copyright ©2025 The Rust Team. All rights reserved.

What it does

Checks for usage of Box<T> where an unboxed T would work fine.

Why is this bad?

This is an unnecessary allocation, and bad for performance. It is only necessary to allocate if you wish to move the box into something.

Example

fn foo(x: Box<u32>) {}

Use instead:

fn foo(x: u32) {}

Configuration

  • too-large-for-stack: The maximum size of objects (in bytes) that will be linted. Larger objects are ok on the heap

    (default: 200)