1 #![warn(clippy::inherent_to_string)]
2 #![deny(clippy::inherent_to_string_shadow_display)]
3 #![allow(clippy::many_single_char_names)]
8 fn to_string(&self) -> String;
20 // Should be detected; emit warning
21 fn to_string(&self) -> String {
22 "A.to_string()".to_string()
25 // Should not be detected as it does not match the function signature
26 fn to_str(&self) -> String {
27 "A.to_str()".to_string()
31 // Should not be detected as it is a free function
32 fn to_string() -> String {
33 "free to_string()".to_string()
37 // Should not be detected, wrong return type
38 fn to_string(&self) -> i32 {
44 // Should be detected and emit error as C also implements Display
45 fn to_string(&self) -> String {
46 "C.to_string()".to_string()
50 impl fmt::Display for C {
51 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
52 write!(f, "impl Display for C")
56 impl FalsePositive for D {
57 // Should not be detected, as it is a trait function
58 fn to_string(&self) -> String {
59 "impl FalsePositive for D".to_string()
64 // Should not be detected, as it is not bound to an instance
65 fn to_string() -> String {
66 "E::to_string()".to_string()
71 // Should not be detected, as it does not match the function signature
72 fn to_string(&self, _i: i32) -> String {
73 "F.to_string()".to_string()
78 // Should not be detected, as it does not match the function signature
79 fn to_string<const _N: usize>(&self) -> String {
80 "G.to_string()".to_string()