2021-03-29 19:51:23 +00:00
|
|
|
#![warn(clippy::wrong_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;
|
2021-05-06 17:49:31 +00:00
|
|
|
// don't trigger
|
2021-03-29 19:51:23 +00:00
|
|
|
impl ToU64 for FooNoCopy {
|
|
|
|
fn to_u64(self) -> u64 {
|
|
|
|
2
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-04-11 11:29:08 +00:00
|
|
|
|
|
|
|
mod issue7032 {
|
|
|
|
trait Foo {
|
|
|
|
fn from_usize(x: usize) -> Self;
|
|
|
|
}
|
|
|
|
// don't trigger
|
|
|
|
impl Foo for usize {
|
|
|
|
fn from_usize(x: usize) -> Self {
|
|
|
|
x
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-05-13 08:24:29 +00:00
|
|
|
|
|
|
|
mod issue7179 {
|
|
|
|
pub struct S(i32);
|
|
|
|
|
|
|
|
impl S {
|
|
|
|
// don't trigger (`s` is not `self`)
|
|
|
|
pub fn from_be(s: Self) -> Self {
|
|
|
|
S(i32::from_be(s.0))
|
|
|
|
}
|
|
|
|
|
|
|
|
// lint
|
|
|
|
pub fn from_be_self(self) -> Self {
|
2023-07-28 19:35:48 +00:00
|
|
|
//~^ ERROR: methods called `from_*` usually take no `self`
|
2021-05-13 08:24:29 +00:00
|
|
|
S(i32::from_be(self.0))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
trait T {
|
|
|
|
// don't trigger (`s` is not `self`)
|
|
|
|
fn from_be(s: Self) -> Self;
|
|
|
|
// lint
|
|
|
|
fn from_be_self(self) -> Self;
|
2023-07-28 19:35:48 +00:00
|
|
|
//~^ ERROR: methods called `from_*` usually take no `self`
|
2021-05-13 08:24:29 +00:00
|
|
|
}
|
2021-05-13 21:28:40 +00:00
|
|
|
|
|
|
|
trait Foo: Sized {
|
|
|
|
fn as_byte_slice(slice: &[Self]) -> &[u8];
|
|
|
|
}
|
2021-05-13 08:24:29 +00:00
|
|
|
}
|
2021-09-16 08:52:57 +00:00
|
|
|
|
|
|
|
mod issue3414 {
|
|
|
|
struct CellLikeThing<T>(T);
|
|
|
|
|
|
|
|
impl<T> CellLikeThing<T> {
|
|
|
|
// don't trigger
|
|
|
|
fn into_inner(this: Self) -> T {
|
|
|
|
this.0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<T> std::ops::Deref for CellLikeThing<T> {
|
|
|
|
type Target = T;
|
|
|
|
|
|
|
|
fn deref(&self) -> &T {
|
|
|
|
&self.0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-09-17 03:48:21 +00:00
|
|
|
|
|
|
|
// don't trigger
|
|
|
|
mod issue4546 {
|
|
|
|
use std::pin::Pin;
|
|
|
|
|
|
|
|
struct S;
|
|
|
|
impl S {
|
|
|
|
pub fn as_mut(self: Pin<&mut Self>) {}
|
|
|
|
|
|
|
|
pub fn as_other_thingy(self: Pin<&Self>) {}
|
|
|
|
|
|
|
|
pub fn is_other_thingy(self: Pin<&Self>) {}
|
|
|
|
|
|
|
|
pub fn to_mut(self: Pin<&mut Self>) {}
|
|
|
|
|
|
|
|
pub fn to_other_thingy(self: Pin<&Self>) {}
|
|
|
|
}
|
|
|
|
}
|
2022-04-23 13:45:26 +00:00
|
|
|
|
|
|
|
mod issue_8480_8513 {
|
|
|
|
struct Cat(String);
|
|
|
|
|
|
|
|
impl Cat {
|
|
|
|
fn is_animal(&mut self) -> bool {
|
|
|
|
todo!();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|