Closed
Description
Output of cargo clippy -V
: clippy 0.0.212 (3aea8603 2019-09-03)
Given the following code:
trait Foo {
fn bar(self: Box<Self>) -> u32 {
5
}
}
Clippy lint boxed local is triggered, advising us to remove the Box and have plain self
in the argument list, like this:
trait Foo {
fn bar(self) -> u32 {
5
}
}
However, doing this makes the code fail compilation with the following error:
the size for values of type "Self" cannot be known at compilation time
,
which is always the case for traits.
I've encountered this while implementing the state design pattern with dynamic dispatch. I wouldn't usually opt for dynamic dispatch, however the problem domain requires it.
Ideally this lint should check weather the implementation is a default trait method implementation before triggering.