-
Notifications
You must be signed in to change notification settings - Fork 32
/
elaborate-type-region.rs
64 lines (53 loc) · 1.35 KB
/
elaborate-type-region.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//@ run-pass
#![allow(dead_code)]
// Test that we elaborate `Type: 'region` constraints and infer various important things.
trait Master<'a, T: ?Sized> {
fn foo() where T: 'a;
}
// [U]: 'a => U: 'a
impl<'a, U> Master<'a, [U]> for () {
fn foo() where U: 'a { }
}
// &'b U: 'a => 'b: 'a, U: 'a
impl<'a, 'b, U> Master<'a, &'b U> for () {
fn foo() where 'b: 'a, U: 'a { }
}
// &'b [U]: 'a => 'b: 'a, U: 'a
impl<'a, 'b, U> Master<'a, &'b [U]> for () {
fn foo() where 'b: 'a, U: 'a { }
}
// Foo<'b>: 'a => 'b: 'a
struct Foo<'a> { x: &'a () }
impl<'a, 'b> Master<'a, Foo<'b>> for () {
fn foo() where 'b: 'a { }
}
// Bar<'b, T>: 'a => 'b: 'a, T: 'a
struct Bar<'a, T: 'a> { x: &'a T }
impl<'a, 'b, T> Master<'a, Bar<'b, T>> for () {
fn foo() where 'b: 'a, T: 'a { }
}
// fn(T): 'a => T: 'a
impl<'a, T> Master<'a, fn(T)> for () {
fn foo() where T: 'a { }
}
// fn() -> T: 'a => T: 'a
impl<'a, T> Master<'a, fn() -> T> for () {
fn foo() where T: 'a { }
}
fn main() {
println!("Hello, world!");
}
// ferrocene-annotations: fls_ikfvbeewame7
// Subtyping and Variance
//
// ferrocene-annotations: fls_exe4zodlwfez
// Type Unification
//
// ferrocene-annotations: fls_jeoas4n6su4
// Trait and Lifetime Bounds
//
// ferrocene-annotations: fls_fk2m2irwpeof
// Implementations
//
// ferrocene-annotations: fls_e1pgdlv81vul
// Implementation Conformance