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