UNUSED_ALLOCATION in rustc_lint::unused - Rust
Description: The `unused_allocation` lint detects unnecessary allocations that can be eliminated.

Skip to main content

## UNUSED_ALLOCATION

# Static UNUSED_ALLOCATION

Source

    pub(crate) static UNUSED_ALLOCATION: &Lint

Expand description

The `unused_allocation` lint detects unnecessary allocations that can be eliminated.

#### §Example

    fn main() {
        let a = Box::new([1, 2, 3]).len();
    }

{{produces}}

#### §Explanation

When a `box` expression is immediately coerced to a reference, then the allocation is unnecessary, and a reference (using `&` or `&mut`) should be used instead to avoid the allocation.