]> git.lizzy.rs Git - rust.git/blob - tests/ui/new_ret_no_self.rs
new_ret_no_self corrected panic and added test stderr
[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 T;
39
40 impl T {
41     // should not trigger lint
42     pub fn new() -> Self {
43         unimplemented!();
44     }
45 }
46
47 struct U;
48
49 impl U {
50     // should trigger lint
51     pub fn new() -> u32 {
52         unimplemented!();
53     }
54 }
55
56 struct V;
57
58 impl V {
59     // should trigger lint
60     pub fn new(_: String) -> u32 {
61         unimplemented!();
62     }
63 }