1 #![warn(clippy::inherent_to_string)]
2 #![deny(clippy::inherent_to_string_shadow_display)]
7 fn to_string(&self) -> String;
19 // Should be detected; emit warning
20 fn to_string(&self) -> String {
21 "A.to_string()".to_string()
24 // Should not be detected as it does not match the function signature
25 fn to_str(&self) -> String {
26 "A.to_str()".to_string()
30 // Should not be detected as it is a free function
31 fn to_string() -> String {
32 "free to_string()".to_string()
36 // Should not be detected, wrong return type
37 fn to_string(&self) -> i32 {
43 // Should be detected and emit error as C also implements Display
44 fn to_string(&self) -> String {
45 "C.to_string()".to_string()
49 impl fmt::Display for C {
50 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
51 write!(f, "impl Display for C")
55 impl FalsePositive for D {
56 // Should not be detected, as it is a trait function
57 fn to_string(&self) -> String {
58 "impl FalsePositive for D".to_string()
63 // Should not be detected, as it is not bound to an instance
64 fn to_string() -> String {
65 "E::to_string()".to_string()
70 // Should not be detected, as it does not match the function signature
71 fn to_string(&self, _i: i32) -> String {
72 "F.to_string()".to_string()
77 // Should not be detected, as it does not match the function signature
78 fn to_string<const _N: usize>(&self) -> String {
79 "G.to_string()".to_string()