]> git.lizzy.rs Git - rust.git/blob - tests/compile-fail/new_without_default.rs
30015f6c9e8bd83d72cab54ae1945e8065e534e4
[rust.git] / tests / compile-fail / new_without_default.rs
1 #![feature(plugin)]
2 #![plugin(clippy)]
3
4 #![allow(dead_code)]
5 #![deny(new_without_default)]
6
7 struct Foo;
8
9 impl Foo {
10     fn new() -> Foo { Foo } //~ERROR: you should consider adding a `Default` implementation for `Foo`
11 }
12
13 struct Bar;
14
15 impl Bar {
16     fn new() -> Self { Bar } //~ERROR: you should consider adding a `Default` implementation for `Bar`
17 }
18
19 struct Ok;
20
21 impl Ok {
22     fn new() -> Self { Ok }
23 }
24
25 impl Default for Ok {
26     fn default() -> Self { Ok }
27 }
28
29 struct Params;
30
31 impl Params {
32     fn new(_: u32) -> Self { Params }
33 }
34
35 struct GenericsOk<T> {
36     bar: T,
37 }
38
39 impl<U> Default for GenericsOk<U> {
40     fn default() -> Self { unimplemented!(); }
41 }
42
43 impl<'c, V> GenericsOk<V> {
44     fn new() -> GenericsOk<V> { unimplemented!() }
45 }
46
47 struct LtOk<'a> {
48     foo: &'a bool,
49 }
50
51 impl<'b> Default for LtOk<'b> {
52     fn default() -> Self { unimplemented!(); }
53 }
54
55 impl<'c> LtOk<'c> {
56     fn new() -> LtOk<'c> { unimplemented!() }
57 }
58
59 struct LtKo<'a> {
60     foo: &'a bool,
61 }
62
63 impl<'c> LtKo<'c> {
64     fn new() -> LtKo<'c> { unimplemented!() } //~ERROR: you should consider adding a `Default` implementation for
65 }
66
67 fn main() {}