]> git.lizzy.rs Git - rust.git/blob - src/test/ui/traits/impl-of-supertrait-has-wrong-lifetime-parameters.rs
Auto merge of #84959 - camsteffen:lint-suggest-group, r=estebank
[rust.git] / src / test / ui / traits / impl-of-supertrait-has-wrong-lifetime-parameters.rs
1 // Check that when we test the supertrait we ensure consistent use of
2 // lifetime parameters. In this case, implementing T2<'a,'b> requires
3 // an impl of T1<'a>, but we have an impl of T1<'b>.
4
5 trait T1<'x> {
6     fn x(&self) -> &'x isize;
7 }
8
9 trait T2<'x, 'y> : T1<'x> {
10     fn y(&self) -> &'y isize;
11 }
12
13 struct S<'a, 'b> {
14     a: &'a isize,
15     b: &'b isize
16 }
17
18 impl<'a,'b> T1<'b> for S<'a, 'b> {
19     fn x(&self) -> &'b isize {
20         self.b
21     }
22 }
23
24 impl<'a,'b> T2<'a, 'b> for S<'a, 'b> { //~ ERROR cannot infer an appropriate lifetime
25     fn y(&self) -> &'b isize {
26         self.b
27     }
28 }
29
30 pub fn main() {
31 }