1 #![warn(clippy::inherent_to_string)]
2 //#![deny(clippy::inherent_to_string_shadow)]
7 fn to_string(&self) -> String;
17 // Should be detected; emit warning
18 fn to_string(&self) -> String {
19 "A.to_string()".to_string()
22 // Should not be detected as it does not match the function signature
23 fn to_str(&self) -> String {
24 "A.to_str()".to_string()
28 // Should not be detected as it is a free function
29 fn to_string() -> String {
30 "free to_string()".to_string()
34 // Should not be detected, wrong return type
35 fn to_string(&self) -> i32 {
41 // Should be detected and emit error as C also implements Display
42 fn to_string(&self) -> String {
43 "C.to_string()".to_string()
47 impl fmt::Display for C {
48 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
49 write!(f, "impl Display for C")
53 impl FalsePositive for D {
54 // Should not be detected, as it is a trait function
55 fn to_string(&self) -> String {
56 "impl FalsePositive for D".to_string()
61 // Should not be detected, as it is not bound to an instance
62 fn to_string() -> String {
63 "E::to_string()".to_string()