Restrict concrete types to equivalent types
This commit is contained in:
parent
cf01b514c8
commit
6f83dcc192
25 changed files with 264 additions and 33 deletions
|
|
@ -9,6 +9,6 @@ fn foo() -> Foo {
|
|||
""
|
||||
}
|
||||
|
||||
fn bar() -> Foo { //~ ERROR defining existential type use differs from previous
|
||||
fn bar() -> Foo { //~ ERROR concrete type differs from previous
|
||||
42i32
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
error: defining existential type use differs from previous
|
||||
error: concrete type differs from previous defining existential type use
|
||||
--> $DIR/different_defining_uses.rs:12:1
|
||||
|
|
||||
LL | / fn bar() -> Foo { //~ ERROR defining existential type use differs from previous
|
||||
LL | / fn bar() -> Foo { //~ ERROR concrete type differs from previous
|
||||
LL | | 42i32
|
||||
LL | | }
|
||||
| |_^
|
||||
|
|
|
|||
|
|
@ -9,10 +9,10 @@ fn foo() -> Foo {
|
|||
""
|
||||
}
|
||||
|
||||
fn bar() -> Foo { //~ ERROR defining existential type use differs from previous
|
||||
fn bar() -> Foo { //~ ERROR concrete type differs from previous
|
||||
panic!()
|
||||
}
|
||||
|
||||
fn boo() -> Foo { //~ ERROR defining existential type use differs from previous
|
||||
fn boo() -> Foo { //~ ERROR concrete type differs from previous
|
||||
loop {}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
error: defining existential type use differs from previous
|
||||
error: concrete type differs from previous defining existential type use
|
||||
--> $DIR/different_defining_uses_never_type.rs:12:1
|
||||
|
|
||||
LL | / fn bar() -> Foo { //~ ERROR defining existential type use differs from previous
|
||||
LL | / fn bar() -> Foo { //~ ERROR concrete type differs from previous
|
||||
LL | | panic!()
|
||||
LL | | }
|
||||
| |_^
|
||||
|
|
@ -14,10 +14,10 @@ LL | | ""
|
|||
LL | | }
|
||||
| |_^
|
||||
|
||||
error: defining existential type use differs from previous
|
||||
error: concrete type differs from previous defining existential type use
|
||||
--> $DIR/different_defining_uses_never_type.rs:16:1
|
||||
|
|
||||
LL | / fn boo() -> Foo { //~ ERROR defining existential type use differs from previous
|
||||
LL | / fn boo() -> Foo { //~ ERROR concrete type differs from previous
|
||||
LL | | loop {}
|
||||
LL | | }
|
||||
| |_^
|
||||
|
|
|
|||
|
|
@ -8,6 +8,6 @@ fn my_iter<T>(t: T) -> MyIter<T> {
|
|||
std::iter::once(t)
|
||||
}
|
||||
|
||||
fn my_iter2<T>(t: T) -> MyIter<T> { //~ ERROR defining existential type use differs from previous
|
||||
fn my_iter2<T>(t: T) -> MyIter<T> { //~ ERROR concrete type differs from previous
|
||||
Some(t).into_iter()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
error: defining existential type use differs from previous
|
||||
error: concrete type differs from previous defining existential type use
|
||||
--> $DIR/generic_different_defining_uses.rs:11:1
|
||||
|
|
||||
LL | / fn my_iter2<T>(t: T) -> MyIter<T> { //~ ERROR defining existential type use differs from previous
|
||||
LL | / fn my_iter2<T>(t: T) -> MyIter<T> { //~ ERROR concrete type differs from previous
|
||||
LL | | Some(t).into_iter()
|
||||
LL | | }
|
||||
| |_^
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
// compile-pass
|
||||
#![feature(existential_type)]
|
||||
|
||||
use std::fmt::Debug;
|
||||
|
|
@ -7,7 +6,9 @@ fn main() {}
|
|||
|
||||
// test that unused generic parameters are ok
|
||||
existential type Two<T, U>: Debug;
|
||||
//~^ could not find defining uses
|
||||
|
||||
fn one<T: Debug>(t: T) -> Two<T, T> {
|
||||
//~^ ERROR defining existential type use restricts existential type
|
||||
t
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,17 @@
|
|||
error: defining existential type use restricts existential type by using the generic parameter `T` twice
|
||||
--> $DIR/generic_duplicate_param_use.rs:11:1
|
||||
|
|
||||
LL | / fn one<T: Debug>(t: T) -> Two<T, T> {
|
||||
LL | | //~^ ERROR defining existential type use restricts existential type
|
||||
LL | | t
|
||||
LL | | }
|
||||
| |_^
|
||||
|
||||
error: could not find defining uses
|
||||
--> $DIR/generic_duplicate_param_use.rs:8:1
|
||||
|
|
||||
LL | existential type Two<T, U>: Debug;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
@ -1,4 +1,3 @@
|
|||
// compile-pass
|
||||
#![feature(existential_type)]
|
||||
|
||||
use std::fmt::Debug;
|
||||
|
|
@ -9,6 +8,7 @@ fn main() {}
|
|||
existential type Two<T, U>: Debug;
|
||||
|
||||
fn one<T: Debug>(t: T) -> Two<T, T> {
|
||||
//~^ defining existential type use restricts existential type
|
||||
t
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,11 @@
|
|||
error: defining existential type use restricts existential type by using the generic parameter `T` twice
|
||||
--> $DIR/generic_duplicate_param_use2.rs:10:1
|
||||
|
|
||||
LL | / fn one<T: Debug>(t: T) -> Two<T, T> {
|
||||
LL | | //~^ defining existential type use restricts existential type
|
||||
LL | | t
|
||||
LL | | }
|
||||
| |_^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
@ -1,4 +1,3 @@
|
|||
// compile-pass
|
||||
#![feature(existential_type)]
|
||||
|
||||
use std::fmt::Debug;
|
||||
|
|
@ -9,6 +8,7 @@ fn main() {}
|
|||
existential type Two<T, U>: Debug;
|
||||
|
||||
fn one<T: Debug>(t: T) -> Two<T, T> {
|
||||
//~^ defining existential type use restricts existential type
|
||||
t
|
||||
}
|
||||
|
||||
|
|
@ -17,5 +17,6 @@ fn two<T: Debug, U>(t: T, _: U) -> Two<T, U> {
|
|||
}
|
||||
|
||||
fn three<T, U: Debug>(_: T, u: U) -> Two<T, U> {
|
||||
//~^ concrete type's generic parameters differ from previous defining use
|
||||
u
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,28 @@
|
|||
error: defining existential type use restricts existential type by using the generic parameter `T` twice
|
||||
--> $DIR/generic_duplicate_param_use3.rs:10:1
|
||||
|
|
||||
LL | / fn one<T: Debug>(t: T) -> Two<T, T> {
|
||||
LL | | //~^ defining existential type use restricts existential type
|
||||
LL | | t
|
||||
LL | | }
|
||||
| |_^
|
||||
|
||||
error: concrete type's generic parameters differ from previous defining use
|
||||
--> $DIR/generic_duplicate_param_use3.rs:19:1
|
||||
|
|
||||
LL | / fn three<T, U: Debug>(_: T, u: U) -> Two<T, U> {
|
||||
LL | | //~^ concrete type's generic parameters differ from previous defining use
|
||||
LL | | u
|
||||
LL | | }
|
||||
| |_^
|
||||
|
|
||||
note: previous use here
|
||||
--> $DIR/generic_duplicate_param_use3.rs:15:1
|
||||
|
|
||||
LL | / fn two<T: Debug, U>(t: T, _: U) -> Two<T, U> {
|
||||
LL | | t
|
||||
LL | | }
|
||||
| |_^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
@ -1,4 +1,3 @@
|
|||
// compile-pass
|
||||
#![feature(existential_type)]
|
||||
|
||||
use std::fmt::Debug;
|
||||
|
|
@ -9,6 +8,7 @@ fn main() {}
|
|||
existential type Two<T, U>: Debug;
|
||||
|
||||
fn one<T: Debug>(t: T) -> Two<T, T> {
|
||||
//~^ ERROR defining existential type use restricts existential type
|
||||
t
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,11 @@
|
|||
error: defining existential type use restricts existential type by using the generic parameter `T` twice
|
||||
--> $DIR/generic_duplicate_param_use4.rs:10:1
|
||||
|
|
||||
LL | / fn one<T: Debug>(t: T) -> Two<T, T> {
|
||||
LL | | //~^ ERROR defining existential type use restricts existential type
|
||||
LL | | t
|
||||
LL | | }
|
||||
| |_^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
#![feature(existential_type)]
|
||||
|
||||
use std::fmt::Debug;
|
||||
|
||||
fn main() {}
|
||||
|
||||
// test that unused generic parameters are ok
|
||||
existential type Two<T, U>: Debug;
|
||||
|
||||
fn two<T: Debug, U: Debug>(t: T, u: U) -> Two<T, U> {
|
||||
(t, u)
|
||||
}
|
||||
|
||||
fn three<T: Debug, U: Debug>(t: T, u: U) -> Two<T, U> {
|
||||
//~^ concrete type differs from previous
|
||||
(u, t)
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
error: concrete type differs from previous defining existential type use
|
||||
--> $DIR/generic_duplicate_param_use5.rs:14:1
|
||||
|
|
||||
LL | / fn three<T: Debug, U: Debug>(t: T, u: U) -> Two<T, U> {
|
||||
LL | | //~^ concrete type differs from previous
|
||||
LL | | (u, t)
|
||||
LL | | }
|
||||
| |_^
|
||||
|
|
||||
note: previous use here
|
||||
--> $DIR/generic_duplicate_param_use5.rs:10:1
|
||||
|
|
||||
LL | / fn two<T: Debug, U: Debug>(t: T, u: U) -> Two<T, U> {
|
||||
LL | | (t, u)
|
||||
LL | | }
|
||||
| |_^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
#![feature(existential_type)]
|
||||
|
||||
use std::fmt::Debug;
|
||||
|
||||
fn main() {}
|
||||
|
||||
// test that unused generic parameters are ok
|
||||
existential type Two<T, U>: Debug;
|
||||
|
||||
fn two<T: Debug, U: Debug>(t: T, u: U) -> Two<T, U> {
|
||||
(t, t)
|
||||
}
|
||||
|
||||
fn three<T: Debug, U: Debug>(t: T, u: U) -> Two<T, U> {
|
||||
//~^ concrete type differs from previous
|
||||
(u, t)
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
error: concrete type differs from previous defining existential type use
|
||||
--> $DIR/generic_duplicate_param_use6.rs:14:1
|
||||
|
|
||||
LL | / fn three<T: Debug, U: Debug>(t: T, u: U) -> Two<T, U> {
|
||||
LL | | //~^ concrete type differs from previous
|
||||
LL | | (u, t)
|
||||
LL | | }
|
||||
| |_^
|
||||
|
|
||||
note: previous use here
|
||||
--> $DIR/generic_duplicate_param_use6.rs:10:1
|
||||
|
|
||||
LL | / fn two<T: Debug, U: Debug>(t: T, u: U) -> Two<T, U> {
|
||||
LL | | (t, t)
|
||||
LL | | }
|
||||
| |_^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
// compile-pass
|
||||
#![feature(existential_type)]
|
||||
|
||||
use std::fmt::Debug;
|
||||
|
||||
fn main() {}
|
||||
|
||||
existential type Two<A, B>: Debug;
|
||||
|
||||
fn two<T: Debug + Copy, U>(t: T, u: U) -> Two<T, U> {
|
||||
(t, t)
|
||||
}
|
||||
|
||||
fn three<T: Debug, U>(t: T, t2: T, u: U) -> Two<T, U> {
|
||||
(t, t2)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue