Skip to content

Commit 5e5e4b1

Browse files
committed
Add basic tests for opaque type generics
1 parent 97a84ca commit 5e5e4b1

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

tests/test/opaque_types.rs

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,56 @@ fn opaque_reveal() {
4545
}
4646
}
4747
}
48+
49+
#[test]
50+
fn opaque_generics_simple() {
51+
test! {
52+
program {
53+
trait Iterator { type Item; }
54+
55+
struct Vec<T> { }
56+
struct Bar { }
57+
impl<T> Iterator for Vec<T> {
58+
type Item = u32;
59+
}
60+
61+
opaque type Foo<X>: Iterator = Vec<X>;
62+
}
63+
64+
goal {
65+
Foo<Bar>: Iterator
66+
} yields {
67+
"Unique; substitution []"
68+
}
69+
70+
}
71+
}
72+
73+
#[test]
74+
fn opaque_generics() {
75+
test! {
76+
program {
77+
trait Iterator { type Item; }
78+
79+
struct Vec<T> { }
80+
struct Bar { }
81+
82+
opaque type Foo<X>: Iterator<Item = X> = Vec<X>;
83+
}
84+
85+
goal {
86+
Foo<Bar>: Iterator<Item = Bar>
87+
} yields {
88+
"Unique; substitution []"
89+
}
90+
91+
goal {
92+
forall<T> {
93+
Foo<T>: Iterator<Item = T>
94+
}
95+
} yields {
96+
"Unique; substitution []"
97+
}
98+
99+
}
100+
}

0 commit comments

Comments
 (0)