]> git.lizzy.rs Git - rust.git/blob - src/test/ui/traits/elaborate-type-region.rs
:arrow_up: rust-analyzer
[rust.git] / src / test / ui / traits / elaborate-type-region.rs
1 // run-pass
2 #![allow(dead_code)]
3
4 // Test that we elaborate `Type: 'region` constraints and infer various important things.
5
6 trait Master<'a, T: ?Sized> {
7     fn foo() where T: 'a;
8 }
9
10 // [U]: 'a => U: 'a
11 impl<'a, U> Master<'a, [U]> for () {
12     fn foo() where U: 'a { }
13 }
14
15 // &'b U: 'a => 'b: 'a, U: 'a
16 impl<'a, 'b, U> Master<'a, &'b U> for () {
17     fn foo() where 'b: 'a, U: 'a { }
18 }
19
20 // &'b [U]: 'a => 'b: 'a, U: 'a
21 impl<'a, 'b, U> Master<'a, &'b [U]> for () {
22     fn foo() where 'b: 'a, U: 'a { }
23 }
24
25 // Foo<'b>: 'a => 'b: 'a
26 struct Foo<'a> { x: &'a () }
27 impl<'a, 'b> Master<'a, Foo<'b>> for () {
28     fn foo() where 'b: 'a { }
29 }
30
31 // Bar<'b, T>: 'a => 'b: 'a, T: 'a
32 struct Bar<'a, T: 'a> { x: &'a T }
33 impl<'a, 'b, T> Master<'a, Bar<'b, T>> for () {
34     fn foo() where 'b: 'a, T: 'a { }
35 }
36
37 // fn(T): 'a => T: 'a
38 impl<'a, T> Master<'a, fn(T)> for () {
39     fn foo() where T: 'a { }
40 }
41
42 // fn() -> T: 'a => T: 'a
43 impl<'a, T> Master<'a, fn() -> T> for () {
44     fn foo() where T: 'a { }
45 }
46
47 fn main() {
48     println!("Hello, world!");
49 }