]> git.lizzy.rs Git - rust.git/blob - tests/ui/new_ret_no_self.rs
new_ret_no_self fix false positive for impl trait return with associated type self
[rust.git] / tests / ui / new_ret_no_self.rs
1 #![feature(tool_lints)]
2
3 #![warn(clippy::new_ret_no_self)]
4 #![allow(dead_code, clippy::trivially_copy_pass_by_ref)]
5
6 fn main(){}
7
8 trait R {
9     type Item;
10 }
11
12 struct S;
13
14 impl R for S {
15     type Item = Self;
16 }
17
18 impl S {
19     // should not trigger the lint
20     pub fn new() -> impl R<Item = Self> {
21         S
22     }
23 }
24
25 struct S2;
26
27 impl R for S2 {
28     type Item = Self;
29 }
30
31 impl S2 {
32     // should not trigger the lint
33     pub fn new(_: String) -> impl R<Item = Self> {
34         S2
35     }
36 }
37
38 struct S3;
39
40 impl R for S3 {
41     type Item = u32;
42 }
43
44 impl S3 {
45     // should trigger the lint, but currently does not
46     pub fn new(_: String) -> impl R<Item = u32> {
47         S3
48     }
49 }
50
51 struct T;
52
53 impl T {
54     // should not trigger lint
55     pub fn new() -> Self {
56         unimplemented!();
57     }
58 }
59
60 struct U;
61
62 impl U {
63     // should trigger lint
64     pub fn new() -> u32 {
65         unimplemented!();
66     }
67 }
68
69 struct V;
70
71 impl V {
72     // should trigger lint
73     pub fn new(_: String) -> u32 {
74         unimplemented!();
75     }
76 }