Rust-clippy: `use_self` lint false positives

Created on 4 Jul 2018  路  1Comment  路  Source: rust-lang/rust-clippy

Minimal example:

trait IntoBytes {
    fn into_bytes(&self) -> Vec<u8>;
}

impl IntoBytes for u8 {
    fn into_bytes(&self) -> Vec<u8> {
        vec![*self]
    }
}

Here u8 in the trait definition is used as byte, but Clippy suggest to replace u8 with Self which is confusing. I think that this lint shouldn't be triggered for trait implementation.

L-bug

Most helpful comment

Whoops. You're right we should only suggest Self if it was Self in the trait declaration.

>All comments

Whoops. You're right we should only suggest Self if it was Self in the trait declaration.

Was this page helpful?
0 / 5 - 0 ratings