Fix tests

This commit is contained in:
Yuki OKUSHI 2019-04-30 20:43:10 +09:00
parent da46eeac88
commit bb3549fce2
14 changed files with 95 additions and 11 deletions

View file

@ -0,0 +1,14 @@
#![feature(existential_type)]
existential type Foo: 'static;
//~^ ERROR: at least one trait must be specified
fn foo() -> Foo {
"foo"
}
fn bar() -> impl 'static { //~ ERROR: at least one trait must be specified
"foo"
}
fn main() {}

View file

@ -0,0 +1,14 @@
error: at least one trait must be specified
--> $DIR/existential-types-with-no-traits.rs:3:1
|
LL | existential type Foo: 'static;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: at least one trait must be specified
--> $DIR/existential-types-with-no-traits.rs:10:13
|
LL | fn bar() -> impl 'static {
| ^^^^^^^^^^^^
error: aborting due to 2 previous errors

View file

@ -4,6 +4,8 @@ fn main() {}
existential type Cmp<T>: 'static;
//~^ ERROR could not find defining uses
//~^^ ERROR: at least one trait must be specified
// not a defining use, because it doesn't define *all* possible generics
fn cmp() -> Cmp<u32> { //~ ERROR defining existential type use does not fully define

View file

@ -1,5 +1,11 @@
error: at least one trait must be specified
--> $DIR/generic_nondefining_use.rs:5:1
|
LL | existential type Cmp<T>: 'static;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: defining existential type use does not fully define existential type
--> $DIR/generic_nondefining_use.rs:9:1
--> $DIR/generic_nondefining_use.rs:11:1
|
LL | / fn cmp() -> Cmp<u32> {
LL | | 5u32
@ -12,5 +18,5 @@ error: could not find defining uses
LL | existential type Cmp<T>: 'static;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors
error: aborting due to 3 previous errors

View file

@ -3,6 +3,7 @@
fn main() {}
existential type WrongGeneric<T: 'static>: 'static;
//~^ ERROR: at least one trait must be specified
fn wrong_generic<U: 'static, V: 'static>(_: U, v: V) -> WrongGeneric<U> {
//~^ ERROR type parameter `V` is part of concrete type but not used in parameter list

View file

@ -1,5 +1,11 @@
error: at least one trait must be specified
--> $DIR/generic_not_used.rs:5:1
|
LL | existential type WrongGeneric<T: 'static>: 'static;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: type parameter `V` is part of concrete type but not used in parameter list for existential type
--> $DIR/generic_not_used.rs:7:73
--> $DIR/generic_not_used.rs:8:73
|
LL | fn wrong_generic<U: 'static, V: 'static>(_: U, v: V) -> WrongGeneric<U> {
| _________________________________________________________________________^
@ -8,5 +14,5 @@ LL | | v
LL | | }
| |_^
error: aborting due to previous error
error: aborting due to 2 previous errors

View file

@ -8,6 +8,7 @@ fn main() {
existential type WrongGeneric<T>: 'static;
//~^ ERROR the parameter type `T` may not live long enough
//~^^ ERROR: at least one trait must be specified
fn wrong_generic<T>(t: T) -> WrongGeneric<T> {
t

View file

@ -1,3 +1,9 @@
error: at least one trait must be specified
--> $DIR/generic_type_does_not_live_long_enough.rs:9:1
|
LL | existential type WrongGeneric<T>: 'static;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0308]: mismatched types
--> $DIR/generic_type_does_not_live_long_enough.rs:6:18
|
@ -22,7 +28,7 @@ note: ...so that the type `T` will meet its required lifetime bounds
LL | existential type WrongGeneric<T>: 'static;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0308, E0310.
For more information about an error, try `rustc --explain E0308`.

View file

@ -4,6 +4,7 @@ fn main() {}
trait Trait {}
existential type Underconstrained<T: Trait>: 'static; //~ ERROR the trait bound `T: Trait`
//~^ ERROR: at least one trait must be specified
// no `Trait` bound
fn underconstrain<T>(_: T) -> Underconstrained<T> {

View file

@ -1,3 +1,9 @@
error: at least one trait must be specified
--> $DIR/generic_underconstrained.rs:6:1
|
LL | existential type Underconstrained<T: Trait>: 'static;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0277]: the trait bound `T: Trait` is not satisfied
--> $DIR/generic_underconstrained.rs:6:1
|
@ -7,6 +13,6 @@ LL | existential type Underconstrained<T: Trait>: 'static;
= help: consider adding a `where T: Trait` bound
= note: the return type of a function must have a statically known size
error: aborting due to previous error
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0277`.

View file

@ -4,6 +4,7 @@ fn main() {}
existential type Underconstrained<T: std::fmt::Debug>: 'static;
//~^ ERROR `U` doesn't implement `std::fmt::Debug`
//~^^ ERROR: at least one trait must be specified
// not a defining use, because it doesn't define *all* possible generics
fn underconstrained<U>(_: U) -> Underconstrained<U> {
@ -12,6 +13,7 @@ fn underconstrained<U>(_: U) -> Underconstrained<U> {
existential type Underconstrained2<T: std::fmt::Debug>: 'static;
//~^ ERROR `V` doesn't implement `std::fmt::Debug`
//~^^ ERROR: at least one trait must be specified
// not a defining use, because it doesn't define *all* possible generics
fn underconstrained2<U, V>(_: U, _: V) -> Underconstrained2<V> {

View file

@ -1,3 +1,15 @@
error: at least one trait must be specified
--> $DIR/generic_underconstrained2.rs:5:1
|
LL | existential type Underconstrained<T: std::fmt::Debug>: 'static;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: at least one trait must be specified
--> $DIR/generic_underconstrained2.rs:14:1
|
LL | existential type Underconstrained2<T: std::fmt::Debug>: 'static;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0277]: `U` doesn't implement `std::fmt::Debug`
--> $DIR/generic_underconstrained2.rs:5:1
|
@ -9,7 +21,7 @@ LL | existential type Underconstrained<T: std::fmt::Debug>: 'static;
= note: the return type of a function must have a statically known size
error[E0277]: `V` doesn't implement `std::fmt::Debug`
--> $DIR/generic_underconstrained2.rs:13:1
--> $DIR/generic_underconstrained2.rs:14:1
|
LL | existential type Underconstrained2<T: std::fmt::Debug>: 'static;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `V` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug`
@ -18,6 +30,6 @@ LL | existential type Underconstrained2<T: std::fmt::Debug>: 'static;
= help: consider adding a `where V: std::fmt::Debug` bound
= note: the return type of a function must have a statically known size
error: aborting due to 2 previous errors
error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0277`.

View file

@ -1,18 +1,17 @@
// compile-pass
#![feature(existential_type)]
fn main() {
}
// test that unused generic parameters are ok
existential type PartiallyDefined<T>: 'static;
//~^ ERROR: at least one trait must be specified
fn partially_defined<T: std::fmt::Debug>(_: T) -> PartiallyDefined<T> {
4u32
}
// test that unused generic parameters are ok
existential type PartiallyDefined2<T>: 'static;
//~^ ERROR: at least one trait must be specified
fn partially_defined2<T: std::fmt::Debug>(_: T) -> PartiallyDefined2<T> {
4u32

View file

@ -0,0 +1,14 @@
error: at least one trait must be specified
--> $DIR/unused_generic_param.rs:6:1
|
LL | existential type PartiallyDefined<T>: 'static;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: at least one trait must be specified
--> $DIR/unused_generic_param.rs:13:1
|
LL | existential type PartiallyDefined2<T>: 'static;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors