diff options
4 files changed, 92 insertions, 0 deletions
diff --git a/src/test/ui/existential_types/generic_duplicate_param_use8.rs b/src/test/ui/existential_types/generic_duplicate_param_use8.rs new file mode 100644 index 00000000000..83501ad8c41 --- /dev/null +++ b/src/test/ui/existential_types/generic_duplicate_param_use8.rs @@ -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) +} diff --git a/src/test/ui/existential_types/generic_duplicate_param_use8.stderr b/src/test/ui/existential_types/generic_duplicate_param_use8.stderr new file mode 100644 index 00000000000..80c7441c857 --- /dev/null +++ b/src/test/ui/existential_types/generic_duplicate_param_use8.stderr @@ -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 + diff --git a/src/test/ui/existential_types/not_a_defining_use.rs b/src/test/ui/existential_types/not_a_defining_use.rs new file mode 100644 index 00000000000..413cc6788c2 --- /dev/null +++ b/src/test/ui/existential_types/not_a_defining_use.rs @@ -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>>(); +} diff --git a/src/test/ui/existential_types/not_a_defining_use.stderr b/src/test/ui/existential_types/not_a_defining_use.stderr new file mode 100644 index 00000000000..a6ed5dbe0a9 --- /dev/null +++ b/src/test/ui/existential_types/not_a_defining_use.stderr @@ -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 + |
