Static rustc_lint::unused::UNUSED_ALLOCATION
source · pub(crate) static UNUSED_ALLOCATION: &Lint
Expand description
The unused_allocation
lint detects unnecessary allocations that can
be eliminated.
Example
#![feature(box_syntax)]
fn main() {
let a = (box [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.