Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnTitor committed Apr 30, 2019
1 parent da46eea commit bb3549f
Show file tree
Hide file tree
Showing 14 changed files with 95 additions and 11 deletions.
14 changes: 14 additions & 0 deletions src/test/ui/existential_types/existential-types-with-no-traits.rs
@@ -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() {}
@@ -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

2 changes: 2 additions & 0 deletions src/test/ui/existential_types/generic_nondefining_use.rs
Expand Up @@ -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
Expand Down
10 changes: 8 additions & 2 deletions src/test/ui/existential_types/generic_nondefining_use.stderr
@@ -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
Expand All @@ -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

1 change: 1 addition & 0 deletions src/test/ui/existential_types/generic_not_used.rs
Expand Up @@ -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
Expand Down
10 changes: 8 additions & 2 deletions src/test/ui/existential_types/generic_not_used.stderr
@@ -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> {
| _________________________________________________________________________^
Expand All @@ -8,5 +14,5 @@ LL | | v
LL | | }
| |_^

error: aborting due to previous error
error: aborting due to 2 previous errors

Expand Up @@ -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
Expand Down
@@ -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
|
Expand All @@ -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`.
1 change: 1 addition & 0 deletions src/test/ui/existential_types/generic_underconstrained.rs
Expand Up @@ -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> {
Expand Down
@@ -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
|
Expand All @@ -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`.
2 changes: 2 additions & 0 deletions src/test/ui/existential_types/generic_underconstrained2.rs
Expand Up @@ -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> {
Expand All @@ -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> {
Expand Down
16 changes: 14 additions & 2 deletions src/test/ui/existential_types/generic_underconstrained2.stderr
@@ -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
|
Expand All @@ -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`
Expand All @@ -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`.
5 changes: 2 additions & 3 deletions src/test/ui/existential_types/unused_generic_param.rs
@@ -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
Expand Down
14 changes: 14 additions & 0 deletions src/test/ui/existential_types/unused_generic_param.stderr
@@ -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

0 comments on commit bb3549f

Please sign in to comment.