Closed
Description
Description
A lot of the reason you may Box
something is if it is too large to move cheaply. For large types it wouldn't be very unusual to return a Box<T>
, especially if the box existed before returning it (as in the example here) to prevent some unnecessary moves or reallocations.
It could be a good idea to not raise this lint if T is e.g. >64 bytes (or reuse the threashold for suggesting boxed enum variants).
Some relevant zulip discussion: https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/returning.20boxed.20values
#![allow(unused)]
#![warn(clippy::pedantic)]
struct Huge([u8; 500]);
struct HasHuge(Box<Huge> /* ... */);
impl HasHuge {
fn into_huge(self) -> Box<Huge> {
self.0
}
}
Version
rustc 1.68.2 stable
Additional Labels
@rustbot label +C-enhancement