]> git.lizzy.rs Git - rust.git/blob - tests/ui/new_ret_no_self.rs
new_ret_no_self test remove tool lints cfg flag
[rust.git] / tests / ui / new_ret_no_self.rs
1 #![warn(clippy::new_ret_no_self)]
2 #![allow(dead_code, clippy::trivially_copy_pass_by_ref)]
3
4 fn main(){}
5
6 trait R {
7     type Item;
8 }
9
10 trait Q {
11     type Item;
12     type Item2;
13 }
14
15 struct S;
16
17 impl R for S {
18     type Item = Self;
19 }
20
21 impl S {
22     // should not trigger the lint
23     pub fn new() -> impl R<Item = Self> {
24         S
25     }
26 }
27
28 struct S2;
29
30 impl R for S2 {
31     type Item = Self;
32 }
33
34 impl S2 {
35     // should not trigger the lint
36     pub fn new(_: String) -> impl R<Item = Self> {
37         S2
38     }
39 }
40
41 struct S3;
42
43 impl R for S3 {
44     type Item = u32;
45 }
46
47 impl S3 {
48     // should trigger the lint
49     pub fn new(_: String) -> impl R<Item = u32> {
50         S3
51     }
52 }
53
54 struct S4;
55
56 impl Q for S4 {
57     type Item = u32;
58     type Item2 = Self;
59 }
60
61 impl S4 {
62     // should not trigger the lint
63     pub fn new(_: String) -> impl Q<Item = u32, Item2 = Self> {
64         S4
65     }
66 }
67
68 struct T;
69
70 impl T {
71     // should not trigger lint
72     pub fn new() -> Self {
73         unimplemented!();
74     }
75 }
76
77 struct U;
78
79 impl U {
80     // should trigger lint
81     pub fn new() -> u32 {
82         unimplemented!();
83     }
84 }
85
86 struct V;
87
88 impl V {
89     // should trigger lint
90     pub fn new(_: String) -> u32 {
91         unimplemented!();
92     }
93 }