]>
Commit | Line | Data |
---|---|---|
3dfed10e XL |
1 | // run-rustfix |
2 | #![allow(dead_code)] | |
3 | ||
4 | mod foo { | |
5 | trait OtherTrait<'a> {} | |
6 | impl<'a> OtherTrait<'a> for &'a () {} | |
7 | ||
8 | trait ObjectTrait<T> {} | |
9 | trait MyTrait<T> { | |
10 | fn use_self<K>(&self) -> &(); | |
11 | } | |
12 | trait Irrelevant {} | |
13 | ||
14 | impl<T> MyTrait<T> for dyn ObjectTrait<T> + '_ { | |
15 | fn use_self<K>(&self) -> &() { panic!() } | |
16 | } | |
17 | impl<T> Irrelevant for dyn ObjectTrait<T> {} | |
18 | ||
19 | fn use_it<'a, T>(val: &'a dyn ObjectTrait<T>) -> impl OtherTrait<'a> + 'a { | |
20 | val.use_self::<T>() //~ ERROR E0759 | |
21 | } | |
22 | } | |
23 | ||
24 | mod bar { | |
25 | trait ObjectTrait {} | |
26 | trait MyTrait { | |
27 | fn use_self(&self) -> &(); | |
28 | } | |
29 | trait Irrelevant {} | |
30 | ||
31 | impl MyTrait for dyn ObjectTrait + '_ { | |
32 | fn use_self(&self) -> &() { panic!() } | |
33 | } | |
34 | impl Irrelevant for dyn ObjectTrait {} | |
35 | ||
36 | fn use_it<'a>(val: &'a dyn ObjectTrait) -> &'a () { | |
37 | val.use_self() //~ ERROR E0772 | |
38 | } | |
39 | } | |
40 | ||
41 | mod baz { | |
42 | trait ObjectTrait {} | |
43 | trait MyTrait { | |
44 | fn use_self(&self) -> &(); | |
45 | } | |
46 | trait Irrelevant {} | |
47 | ||
48 | impl MyTrait for Box<dyn ObjectTrait + '_> { | |
49 | fn use_self(&self) -> &() { panic!() } | |
50 | } | |
51 | impl Irrelevant for Box<dyn ObjectTrait> {} | |
52 | ||
53 | fn use_it<'a>(val: &'a Box<dyn ObjectTrait + 'a>) -> &'a () { | |
54 | val.use_self() //~ ERROR E0772 | |
55 | } | |
56 | } | |
57 | ||
58 | mod bat { | |
59 | trait OtherTrait<'a> {} | |
60 | impl<'a> OtherTrait<'a> for &'a () {} | |
61 | ||
62 | trait ObjectTrait {} | |
63 | ||
64 | impl dyn ObjectTrait + '_ { | |
65 | fn use_self(&self) -> &() { panic!() } | |
66 | } | |
67 | ||
68 | fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a { | |
69 | val.use_self() //~ ERROR E0772 | |
70 | } | |
71 | } | |
72 | ||
73 | mod ban { | |
74 | trait OtherTrait<'a> {} | |
75 | impl<'a> OtherTrait<'a> for &'a () {} | |
76 | ||
77 | trait ObjectTrait {} | |
78 | trait MyTrait { | |
79 | fn use_self(&self) -> &() { panic!() } | |
80 | } | |
81 | trait Irrelevant { | |
82 | fn use_self(&self) -> &() { panic!() } | |
83 | } | |
84 | ||
85 | impl MyTrait for dyn ObjectTrait + '_ {} | |
86 | ||
87 | fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a { | |
88 | val.use_self() //~ ERROR E0759 | |
89 | } | |
90 | } | |
91 | ||
92 | mod bal { | |
93 | trait OtherTrait<'a> {} | |
94 | impl<'a> OtherTrait<'a> for &'a () {} | |
95 | ||
96 | trait ObjectTrait {} | |
97 | trait MyTrait { | |
98 | fn use_self(&self) -> &() { panic!() } | |
99 | } | |
100 | trait Irrelevant { | |
101 | fn use_self(&self) -> &() { panic!() } | |
102 | } | |
103 | ||
104 | impl MyTrait for dyn ObjectTrait + '_ {} | |
105 | impl Irrelevant for dyn ObjectTrait {} | |
106 | ||
107 | fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a { | |
108 | MyTrait::use_self(val) //~ ERROR E0759 | |
109 | } | |
110 | } | |
111 | ||
112 | fn main() {} |