]> git.lizzy.rs Git - rust.git/blob - tests/ui/same_name_method.rs
removing unsafe from test fn's && renaming shrink to sugg_span
[rust.git] / tests / ui / same_name_method.rs
1 #![warn(clippy::same_name_method)]
2 #![allow(dead_code, non_camel_case_types)]
3
4 trait T1 {
5     fn foo() {}
6 }
7
8 trait T2 {
9     fn foo() {}
10 }
11
12 mod should_lint {
13
14     mod test_basic_case {
15         use crate::T1;
16
17         struct S;
18
19         impl S {
20             fn foo() {}
21         }
22
23         impl T1 for S {
24             fn foo() {}
25         }
26     }
27
28     mod test_derive {
29
30         #[derive(Clone)]
31         struct S;
32
33         impl S {
34             fn clone() {}
35         }
36     }
37
38     mod with_generic {
39         use crate::T1;
40
41         struct S<U>(U);
42
43         impl<U> S<U> {
44             fn foo() {}
45         }
46
47         impl<U: Copy> T1 for S<U> {
48             fn foo() {}
49         }
50     }
51
52     mod default_method {
53         use crate::T1;
54
55         struct S;
56
57         impl S {
58             fn foo() {}
59         }
60
61         impl T1 for S {}
62     }
63
64     mod mulitply_conflicit_trait {
65         use crate::{T1, T2};
66
67         struct S;
68
69         impl S {
70             fn foo() {}
71         }
72
73         impl T1 for S {}
74
75         impl T2 for S {}
76     }
77 }
78
79 mod should_not_lint {
80
81     mod not_lint_two_trait_method {
82         use crate::{T1, T2};
83
84         struct S;
85
86         impl T1 for S {
87             fn foo() {}
88         }
89
90         impl T2 for S {
91             fn foo() {}
92         }
93     }
94
95     mod only_lint_on_method {
96         trait T3 {
97             type foo;
98         }
99
100         struct S;
101
102         impl S {
103             fn foo() {}
104         }
105         impl T3 for S {
106             type foo = usize;
107         }
108     }
109 }
110
111 fn main() {}