--- /dev/null
+#![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() {}
--- /dev/null
+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
+
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
+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
LL | existential type Cmp<T>: 'static;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-error: aborting due to 2 previous errors
+error: aborting due to 3 previous errors
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
+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> {
| _________________________________________________________________________^
LL | | }
| |_^
-error: aborting due to previous error
+error: aborting due to 2 previous errors
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
+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
|
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`.
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> {
+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
|
= 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`.
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> {
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> {
+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
|
= 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`
= 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`.
-// 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
--- /dev/null
+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
+