]> git.lizzy.rs Git - rust.git/blob - src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs
Change error code number
[rust.git] / src / test / ui / suggestions / impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs
1 // FIXME: the following cases need to suggest more things to make users reach a working end state.
2
3 mod bav {
4     trait OtherTrait<'a> {}
5     impl<'a> OtherTrait<'a> for &'a () {}
6
7     trait ObjectTrait {
8         type Assoc: Bar;
9     }
10     trait MyTrait {
11         fn use_self(&self) -> &() { panic!() }
12     }
13     trait Bar {}
14
15     impl MyTrait for Box<dyn ObjectTrait<Assoc = i32>> {
16         fn use_self(&self) -> &() { panic!() }
17     }
18     impl Bar for i32 {}
19
20     fn use_it<'a>(val: Box<dyn ObjectTrait<Assoc = i32>>) -> impl OtherTrait<'a> {
21         val.use_self() //~ ERROR E0597
22     }
23 }
24
25 mod bap {
26     trait OtherTrait<'a> {}
27     impl<'a> OtherTrait<'a> for &'a () {}
28
29     trait ObjectTrait {
30         type Assoc: Bar;
31     }
32     trait MyTrait {
33         fn use_self(&self) -> &() { panic!() }
34     }
35     trait Bar {}
36
37     impl MyTrait for Box<dyn ObjectTrait<Assoc = i32>> {
38         fn use_self(&self) -> &() { panic!() }
39     }
40     impl Bar for i32 {}
41
42     fn use_it<'a>(val: Box<dyn ObjectTrait<Assoc = i32>>) -> impl OtherTrait<'a> + 'a {
43         val.use_self() //~ ERROR E0515
44     }
45 }
46
47 // This case in particular requires the user to write all of the bounds we have in `mod bax`.
48 mod bay {
49     trait OtherTrait<'a> {}
50     impl<'a> OtherTrait<'a> for &'a () {}
51
52     trait ObjectTrait {
53         type Assoc: Bar;
54     }
55     trait MyTrait {
56         fn use_self(&self) -> &() { panic!() }
57     }
58     trait Bar {}
59
60     impl MyTrait for Box<dyn ObjectTrait<Assoc = i32>> {
61         fn use_self(&self) -> &() { panic!() }
62     }
63     impl Bar for i32 {}
64
65     fn use_it<'a>(val: Box<dyn ObjectTrait<Assoc = i32> + 'a>) -> &'a () {
66         val.use_self() //~ ERROR E0772
67     }
68 }
69
70 mod bax {
71     trait OtherTrait<'a> {}
72     impl<'a> OtherTrait<'a> for &'a () {}
73
74     trait ObjectTrait {
75         type Assoc: Bar;
76     }
77     trait MyTrait<'a> {
78         fn use_self(&'a self) -> &'a () { panic!() }
79     }
80     trait Bar {}
81
82     impl<'a> MyTrait<'a> for Box<dyn ObjectTrait<Assoc = i32> + 'a> {
83         fn use_self(&'a self) -> &'a () { panic!() }
84     }
85     impl Bar for i32 {}
86
87     fn use_it<'a>(val: Box<dyn ObjectTrait<Assoc = i32> + 'a>) -> &'a () {
88         val.use_self()
89     }
90 }
91
92 mod baw {
93     trait OtherTrait<'a> {}
94     impl<'a> OtherTrait<'a> for &'a () {}
95
96     trait ObjectTrait {
97         type Assoc: Bar;
98     }
99     trait MyTrait {
100         fn use_self(&self) -> &() { panic!() }
101     }
102     trait Bar {}
103
104     impl<'a> MyTrait for Box<dyn ObjectTrait<Assoc = Box<dyn Bar>>> {
105         fn use_self(&self) -> &() { panic!() }
106     }
107
108     fn use_it<'a>(val: Box<dyn ObjectTrait<Assoc = Box<dyn Bar>>>) -> impl OtherTrait<'a> + 'a{
109         val.use_self() //~ ERROR E0515
110     }
111 }
112
113 fn main() {}