Add more tests
This commit is contained in:
parent
f2241f640b
commit
c93bce85e5
4 changed files with 92 additions and 0 deletions
|
|
@ -0,0 +1,16 @@
|
|||
#![feature(existential_type)]
|
||||
|
||||
use std::fmt::Debug;
|
||||
|
||||
fn main() {}
|
||||
|
||||
existential type Two<T, U>: Debug;
|
||||
|
||||
fn two<T: Debug, U: Debug>(t: T, _: U) -> Two<T, U> {
|
||||
(t, 4u32)
|
||||
}
|
||||
|
||||
fn three<T: Debug, U: Debug>(_: T, u: U) -> Two<T, U> {
|
||||
//~^ concrete type differs from previous
|
||||
(u, 4u32)
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
error: concrete type differs from previous defining existential type use
|
||||
--> $DIR/generic_duplicate_param_use8.rs:13:1
|
||||
|
|
||||
LL | / fn three<T: Debug, U: Debug>(_: T, u: U) -> Two<T, U> {
|
||||
LL | | //~^ concrete type differs from previous
|
||||
LL | | (u, 4u32)
|
||||
LL | | }
|
||||
| |_^ expected `(T, u32)`, got `(U, u32)`
|
||||
|
|
||||
note: previous use here
|
||||
--> $DIR/generic_duplicate_param_use8.rs:9:1
|
||||
|
|
||||
LL | / fn two<T: Debug, U: Debug>(t: T, _: U) -> Two<T, U> {
|
||||
LL | | (t, 4u32)
|
||||
LL | | }
|
||||
| |_^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
39
src/test/ui/existential_types/not_a_defining_use.rs
Normal file
39
src/test/ui/existential_types/not_a_defining_use.rs
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
#![feature(existential_type)]
|
||||
|
||||
use std::fmt::Debug;
|
||||
|
||||
fn main() {}
|
||||
|
||||
existential type Two<T, U>: Debug;
|
||||
|
||||
fn two<T: Debug>(t: T) -> Two<T, u32> {
|
||||
(t, 4i8)
|
||||
}
|
||||
|
||||
fn three<T: Debug, U>(t: T) -> Two<T, U> {
|
||||
(t, 5i8)
|
||||
}
|
||||
|
||||
trait Bar {
|
||||
type Blub: Debug;
|
||||
const FOO: Self::Blub;
|
||||
}
|
||||
|
||||
impl Bar for u32 {
|
||||
type Blub = i32;
|
||||
const FOO: i32 = 42;
|
||||
}
|
||||
|
||||
// this should work! But it requires `two` and `three` not to be defining uses,
|
||||
// just restricting uses
|
||||
fn four<T: Debug, U: Bar>(t: T) -> Two<T, U> { //~ concrete type differs from previous
|
||||
(t, <U as Bar>::FOO)
|
||||
}
|
||||
|
||||
fn is_sync<T: Sync>() {}
|
||||
|
||||
fn asdfl() {
|
||||
//FIXME(oli-obk): these currently cause cycle errors
|
||||
//is_sync::<Two<i32, u32>>();
|
||||
//is_sync::<Two<i32, *const i32>>();
|
||||
}
|
||||
18
src/test/ui/existential_types/not_a_defining_use.stderr
Normal file
18
src/test/ui/existential_types/not_a_defining_use.stderr
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
error: concrete type differs from previous defining existential type use
|
||||
--> $DIR/not_a_defining_use.rs:29:1
|
||||
|
|
||||
LL | / fn four<T: Debug, U: Bar>(t: T) -> Two<T, U> { //~ concrete type differs from previous
|
||||
LL | | (t, <U as Bar>::FOO)
|
||||
LL | | }
|
||||
| |_^ expected `(T, i8)`, got `(T, <U as Bar>::Blub)`
|
||||
|
|
||||
note: previous use here
|
||||
--> $DIR/not_a_defining_use.rs:9:1
|
||||
|
|
||||
LL | / fn two<T: Debug>(t: T) -> Two<T, u32> {
|
||||
LL | | (t, 4i8)
|
||||
LL | | }
|
||||
| |_^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue