forked from rust-lang/chalk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathopaque_types.rs
100 lines (82 loc) · 1.71 KB
/
opaque_types.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
use super::*;
#[test]
fn opaque_bounds() {
test! {
program {
struct Ty { }
trait Clone { }
opaque type T: Clone = Ty;
}
goal {
T: Clone
} yields {
"Unique; substitution []"
}
}
}
#[test]
fn opaque_reveal() {
test! {
program {
struct Ty { }
trait Trait { }
impl Trait for Ty { }
trait Clone { }
opaque type T: Clone = Ty;
}
goal {
if (Reveal) {
T: Trait
}
} yields {
"Unique; substitution []"
}
goal {
T: Trait
} yields {
"No possible solution"
}
}
}
#[test]
fn opaque_generics_simple() {
test! {
program {
trait Iterator { type Item; }
struct Vec<T> { }
struct Bar { }
impl<T> Iterator for Vec<T> {
type Item = u32;
}
opaque type Foo<X>: Iterator = Vec<X>;
}
goal {
Foo<Bar>: Iterator
} yields {
"Unique; substitution []"
}
}
}
#[test]
fn opaque_generics() {
test! {
program {
trait Iterator { type Item; }
struct Vec<T> { }
struct Bar { }
opaque type Foo<X>: Iterator<Item = X> = Vec<X>;
}
goal {
Foo<Bar>: Iterator<Item = Bar>
} yields {
"Unique; substitution []"
}
goal {
forall<T> {
Foo<T>: Iterator<Item = T>
}
} yields {
"Unique; substitution []"
}
}
}