]> git.lizzy.rs Git - rust.git/blob - src/test/ui/associated-types/associated-types-subtyping-1.rs
Rollup merge of #53317 - estebank:abolish-ice, r=oli-obk
[rust.git] / src / test / ui / associated-types / associated-types-subtyping-1.rs
1 // Copyright 2015 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 // ignore-compare-mode-nll
12
13 #![allow(unused_variables)]
14
15 trait Trait<'a> {
16     type Type;
17
18     fn method(&'a self) { }
19 }
20
21 fn method1<'a,'b,T>(x: &'a T, y: &'b T)
22     where T : for<'z> Trait<'z>, 'a : 'b
23 {
24     // Note that &'static T <: &'a T.
25     let a: <T as Trait<'a>>::Type = loop { };
26     let b: <T as Trait<'b>>::Type = loop { };
27     let _c: <T as Trait<'a>>::Type = a;
28 }
29
30 fn method2<'a,'b,T>(x: &'a T, y: &'b T)
31     where T : for<'z> Trait<'z>, 'a : 'b
32 {
33     // Note that &'static T <: &'a T.
34     let a: <T as Trait<'a>>::Type = loop { };
35     let b: <T as Trait<'b>>::Type = loop { };
36     let _c: <T as Trait<'b>>::Type = a; //~ ERROR E0623
37 }
38
39 fn method3<'a,'b,T>(x: &'a T, y: &'b T)
40     where T : for<'z> Trait<'z>, 'a : 'b
41 {
42     // Note that &'static T <: &'a T.
43     let a: <T as Trait<'a>>::Type = loop { };
44     let b: <T as Trait<'b>>::Type = loop { };
45     let _c: <T as Trait<'a>>::Type = b; //~ ERROR E0623
46 }
47
48 fn method4<'a,'b,T>(x: &'a T, y: &'b T)
49     where T : for<'z> Trait<'z>, 'a : 'b
50 {
51     // Note that &'static T <: &'a T.
52     let a: <T as Trait<'a>>::Type = loop { };
53     let b: <T as Trait<'b>>::Type = loop { };
54     let _c: <T as Trait<'b>>::Type = b;
55 }
56
57 fn main() { }