1 #![warn(clippy::wrong_self_convention)] 2 #![allow(dead_code)] 3 main()4fn main() {} 5 6 mod issue6983 { 7 pub struct Thing; 8 pub trait Trait { to_thing(&self) -> Thing9 fn to_thing(&self) -> Thing; 10 } 11 12 impl Trait for u8 { 13 // don't trigger, e.g. `ToString` from `std` requires `&self` to_thing(&self) -> Thing14 fn to_thing(&self) -> Thing { 15 Thing 16 } 17 } 18 19 trait ToU64 { to_u64(self) -> u6420 fn to_u64(self) -> u64; 21 } 22 23 struct FooNoCopy; 24 // don't trigger 25 impl ToU64 for FooNoCopy { to_u64(self) -> u6426 fn to_u64(self) -> u64 { 27 2 28 } 29 } 30 } 31 32 mod issue7032 { 33 trait Foo { from_usize(x: usize) -> Self34 fn from_usize(x: usize) -> Self; 35 } 36 // don't trigger 37 impl Foo for usize { from_usize(x: usize) -> Self38 fn from_usize(x: usize) -> Self { 39 x 40 } 41 } 42 } 43 44 mod issue7179 { 45 pub struct S(i32); 46 47 impl S { 48 // don't trigger (`s` is not `self`) from_be(s: Self) -> Self49 pub fn from_be(s: Self) -> Self { 50 S(i32::from_be(s.0)) 51 } 52 53 // lint from_be_self(self) -> Self54 pub fn from_be_self(self) -> Self { 55 S(i32::from_be(self.0)) 56 } 57 } 58 59 trait T { 60 // don't trigger (`s` is not `self`) from_be(s: Self) -> Self61 fn from_be(s: Self) -> Self; 62 // lint from_be_self(self) -> Self63 fn from_be_self(self) -> Self; 64 } 65 66 trait Foo: Sized { as_byte_slice(slice: &[Self]) -> &[u8]67 fn as_byte_slice(slice: &[Self]) -> &[u8]; 68 } 69 } 70 71 mod issue3414 { 72 struct CellLikeThing<T>(T); 73 74 impl<T> CellLikeThing<T> { 75 // don't trigger into_inner(this: Self) -> T76 fn into_inner(this: Self) -> T { 77 this.0 78 } 79 } 80 81 impl<T> std::ops::Deref for CellLikeThing<T> { 82 type Target = T; 83 deref(&self) -> &T84 fn deref(&self) -> &T { 85 &self.0 86 } 87 } 88 } 89 90 // don't trigger 91 mod issue4546 { 92 use std::pin::Pin; 93 94 struct S; 95 impl S { as_mut(self: Pin<&mut Self>)96 pub fn as_mut(self: Pin<&mut Self>) {} 97 as_other_thingy(self: Pin<&Self>)98 pub fn as_other_thingy(self: Pin<&Self>) {} 99 is_other_thingy(self: Pin<&Self>)100 pub fn is_other_thingy(self: Pin<&Self>) {} 101 to_mut(self: Pin<&mut Self>)102 pub fn to_mut(self: Pin<&mut Self>) {} 103 to_other_thingy(self: Pin<&Self>)104 pub fn to_other_thingy(self: Pin<&Self>) {} 105 } 106 } 107 108 mod issue_8480_8513 { 109 struct Cat(String); 110 111 impl Cat { is_animal(&mut self) -> bool112 fn is_animal(&mut self) -> bool { 113 todo!(); 114 } 115 } 116 } 117