rustc_lint::unused

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.