Skip to content

Commit c93bce8

Browse files
committed
Add more tests
1 parent f2241f6 commit c93bce8

File tree

4 files changed

+92
-0
lines changed

4 files changed

+92
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#![feature(existential_type)]
2+
3+
use std::fmt::Debug;
4+
5+
fn main() {}
6+
7+
existential type Two<T, U>: Debug;
8+
9+
fn two<T: Debug, U: Debug>(t: T, _: U) -> Two<T, U> {
10+
(t, 4u32)
11+
}
12+
13+
fn three<T: Debug, U: Debug>(_: T, u: U) -> Two<T, U> {
14+
//~^ concrete type differs from previous
15+
(u, 4u32)
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
error: concrete type differs from previous defining existential type use
2+
--> $DIR/generic_duplicate_param_use8.rs:13:1
3+
|
4+
LL | / fn three<T: Debug, U: Debug>(_: T, u: U) -> Two<T, U> {
5+
LL | | //~^ concrete type differs from previous
6+
LL | | (u, 4u32)
7+
LL | | }
8+
| |_^ expected `(T, u32)`, got `(U, u32)`
9+
|
10+
note: previous use here
11+
--> $DIR/generic_duplicate_param_use8.rs:9:1
12+
|
13+
LL | / fn two<T: Debug, U: Debug>(t: T, _: U) -> Two<T, U> {
14+
LL | | (t, 4u32)
15+
LL | | }
16+
| |_^
17+
18+
error: aborting due to previous error
19+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#![feature(existential_type)]
2+
3+
use std::fmt::Debug;
4+
5+
fn main() {}
6+
7+
existential type Two<T, U>: Debug;
8+
9+
fn two<T: Debug>(t: T) -> Two<T, u32> {
10+
(t, 4i8)
11+
}
12+
13+
fn three<T: Debug, U>(t: T) -> Two<T, U> {
14+
(t, 5i8)
15+
}
16+
17+
trait Bar {
18+
type Blub: Debug;
19+
const FOO: Self::Blub;
20+
}
21+
22+
impl Bar for u32 {
23+
type Blub = i32;
24+
const FOO: i32 = 42;
25+
}
26+
27+
// this should work! But it requires `two` and `three` not to be defining uses,
28+
// just restricting uses
29+
fn four<T: Debug, U: Bar>(t: T) -> Two<T, U> { //~ concrete type differs from previous
30+
(t, <U as Bar>::FOO)
31+
}
32+
33+
fn is_sync<T: Sync>() {}
34+
35+
fn asdfl() {
36+
//FIXME(oli-obk): these currently cause cycle errors
37+
//is_sync::<Two<i32, u32>>();
38+
//is_sync::<Two<i32, *const i32>>();
39+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
error: concrete type differs from previous defining existential type use
2+
--> $DIR/not_a_defining_use.rs:29:1
3+
|
4+
LL | / fn four<T: Debug, U: Bar>(t: T) -> Two<T, U> { //~ concrete type differs from previous
5+
LL | | (t, <U as Bar>::FOO)
6+
LL | | }
7+
| |_^ expected `(T, i8)`, got `(T, <U as Bar>::Blub)`
8+
|
9+
note: previous use here
10+
--> $DIR/not_a_defining_use.rs:9:1
11+
|
12+
LL | / fn two<T: Debug>(t: T) -> Two<T, u32> {
13+
LL | | (t, 4i8)
14+
LL | | }
15+
| |_^
16+
17+
error: aborting due to previous error
18+

0 commit comments

Comments
 (0)