mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-12-24 20:13:24 +00:00
6966c78be7
When the `to_*` method takes `&self` and it is a trait implementation, we don't trigger the lint.
32 lines
602 B
Rust
32 lines
602 B
Rust
// edition:2018
|
|
#![warn(clippy::wrong_self_convention)]
|
|
#![warn(clippy::wrong_pub_self_convention)]
|
|
#![allow(dead_code)]
|
|
|
|
fn main() {}
|
|
|
|
mod issue6983 {
|
|
pub struct Thing;
|
|
pub trait Trait {
|
|
fn to_thing(&self) -> Thing;
|
|
}
|
|
|
|
impl Trait for u8 {
|
|
// don't trigger, e.g. `ToString` from `std` requires `&self`
|
|
fn to_thing(&self) -> Thing {
|
|
Thing
|
|
}
|
|
}
|
|
|
|
trait ToU64 {
|
|
fn to_u64(self) -> u64;
|
|
}
|
|
|
|
struct FooNoCopy;
|
|
// trigger lint
|
|
impl ToU64 for FooNoCopy {
|
|
fn to_u64(self) -> u64 {
|
|
2
|
|
}
|
|
}
|
|
}
|