derive_more icon indicating copy to clipboard operation
derive_more copied to clipboard

Support `Self` in `Into` derive

Open nazar-pc opened this issue 1 year ago • 2 comments
trafficstars

#[derive(Into)]
pub struct A( [u8; Self::SIZE]);

impl A {
    const SIZE: usize = 32;
}

This generates following code:

#[allow(clippy::unused_unit)]
#[automatically_derived]
impl derive_more::core::convert::From<A> for ( [u8; Self::SIZE] ) {
    #[inline]
    fn from(value: A) -> Self { (<[u8; Self::SIZE] as derive_more::core::convert::From<_>>::from(value.0)) }
}

Which is clearly problematic because for [u8; Self::SIZE] doesn't make sense.

Self in such cases should be replaced with struct name.

nazar-pc avatar Sep 24 '24 04:09 nazar-pc