]> git.lizzy.rs Git - rust.git/blob - src/test/compile-fail/trait-impl-of-supertrait-has-wrong-lifetime-parameters.rs
Update compile fail tests to use isize.
[rust.git] / src / test / compile-fail / trait-impl-of-supertrait-has-wrong-lifetime-parameters.rs
1 // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 // Check that when we test the supertrait we ensure consistent use of
12 // lifetime parameters. In this case, implementing T2<'a,'b> requires
13 // an impl of T1<'a>, but we have an impl of T1<'b>.
14
15 trait T1<'x> {
16     fn x(&self) -> &'x isize;
17 }
18
19 trait T2<'x, 'y> : T1<'x> {
20     fn y(&self) -> &'y isize;
21 }
22
23 struct S<'a, 'b> {
24     a: &'a isize,
25     b: &'b isize
26 }
27
28 impl<'a,'b> T1<'b> for S<'a, 'b> {
29     fn x(&self) -> &'b isize {
30         self.b
31     }
32 }
33
34 impl<'a,'b> T2<'a, 'b> for S<'a, 'b> { //~ ERROR cannot infer an appropriate lifetime
35     fn y(&self) -> &'b isize {
36         self.b
37     }
38 }
39
40 pub fn main() {
41 }