diff options
| author | bors <bors@rust-lang.org> | 2019-08-03 02:21:23 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-08-03 02:21:23 +0000 |
| commit | d7270712cb446aad0817040bbca73a8d024f67b0 (patch) | |
| tree | 22cf18615b2177381934d771fc3710e6fd04c257 /src/test | |
| parent | d9bd4b289f07956819c59704d88d9eed61af3a6d (diff) | |
| parent | fbd7e0cf0e31ab612343311a61fe4f58a76a1698 (diff) | |
Auto merge of #63180 - varkor:trait-alias-impl-trait, r=Centril
Change opaque type syntax from `existential type` to type alias `impl Trait` This implements a new feature gate `type_alias_impl_trait` (this is slightly different from the originally proposed feature name, but matches what has been used in discussion since), deprecating the old `existential_types` feature. The syntax for opaque types has been changed. In addition, the "existential" terminology has been replaced with "opaque", as per previous discussion and the RFC. This makes partial progress towards implementing https://github.com/rust-lang/rust/issues/63063. r? @Centril
Diffstat (limited to 'src/test')
145 files changed, 533 insertions, 517 deletions
diff --git a/src/test/rustdoc-ui/coverage/traits.rs b/src/test/rustdoc-ui/coverage/traits.rs index 40d68423f1b..97f73b4e1f2 100644 --- a/src/test/rustdoc-ui/coverage/traits.rs +++ b/src/test/rustdoc-ui/coverage/traits.rs @@ -29,9 +29,10 @@ impl ThisTrait for SomeStruct { /// but what about those aliases? i hear they're pretty exotic pub trait MyAlias = ThisTrait + Send + Sync; -// FIXME(58624): once rustdoc can process existential types, we need to make sure they're counted -// /// woah, getting all existential in here -// pub existential type ThisExists: ThisTrait; +// FIXME(58624): once rustdoc can process opaque `impl Trait` types, +// we need to make sure they're counted +// /// woah, getting all opaque in here +// pub type ThisExists = impl ThisTrait; // // /// why don't we get a little more concrete // pub fn defines() -> ThisExists { SomeStruct {} } diff --git a/src/test/ui/associated-type-bounds/bounds-on-assoc-in-trait.rs b/src/test/ui/associated-type-bounds/bounds-on-assoc-in-trait.rs index 8c9110d03ec..9db5233e21e 100644 --- a/src/test/ui/associated-type-bounds/bounds-on-assoc-in-trait.rs +++ b/src/test/ui/associated-type-bounds/bounds-on-assoc-in-trait.rs @@ -28,7 +28,7 @@ impl Case1 for S1 { type B = Range<u16>; } -// Ensure we don't have existential desugaring: +// Ensure we don't have opaque `impl Trait` desugaring: pub trait Foo { type Out: Baz<Assoc: Default>; } pub trait Baz { type Assoc; } diff --git a/src/test/ui/associated-type-bounds/duplicate.rs b/src/test/ui/associated-type-bounds/duplicate.rs index bee56d6f689..1f2d755ed71 100644 --- a/src/test/ui/associated-type-bounds/duplicate.rs +++ b/src/test/ui/associated-type-bounds/duplicate.rs @@ -3,7 +3,7 @@ // error-pattern:could not find defining uses #![feature(associated_type_bounds)] -#![feature(existential_type)] +#![feature(type_alias_impl_trait)] #![feature(impl_trait_in_bindings)] #![feature(untagged_unions)] @@ -107,17 +107,17 @@ type TAW2<T> where T: Iterator<Item: Copy, Item: Copy> = T; type TAW3<T> where T: Iterator<Item: 'static, Item: 'static> = T; //~^ the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] -existential type ETAI1<T: Iterator<Item: Copy, Item: Send>>: Copy; +type ETAI1<T: Iterator<Item: Copy, Item: Send>> = impl Copy; //~^ the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] -existential type ETAI2<T: Iterator<Item: Copy, Item: Copy>>: Copy; +type ETAI2<T: Iterator<Item: Copy, Item: Copy>> = impl Copy; //~^ the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] -existential type ETAI3<T: Iterator<Item: 'static, Item: 'static>>: Copy; +type ETAI3<T: Iterator<Item: 'static, Item: 'static>> = impl Copy; //~^ the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] -existential type ETAI4: Iterator<Item: Copy, Item: Send>; +type ETAI4 = impl Iterator<Item: Copy, Item: Send>; //~^ the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] -existential type ETAI5: Iterator<Item: Copy, Item: Copy>; +type ETAI5 = impl Iterator<Item: Copy, Item: Copy>; //~^ the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] -existential type ETAI6: Iterator<Item: 'static, Item: 'static>; +type ETAI6 = impl Iterator<Item: 'static, Item: 'static>; //~^ the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] trait TRI1<T: Iterator<Item: Copy, Item: Send>> {} diff --git a/src/test/ui/associated-type-bounds/duplicate.stderr b/src/test/ui/associated-type-bounds/duplicate.stderr index 7f14a033688..7f3a65ab696 100644 --- a/src/test/ui/associated-type-bounds/duplicate.stderr +++ b/src/test/ui/associated-type-bounds/duplicate.stderr @@ -369,86 +369,86 @@ LL | type TAW3<T> where T: Iterator<Item: 'static, Item: 'static> = T; error: could not find defining uses --> $DIR/duplicate.rs:110:1 | -LL | existential type ETAI1<T: Iterator<Item: Copy, Item: Send>>: Copy; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | type ETAI1<T: Iterator<Item: Copy, Item: Send>> = impl Copy; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified - --> $DIR/duplicate.rs:110:48 + --> $DIR/duplicate.rs:110:36 | -LL | existential type ETAI1<T: Iterator<Item: Copy, Item: Send>>: Copy; - | ---------- ^^^^^^^^^^ re-bound here - | | - | `Item` bound here first +LL | type ETAI1<T: Iterator<Item: Copy, Item: Send>> = impl Copy; + | ---------- ^^^^^^^^^^ re-bound here + | | + | `Item` bound here first error: could not find defining uses --> $DIR/duplicate.rs:112:1 | -LL | existential type ETAI2<T: Iterator<Item: Copy, Item: Copy>>: Copy; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | type ETAI2<T: Iterator<Item: Copy, Item: Copy>> = impl Copy; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified - --> $DIR/duplicate.rs:112:48 + --> $DIR/duplicate.rs:112:36 | -LL | existential type ETAI2<T: Iterator<Item: Copy, Item: Copy>>: Copy; - | ---------- ^^^^^^^^^^ re-bound here - | | - | `Item` bound here first +LL | type ETAI2<T: Iterator<Item: Copy, Item: Copy>> = impl Copy; + | ---------- ^^^^^^^^^^ re-bound here + | | + | `Item` bound here first error: could not find defining uses --> $DIR/duplicate.rs:114:1 | -LL | existential type ETAI3<T: Iterator<Item: 'static, Item: 'static>>: Copy; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | type ETAI3<T: Iterator<Item: 'static, Item: 'static>> = impl Copy; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified - --> $DIR/duplicate.rs:114:51 + --> $DIR/duplicate.rs:114:39 | -LL | existential type ETAI3<T: Iterator<Item: 'static, Item: 'static>>: Copy; - | ------------- ^^^^^^^^^^^^^ re-bound here - | | - | `Item` bound here first +LL | type ETAI3<T: Iterator<Item: 'static, Item: 'static>> = impl Copy; + | ------------- ^^^^^^^^^^^^^ re-bound here + | | + | `Item` bound here first error: could not find defining uses --> $DIR/duplicate.rs:116:1 | -LL | existential type ETAI4: Iterator<Item: Copy, Item: Send>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | type ETAI4 = impl Iterator<Item: Copy, Item: Send>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified - --> $DIR/duplicate.rs:116:46 + --> $DIR/duplicate.rs:116:40 | -LL | existential type ETAI4: Iterator<Item: Copy, Item: Send>; - | ---------- ^^^^^^^^^^ re-bound here - | | - | `Item` bound here first +LL | type ETAI4 = impl Iterator<Item: Copy, Item: Send>; + | ---------- ^^^^^^^^^^ re-bound here + | | + | `Item` bound here first error: could not find defining uses --> $DIR/duplicate.rs:118:1 | -LL | existential type ETAI5: Iterator<Item: Copy, Item: Copy>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | type ETAI5 = impl Iterator<Item: Copy, Item: Copy>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified - --> $DIR/duplicate.rs:118:46 + --> $DIR/duplicate.rs:118:40 | -LL | existential type ETAI5: Iterator<Item: Copy, Item: Copy>; - | ---------- ^^^^^^^^^^ re-bound here - | | - | `Item` bound here first +LL | type ETAI5 = impl Iterator<Item: Copy, Item: Copy>; + | ---------- ^^^^^^^^^^ re-bound here + | | + | `Item` bound here first error: could not find defining uses --> $DIR/duplicate.rs:120:1 | -LL | existential type ETAI6: Iterator<Item: 'static, Item: 'static>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | type ETAI6 = impl Iterator<Item: 'static, Item: 'static>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified - --> $DIR/duplicate.rs:120:49 + --> $DIR/duplicate.rs:120:43 | -LL | existential type ETAI6: Iterator<Item: 'static, Item: 'static>; - | ------------- ^^^^^^^^^^^^^ re-bound here - | | - | `Item` bound here first +LL | type ETAI6 = impl Iterator<Item: 'static, Item: 'static>; + | ------------- ^^^^^^^^^^^^^ re-bound here + | | + | `Item` bound here first error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified --> $DIR/duplicate.rs:123:36 diff --git a/src/test/ui/associated-type-bounds/dyn-existential-type.rs b/src/test/ui/associated-type-bounds/dyn-impl-trait-type.rs index dc0afaa934a..fd9e52a6ff2 100644 --- a/src/test/ui/associated-type-bounds/dyn-existential-type.rs +++ b/src/test/ui/associated-type-bounds/dyn-impl-trait-type.rs @@ -1,7 +1,6 @@ // run-pass #![feature(associated_type_bounds)] -#![feature(existential_type)] use std::ops::Add; diff --git a/src/test/ui/associated-type-bounds/existential-type.rs b/src/test/ui/associated-type-bounds/trait-alias-impl-trait.rs index 87046aec5c4..9ee33e4149a 100644 --- a/src/test/ui/associated-type-bounds/existential-type.rs +++ b/src/test/ui/associated-type-bounds/trait-alias-impl-trait.rs @@ -1,7 +1,7 @@ // run-pass #![feature(associated_type_bounds)] -#![feature(existential_type)] +#![feature(type_alias_impl_trait)] use std::ops::Add; @@ -17,15 +17,15 @@ struct S1; struct S2; impl Tr1 for S1 { type As1 = S2; fn mk(self) -> Self::As1 { S2 } } -existential type Et1: Tr1<As1: Copy>; +type Et1 = impl Tr1<As1: Copy>; fn def_et1() -> Et1 { S1 } pub fn use_et1() { assert_copy(def_et1().mk()); } -existential type Et2: Tr1<As1: 'static>; +type Et2 = impl Tr1<As1: 'static>; fn def_et2() -> Et2 { S1 } pub fn use_et2() { assert_static(def_et2().mk()); } -existential type Et3: Tr1<As1: Clone + Iterator<Item: Add<u8, Output: Into<u8>>>>; +type Et3 = impl Tr1<As1: Clone + Iterator<Item: Add<u8, Output: Into<u8>>>>; fn def_et3() -> Et3 { struct A; impl Tr1 for A { @@ -44,7 +44,7 @@ pub fn use_et3() { assert_eq!(s, (0..10).map(|x| x + 1).sum()); } -existential type Et4: Tr1<As1: for<'a> Tr2<'a>>; +type Et4 = impl Tr1<As1: for<'a> Tr2<'a>>; fn def_et4() -> Et4 { #[derive(Copy, Clone)] struct A; diff --git a/src/test/ui/async-await/async-await.rs b/src/test/ui/async-await/async-await.rs index 5ec99c5d183..8a15eb8c573 100644 --- a/src/test/ui/async-await/async-await.rs +++ b/src/test/ui/async-await/async-await.rs @@ -99,12 +99,10 @@ fn async_fn_with_impl_future_named_lifetime<'a>(x: &'a u8) -> impl Future<Output } } -/* FIXME(cramertj) support when `existential type T<'a, 'b>:;` works async fn async_fn_multiple_args(x: &u8, _y: &u8) -> u8 { - await!(wake_and_yield_once()); + wake_and_yield_once().await; *x } -*/ async fn async_fn_multiple_args_named_lifetime<'a>(x: &'a u8, _y: &'a u8) -> u8 { wake_and_yield_once().await; diff --git a/src/test/ui/async-await/issues/issue-60655-latebound-regions.rs b/src/test/ui/async-await/issues/issue-60655-latebound-regions.rs index 2328ceb144f..99213e64d16 100644 --- a/src/test/ui/async-await/issues/issue-60655-latebound-regions.rs +++ b/src/test/ui/async-await/issues/issue-60655-latebound-regions.rs @@ -1,13 +1,14 @@ -// Test that existential types are allowed to contain late-bound regions. +// Test that opaque `impl Trait` types are allowed to contain late-bound regions. // build-pass (FIXME(62277): could be check-pass?) // edition:2018 -#![feature(async_await, existential_type)] +#![feature(async_await)] +#![feature(type_alias_impl_trait)] use std::future::Future; -pub existential type Func: Sized; +pub type Func = impl Sized; // Late bound region should be allowed to escape the function, since it's bound // in the type. @@ -17,7 +18,7 @@ fn null_function_ptr() -> Func { async fn async_nop(_: &u8) {} -pub existential type ServeFut: Future<Output=()>; +pub type ServeFut = impl Future<Output=()>; // Late bound regions occur in the generator witness type here. fn serve() -> ServeFut { diff --git a/src/test/ui/existential-type/issue-52843-closure-constrain.rs b/src/test/ui/existential-type/issue-52843-closure-constrain.rs deleted file mode 100644 index b2bbc1f1549..00000000000 --- a/src/test/ui/existential-type/issue-52843-closure-constrain.rs +++ /dev/null @@ -1,12 +0,0 @@ -// Checks to ensure that we properly detect when a closure constrains an existential type -#![feature(existential_type)] - -use std::fmt::Debug; - -fn main() { - existential type Existential: Debug; - fn _unused() -> Existential { String::new() } - //~^ ERROR: concrete type differs from previous defining existential type use - let null = || -> Existential { 0 }; - println!("{:?}", null()); -} diff --git a/src/test/ui/existential-type/issue-52843-closure-constrain.stderr b/src/test/ui/existential-type/issue-52843-closure-constrain.stderr deleted file mode 100644 index 424d65a193c..00000000000 --- a/src/test/ui/existential-type/issue-52843-closure-constrain.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error: concrete type differs from previous defining existential type use - --> $DIR/issue-52843-closure-constrain.rs:8:5 - | -LL | fn _unused() -> Existential { String::new() } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, got `std::string::String` - | -note: previous use here - --> $DIR/issue-52843-closure-constrain.rs:6:1 - | -LL | / fn main() { -LL | | existential type Existential: Debug; -LL | | fn _unused() -> Existential { String::new() } -LL | | -LL | | let null = || -> Existential { 0 }; -LL | | println!("{:?}", null()); -LL | | } - | |_^ - -error: aborting due to previous error - diff --git a/src/test/ui/existential_types/auxiliary/cross_crate_ice.rs b/src/test/ui/existential_types/auxiliary/cross_crate_ice.rs deleted file mode 100644 index 96ab476061d..00000000000 --- a/src/test/ui/existential_types/auxiliary/cross_crate_ice.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Crate that exports an existential type. Used for testing cross-crate. - -#![crate_type="rlib"] - -#![feature(existential_type)] - -pub existential type Foo: std::fmt::Debug; - -pub fn foo() -> Foo { - 5 -} diff --git a/src/test/ui/existential_types/declared_but_never_defined.rs b/src/test/ui/existential_types/declared_but_never_defined.rs deleted file mode 100644 index ff253391f2a..00000000000 --- a/src/test/ui/existential_types/declared_but_never_defined.rs +++ /dev/null @@ -1,6 +0,0 @@ -#![feature(existential_type)] - -fn main() {} - -// declared but never defined -existential type Bar: std::fmt::Debug; //~ ERROR could not find defining uses diff --git a/src/test/ui/existential_types/declared_but_not_defined_in_scope.rs b/src/test/ui/existential_types/declared_but_not_defined_in_scope.rs deleted file mode 100644 index a6311ee964d..00000000000 --- a/src/test/ui/existential_types/declared_but_not_defined_in_scope.rs +++ /dev/null @@ -1,12 +0,0 @@ -#![feature(existential_type)] - -fn main() {} - -mod boo { - // declared in module but not defined inside of it - pub existential type Boo: ::std::fmt::Debug; //~ ERROR could not find defining uses -} - -fn bomp() -> boo::Boo { - "" -} diff --git a/src/test/ui/existential_types/existential-types-with-cycle-error.stderr b/src/test/ui/existential_types/existential-types-with-cycle-error.stderr deleted file mode 100644 index 98a269d5271..00000000000 --- a/src/test/ui/existential_types/existential-types-with-cycle-error.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: could not find defining uses - --> $DIR/existential-types-with-cycle-error.rs:3:1 - | -LL | existential type Foo: Fn() -> Foo; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/existential_types/existential-types-with-cycle-error2.stderr b/src/test/ui/existential_types/existential-types-with-cycle-error2.stderr deleted file mode 100644 index 830305d8631..00000000000 --- a/src/test/ui/existential_types/existential-types-with-cycle-error2.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: could not find defining uses - --> $DIR/existential-types-with-cycle-error2.rs:7:1 - | -LL | existential type Foo: Bar<Foo, Item = Foo>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/existential_types/generic_duplicate_lifetime_param.rs b/src/test/ui/existential_types/generic_duplicate_lifetime_param.rs deleted file mode 100644 index e9943beddbf..00000000000 --- a/src/test/ui/existential_types/generic_duplicate_lifetime_param.rs +++ /dev/null @@ -1,9 +0,0 @@ -#![feature(existential_type)] - -fn main() {} - -existential type Two<'a, 'b>: std::fmt::Debug; - -fn one<'a>(t: &'a ()) -> Two<'a, 'a> { //~ ERROR non-defining existential type use - t -} diff --git a/src/test/ui/existential_types/unused_generic_param.stderr b/src/test/ui/existential_types/unused_generic_param.stderr deleted file mode 100644 index 9d628d069d3..00000000000 --- a/src/test/ui/existential_types/unused_generic_param.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error: at least one trait must be specified - --> $DIR/unused_generic_param.rs:6:39 - | -LL | existential type PartiallyDefined<T>: 'static; - | ^^^^^^^ - -error: at least one trait must be specified - --> $DIR/unused_generic_param.rs:13:40 - | -LL | existential type PartiallyDefined2<T>: 'static; - | ^^^^^^^ - -error: aborting due to 2 previous errors - diff --git a/src/test/ui/feature-gates/feature-gate-existential-type.rs b/src/test/ui/feature-gates/feature-gate-existential-type.rs deleted file mode 100644 index 6dfd2d10870..00000000000 --- a/src/test/ui/feature-gates/feature-gate-existential-type.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Check that existential types must be ungated to use the `existential` keyword - -existential type Foo: std::fmt::Debug; //~ ERROR existential types are unstable - -trait Bar { - type Baa: std::fmt::Debug; - fn define() -> Self::Baa; -} - -impl Bar for () { - existential type Baa: std::fmt::Debug; //~ ERROR existential types are unstable - fn define() -> Self::Baa { 0 } -} - -fn define() -> Foo { 0 } - -fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-existential-type.stderr b/src/test/ui/feature-gates/feature-gate-existential-type.stderr deleted file mode 100644 index 30e25e55aff..00000000000 --- a/src/test/ui/feature-gates/feature-gate-existential-type.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0658]: existential types are unstable - --> $DIR/feature-gate-existential-type.rs:3:1 - | -LL | existential type Foo: std::fmt::Debug; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: for more information, see https://github.com/rust-lang/rust/issues/63063 - = help: add `#![feature(existential_type)]` to the crate attributes to enable - -error[E0658]: existential types are unstable - --> $DIR/feature-gate-existential-type.rs:11:5 - | -LL | existential type Baa: std::fmt::Debug; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: for more information, see https://github.com/rust-lang/rust/issues/63063 - = help: add `#![feature(existential_type)]` to the crate attributes to enable - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/feature-gates/feature-gate-type_alias_impl_trait.rs b/src/test/ui/feature-gates/feature-gate-type_alias_impl_trait.rs new file mode 100644 index 00000000000..4a0c8c52c4e --- /dev/null +++ b/src/test/ui/feature-gates/feature-gate-type_alias_impl_trait.rs @@ -0,0 +1,15 @@ +type Foo = impl std::fmt::Debug; //~ ERROR `impl Trait` in type aliases is unstable + +trait Bar { + type Baa: std::fmt::Debug; + fn define() -> Self::Baa; +} + +impl Bar for () { + type Baa = impl std::fmt::Debug; //~ ERROR `impl Trait` in type aliases is unstable + fn define() -> Self::Baa { 0 } +} + +fn define() -> Foo { 0 } + +fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-type_alias_impl_trait.stderr b/src/test/ui/feature-gates/feature-gate-type_alias_impl_trait.stderr new file mode 100644 index 00000000000..2d0710ea37c --- /dev/null +++ b/src/test/ui/feature-gates/feature-gate-type_alias_impl_trait.stderr @@ -0,0 +1,21 @@ +error[E0658]: `impl Trait` in type aliases is unstable + --> $DIR/feature-gate-type_alias_impl_trait.rs:1:1 + | +LL | type Foo = impl std::fmt::Debug; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/63063 + = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable + +error[E0658]: `impl Trait` in type aliases is unstable + --> $DIR/feature-gate-type_alias_impl_trait.rs:9:5 + | +LL | type Baa = impl std::fmt::Debug; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/63063 + = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/impl-trait/associated-existential-type-generic-trait.rs b/src/test/ui/impl-trait/associated-impl-trait-type-generic-trait.rs index 130de9ccf62..6c7c46b0e3d 100644 --- a/src/test/ui/impl-trait/associated-existential-type-generic-trait.rs +++ b/src/test/ui/impl-trait/associated-impl-trait-type-generic-trait.rs @@ -1,4 +1,4 @@ -#![feature(existential_type)] +#![feature(type_alias_impl_trait)] // build-pass (FIXME(62277): could be check-pass?) trait Bar {} @@ -11,7 +11,7 @@ trait Foo<T> { } impl<W> Foo<W> for i32 { - existential type Assoc: Bar; + type Assoc = impl Bar; fn foo(w: W) -> Self::Assoc { Dummy(w) } @@ -21,7 +21,7 @@ struct NonGeneric; impl Bar for NonGeneric {} impl<W> Foo<W> for u32 { - existential type Assoc: Bar; + type Assoc = impl Bar; fn foo(_: W) -> Self::Assoc { NonGeneric } diff --git a/src/test/ui/impl-trait/associated-existential-type-trivial.rs b/src/test/ui/impl-trait/associated-impl-trait-type-trivial.rs index 0e83b4084b6..cdda341cad8 100644 --- a/src/test/ui/impl-trait/associated-existential-type-trivial.rs +++ b/src/test/ui/impl-trait/associated-impl-trait-type-trivial.rs @@ -1,4 +1,4 @@ -#![feature(existential_type)] +#![feature(type_alias_impl_trait)] // build-pass (FIXME(62277): could be check-pass?) trait Bar {} @@ -11,7 +11,7 @@ trait Foo { } impl Foo for i32 { - existential type Assoc: Bar; + type Assoc = impl Bar; fn foo() -> Self::Assoc { Dummy } diff --git a/src/test/ui/impl-trait/associated-existential-type.rs b/src/test/ui/impl-trait/associated-impl-trait-type.rs index 58966aefe1c..d0661d66f4b 100644 --- a/src/test/ui/impl-trait/associated-existential-type.rs +++ b/src/test/ui/impl-trait/associated-impl-trait-type.rs @@ -1,4 +1,4 @@ -#![feature(existential_type)] +#![feature(type_alias_impl_trait)] // build-pass (FIXME(62277): could be check-pass?) trait Bar {} @@ -12,7 +12,7 @@ trait Foo { } impl Foo for i32 { - existential type Assoc: Bar; + type Assoc = impl Bar; fn foo() -> Self::Assoc { Dummy } diff --git a/src/test/ui/impl-trait/bound-normalization-fail.rs b/src/test/ui/impl-trait/bound-normalization-fail.rs index 476ae62fa0f..c33261bfd09 100644 --- a/src/test/ui/impl-trait/bound-normalization-fail.rs +++ b/src/test/ui/impl-trait/bound-normalization-fail.rs @@ -2,7 +2,6 @@ // edition:2018 #![feature(async_await)] -#![feature(existential_type)] #![feature(impl_trait_in_bindings)] //~^ WARNING the feature `impl_trait_in_bindings` is incomplete diff --git a/src/test/ui/impl-trait/bound-normalization-fail.stderr b/src/test/ui/impl-trait/bound-normalization-fail.stderr index 24a687491e5..aa306a7e08a 100644 --- a/src/test/ui/impl-trait/bound-normalization-fail.stderr +++ b/src/test/ui/impl-trait/bound-normalization-fail.stderr @@ -1,5 +1,5 @@ warning: the feature `impl_trait_in_bindings` is incomplete and may cause the compiler to crash - --> $DIR/bound-normalization-fail.rs:6:12 + --> $DIR/bound-normalization-fail.rs:5:12 | LL | #![feature(impl_trait_in_bindings)] | ^^^^^^^^^^^^^^^^^^^^^^ @@ -7,7 +7,7 @@ LL | #![feature(impl_trait_in_bindings)] = note: `#[warn(incomplete_features)]` on by default error[E0271]: type mismatch resolving `<Foo<()> as FooLike>::Output == <T as impl_trait::Trait>::Assoc` - --> $DIR/bound-normalization-fail.rs:30:32 + --> $DIR/bound-normalization-fail.rs:29:32 | LL | fn foo_fail<T: Trait>() -> impl FooLike<Output=T::Assoc> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected (), found associated type @@ -17,7 +17,7 @@ LL | fn foo_fail<T: Trait>() -> impl FooLike<Output=T::Assoc> { = note: the return type of a function must have a statically known size error[E0271]: type mismatch resolving `<Foo<()> as FooLike>::Output == <T as lifetimes::Trait<'static>>::Assoc` - --> $DIR/bound-normalization-fail.rs:47:41 + --> $DIR/bound-normalization-fail.rs:46:41 | LL | fn foo2_fail<'a, T: Trait<'a>>() -> impl FooLike<Output=T::Assoc> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected (), found associated type diff --git a/src/test/ui/impl-trait/bound-normalization-pass.rs b/src/test/ui/impl-trait/bound-normalization-pass.rs index 3fdd7c0ecb6..5b634e3106e 100644 --- a/src/test/ui/impl-trait/bound-normalization-pass.rs +++ b/src/test/ui/impl-trait/bound-normalization-pass.rs @@ -2,7 +2,7 @@ // edition:2018 #![feature(async_await)] -#![feature(existential_type)] +#![feature(type_alias_impl_trait)] #![feature(impl_trait_in_bindings)] //~^ WARNING the feature `impl_trait_in_bindings` is incomplete @@ -81,9 +81,9 @@ mod impl_trait_in_bindings { } ///////////////////////////////////////////// -// The same applied to `existential type`s +// The same applied to `type Foo = impl Bar`s -mod existential_types { +mod opaque_types { trait Implemented { type Assoc; } @@ -99,7 +99,7 @@ mod existential_types { type Out = u8; } - existential type Ex: Trait<Out = <() as Implemented>::Assoc>; + type Ex = impl Trait<Out = <() as Implemented>::Assoc>; fn define() -> Ex { () diff --git a/src/test/ui/impl-trait/issue-55872-1.rs b/src/test/ui/impl-trait/issue-55872-1.rs index 5095b26f8a4..f99096b4d58 100644 --- a/src/test/ui/impl-trait/issue-55872-1.rs +++ b/src/test/ui/impl-trait/issue-55872-1.rs @@ -1,5 +1,5 @@ // ignore-tidy-linelength -#![feature(existential_type)] +#![feature(type_alias_impl_trait)] pub trait Bar { @@ -9,12 +9,12 @@ pub trait Bar } impl<S: Default> Bar for S { - existential type E: Copy; + type E = impl Copy; //~^ ERROR the trait bound `S: std::marker::Copy` is not satisfied in `(S, T)` [E0277] //~^^ ERROR the trait bound `T: std::marker::Copy` is not satisfied in `(S, T)` [E0277] fn foo<T: Default>() -> Self::E { - //~^ ERROR type parameter `T` is part of concrete type but not used in parameter list for existential type + //~^ ERROR type parameter `T` is part of concrete type but not used in parameter list for the `impl Trait` type alias (S::default(), T::default()) } } diff --git a/src/test/ui/impl-trait/issue-55872-1.stderr b/src/test/ui/impl-trait/issue-55872-1.stderr index 04b4d2d4a50..d5756c01559 100644 --- a/src/test/ui/impl-trait/issue-55872-1.stderr +++ b/src/test/ui/impl-trait/issue-55872-1.stderr @@ -1,8 +1,8 @@ error[E0277]: the trait bound `S: std::marker::Copy` is not satisfied in `(S, T)` --> $DIR/issue-55872-1.rs:12:5 | -LL | existential type E: Copy; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ within `(S, T)`, the trait `std::marker::Copy` is not implemented for `S` +LL | type E = impl Copy; + | ^^^^^^^^^^^^^^^^^^^ within `(S, T)`, the trait `std::marker::Copy` is not implemented for `S` | = help: consider adding a `where S: std::marker::Copy` bound = note: required because it appears within the type `(S, T)` @@ -11,14 +11,14 @@ LL | existential type E: Copy; error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied in `(S, T)` --> $DIR/issue-55872-1.rs:12:5 | -LL | existential type E: Copy; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ within `(S, T)`, the trait `std::marker::Copy` is not implemented for `T` +LL | type E = impl Copy; + | ^^^^^^^^^^^^^^^^^^^ within `(S, T)`, the trait `std::marker::Copy` is not implemented for `T` | = help: consider adding a `where T: std::marker::Copy` bound = note: required because it appears within the type `(S, T)` = note: the return type of a function must have a statically known size -error: type parameter `T` is part of concrete type but not used in parameter list for existential type +error: type parameter `T` is part of concrete type but not used in parameter list for the `impl Trait` type alias --> $DIR/issue-55872-1.rs:16:37 | LL | fn foo<T: Default>() -> Self::E { diff --git a/src/test/ui/impl-trait/issue-55872-2.rs b/src/test/ui/impl-trait/issue-55872-2.rs index 2bdeb14bdc3..dfee20ca649 100644 --- a/src/test/ui/impl-trait/issue-55872-2.rs +++ b/src/test/ui/impl-trait/issue-55872-2.rs @@ -1,6 +1,6 @@ // edition:2018 // ignore-tidy-linelength -#![feature(async_await, existential_type)] +#![feature(async_await, type_alias_impl_trait)] pub trait Bar { type E: Copy; @@ -9,10 +9,10 @@ pub trait Bar { } impl<S> Bar for S { - existential type E: Copy; + type E = impl Copy; //~^ ERROR the trait bound `impl std::future::Future: std::marker::Copy` is not satisfied [E0277] fn foo<T>() -> Self::E { - //~^ ERROR type parameter `T` is part of concrete type but not used in parameter list for existential type + //~^ ERROR type parameter `T` is part of concrete type but not used in parameter list for the `impl Trait` type alias async {} } } diff --git a/src/test/ui/impl-trait/issue-55872-2.stderr b/src/test/ui/impl-trait/issue-55872-2.stderr index 2505a82ee23..676c3fe3d4c 100644 --- a/src/test/ui/impl-trait/issue-55872-2.stderr +++ b/src/test/ui/impl-trait/issue-55872-2.stderr @@ -1,12 +1,12 @@ error[E0277]: the trait bound `impl std::future::Future: std::marker::Copy` is not satisfied --> $DIR/issue-55872-2.rs:12:5 | -LL | existential type E: Copy; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `impl std::future::Future` +LL | type E = impl Copy; + | ^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `impl std::future::Future` | = note: the return type of a function must have a statically known size -error: type parameter `T` is part of concrete type but not used in parameter list for existential type +error: type parameter `T` is part of concrete type but not used in parameter list for the `impl Trait` type alias --> $DIR/issue-55872-2.rs:14:28 | LL | fn foo<T>() -> Self::E { diff --git a/src/test/ui/impl-trait/issue-55872.rs b/src/test/ui/impl-trait/issue-55872.rs index 95604545c37..bc91aae70c7 100644 --- a/src/test/ui/impl-trait/issue-55872.rs +++ b/src/test/ui/impl-trait/issue-55872.rs @@ -1,5 +1,5 @@ // ignore-tidy-linelength -#![feature(existential_type)] +#![feature(type_alias_impl_trait)] pub trait Bar { type E: Copy; @@ -8,10 +8,10 @@ pub trait Bar { } impl<S> Bar for S { - existential type E: Copy; + type E = impl Copy; fn foo<T>() -> Self::E { - //~^ ERROR type parameter `T` is part of concrete type but not used in parameter list for existential type + //~^ ERROR type parameter `T` is part of concrete type but not used in parameter list for the `impl Trait` type alias || () } } diff --git a/src/test/ui/impl-trait/issue-55872.stderr b/src/test/ui/impl-trait/issue-55872.stderr index 487f276e317..60654ec3461 100644 --- a/src/test/ui/impl-trait/issue-55872.stderr +++ b/src/test/ui/impl-trait/issue-55872.stderr @@ -1,4 +1,4 @@ -error: type parameter `T` is part of concrete type but not used in parameter list for existential type +error: type parameter `T` is part of concrete type but not used in parameter list for the `impl Trait` type alias --> $DIR/issue-55872.rs:13:28 | LL | fn foo<T>() -> Self::E { diff --git a/src/test/ui/impl-trait/issues/issue-53457.rs b/src/test/ui/impl-trait/issues/issue-53457.rs index 3f6a4fb2787..de8c579743f 100644 --- a/src/test/ui/impl-trait/issues/issue-53457.rs +++ b/src/test/ui/impl-trait/issues/issue-53457.rs @@ -1,8 +1,8 @@ // run-pass -#![feature(existential_type)] +#![feature(type_alias_impl_trait)] -existential type X: Clone; +type X = impl Clone; fn bar<F: Fn(&i32) + Clone>(f: F) -> F { f diff --git a/src/test/ui/impl-trait/multiple-lifetimes/error-handling.rs b/src/test/ui/impl-trait/multiple-lifetimes/error-handling.rs index 61e858ee02d..b226cf058aa 100644 --- a/src/test/ui/impl-trait/multiple-lifetimes/error-handling.rs +++ b/src/test/ui/impl-trait/multiple-lifetimes/error-handling.rs @@ -1,14 +1,14 @@ // compile-flags:-Zborrowck=mir #![feature(member_constraints)] -#![feature(existential_type)] +#![feature(type_alias_impl_trait)] #[derive(Clone)] struct CopyIfEq<T, U>(T, U); impl<T: Copy> Copy for CopyIfEq<T, T> {} -existential type E<'a, 'b>: Sized; +type E<'a, 'b> = impl Sized; fn foo<'a, 'b, 'c>(x: &'static i32, mut y: &'a i32) -> E<'b, 'c> { //~^ ERROR lifetime may not live long enough diff --git a/src/test/ui/impl-trait/multiple-lifetimes/error-handling.stderr b/src/test/ui/impl-trait/multiple-lifetimes/error-handling.stderr index b59dfbe9f2a..f27e6ff44a6 100644 --- a/src/test/ui/impl-trait/multiple-lifetimes/error-handling.stderr +++ b/src/test/ui/impl-trait/multiple-lifetimes/error-handling.stderr @@ -5,7 +5,7 @@ LL | fn foo<'a, 'b, 'c>(x: &'static i32, mut y: &'a i32) -> E<'b, 'c> { | -- lifetime `'a` defined here ^^^^^^^^^ opaque type requires that `'a` must outlive `'static` help: to allow this `impl Trait` to capture borrowed data with lifetime `'a`, add `'a` as a constraint | -LL | existential type E<'a, 'b>: Sized; + 'a +LL | type E<'a, 'b> = impl Sized; + 'a | error: aborting due to previous error diff --git a/src/test/ui/impl-trait/multiple-lifetimes/ordinary-bounds-pick-original-existential.rs b/src/test/ui/impl-trait/multiple-lifetimes/ordinary-bounds-pick-original-type-alias-impl-trait.rs index 43915e05e88..ae44b371f4f 100644 --- a/src/test/ui/impl-trait/multiple-lifetimes/ordinary-bounds-pick-original-existential.rs +++ b/src/test/ui/impl-trait/multiple-lifetimes/ordinary-bounds-pick-original-type-alias-impl-trait.rs @@ -4,7 +4,7 @@ //[mir]compile-flags: -Z borrowck=mir #![feature(member_constraints)] -#![feature(existential_type)] +#![feature(type_alias_impl_trait)] trait Trait<'a, 'b> { } impl<T> Trait<'_, '_> for T { } @@ -12,7 +12,7 @@ impl<T> Trait<'_, '_> for T { } // Here we wind up selecting `'a` and `'b` in the hidden type because // those are the types that appear in the original values. -existential type Foo<'a, 'b>: Trait<'a, 'b>; +type Foo<'a, 'b> = impl Trait<'a, 'b>; fn upper_bounds<'a, 'b>(a: &'a u8, b: &'b u8) -> Foo<'a, 'b> { // In this simple case, you have a hidden type `(&'0 u8, &'1 u8)` and constraints like diff --git a/src/test/ui/impl-trait/existential-minimal.rs b/src/test/ui/impl-trait/return-position-impl-trait-minimal.rs index 6d3c0692970..6d3c0692970 100644 --- a/src/test/ui/impl-trait/existential-minimal.rs +++ b/src/test/ui/impl-trait/return-position-impl-trait-minimal.rs diff --git a/src/test/ui/impl-trait/existential_type_in_fn_body.rs b/src/test/ui/impl-trait/type-alias-impl-trait-in-fn-body.rs index 32fc4a97ef4..91be4efd56a 100644 --- a/src/test/ui/impl-trait/existential_type_in_fn_body.rs +++ b/src/test/ui/impl-trait/type-alias-impl-trait-in-fn-body.rs @@ -1,11 +1,11 @@ // build-pass (FIXME(62277): could be check-pass?) -#![feature(existential_type)] +#![feature(type_alias_impl_trait)] use std::fmt::Debug; fn main() { - existential type Existential: Debug; + type Existential = impl Debug; fn f() -> Existential {} println!("{:?}", f()); diff --git a/src/test/ui/impl-trait/where-allowed.rs b/src/test/ui/impl-trait/where-allowed.rs index 31bc9f449a0..9eac6b714de 100644 --- a/src/test/ui/impl-trait/where-allowed.rs +++ b/src/test/ui/impl-trait/where-allowed.rs @@ -120,7 +120,8 @@ trait DummyTrait { } impl DummyTrait for () { type Out = impl Debug; - //~^ ERROR `impl Trait` not allowed outside of function and inherent method return types + //~^ ERROR `impl Trait` in type aliases is unstable + //~^^ ERROR could not find defining uses fn in_trait_impl_parameter(_: impl Debug) { } // Allowed @@ -155,7 +156,8 @@ extern "C" fn in_extern_fn_return() -> impl Debug { } type InTypeAlias<R> = impl Debug; -//~^ ERROR `impl Trait` not allowed outside of function and inherent method return types +//~^ ERROR `impl Trait` in type aliases is unstable +//~^^ ERROR could not find defining uses type InReturnInTypeAlias<R> = fn() -> impl Debug; //~^ ERROR `impl Trait` not allowed outside of function and inherent method return types diff --git a/src/test/ui/impl-trait/where-allowed.stderr b/src/test/ui/impl-trait/where-allowed.stderr index 9895b028a4e..1332fff84f5 100644 --- a/src/test/ui/impl-trait/where-allowed.stderr +++ b/src/test/ui/impl-trait/where-allowed.stderr @@ -16,6 +16,24 @@ LL | fn in_impl_Fn_parameter_in_return() -> &'static impl Fn(impl Debug) { panic | | nested `impl Trait` here | outer `impl Trait` +error[E0658]: `impl Trait` in type aliases is unstable + --> $DIR/where-allowed.rs:122:5 + | +LL | type Out = impl Debug; + | ^^^^^^^^^^^^^^^^^^^^^^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/63063 + = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable + +error[E0658]: `impl Trait` in type aliases is unstable + --> $DIR/where-allowed.rs:158:1 + | +LL | type InTypeAlias<R> = impl Debug; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/63063 + = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable + error[E0562]: `impl Trait` not allowed outside of function and inherent method return types --> $DIR/where-allowed.rs:18:40 | @@ -137,97 +155,85 @@ LL | fn in_return() -> impl Debug; | ^^^^^^^^^^ error[E0562]: `impl Trait` not allowed outside of function and inherent method return types - --> $DIR/where-allowed.rs:122:16 - | -LL | type Out = impl Debug; - | ^^^^^^^^^^ - -error[E0562]: `impl Trait` not allowed outside of function and inherent method return types - --> $DIR/where-allowed.rs:128:34 + --> $DIR/where-allowed.rs:129:34 | LL | fn in_trait_impl_return() -> impl Debug { () } | ^^^^^^^^^^ error[E0562]: `impl Trait` not allowed outside of function and inherent method return types - --> $DIR/where-allowed.rs:141:33 + --> $DIR/where-allowed.rs:142:33 | LL | fn in_foreign_parameters(_: impl Debug); | ^^^^^^^^^^ error[E0562]: `impl Trait` not allowed outside of function and inherent method return types - --> $DIR/where-allowed.rs:144:31 + --> $DIR/where-allowed.rs:145:31 | LL | fn in_foreign_return() -> impl Debug; | ^^^^^^^^^^ error[E0562]: `impl Trait` not allowed outside of function and inherent method return types - --> $DIR/where-allowed.rs:157:23 - | -LL | type InTypeAlias<R> = impl Debug; - | ^^^^^^^^^^ - -error[E0562]: `impl Trait` not allowed outside of function and inherent method return types - --> $DIR/where-allowed.rs:160:39 + --> $DIR/where-allowed.rs:162:39 | LL | type InReturnInTypeAlias<R> = fn() -> impl Debug; | ^^^^^^^^^^ error[E0562]: `impl Trait` not allowed outside of function and inherent method return types - --> $DIR/where-allowed.rs:164:16 + --> $DIR/where-allowed.rs:166:16 | LL | impl PartialEq<impl Debug> for () { | ^^^^^^^^^^ error[E0562]: `impl Trait` not allowed outside of function and inherent method return types - --> $DIR/where-allowed.rs:169:24 + --> $DIR/where-allowed.rs:171:24 | LL | impl PartialEq<()> for impl Debug { | ^^^^^^^^^^ error[E0562]: `impl Trait` not allowed outside of function and inherent method return types - --> $DIR/where-allowed.rs:174:6 + --> $DIR/where-allowed.rs:176:6 | LL | impl impl Debug { | ^^^^^^^^^^ error[E0562]: `impl Trait` not allowed outside of function and inherent method return types - --> $DIR/where-allowed.rs:180:24 + --> $DIR/where-allowed.rs:182:24 | LL | impl InInherentImplAdt<impl Debug> { | ^^^^^^^^^^ error[E0562]: `impl Trait` not allowed outside of function and inherent method return types - --> $DIR/where-allowed.rs:186:11 + --> $DIR/where-allowed.rs:188:11 | LL | where impl Debug: Debug | ^^^^^^^^^^ error[E0562]: `impl Trait` not allowed outside of function and inherent method return types - --> $DIR/where-allowed.rs:193:15 + --> $DIR/where-allowed.rs:195:15 | LL | where Vec<impl Debug>: Debug | ^^^^^^^^^^ error[E0562]: `impl Trait` not allowed outside of function and inherent method return types - --> $DIR/where-allowed.rs:200:24 + --> $DIR/where-allowed.rs:202:24 | LL | where T: PartialEq<impl Debug> | ^^^^^^^^^^ error[E0562]: `impl Trait` not allowed outside of function and inherent method return types - --> $DIR/where-allowed.rs:207:17 + --> $DIR/where-allowed.rs:209:17 | LL | where T: Fn(impl Debug) | ^^^^^^^^^^ error[E0562]: `impl Trait` not allowed outside of function and inherent method return types - --> $DIR/where-allowed.rs:214:22 + --> $DIR/where-allowed.rs:216:22 | LL | where T: Fn() -> impl Debug | ^^^^^^^^^^ error[E0562]: `impl Trait` not allowed outside of function and inherent method return types - --> $DIR/where-allowed.rs:220:29 + --> $DIR/where-allowed.rs:222:29 | LL | let _in_local_variable: impl Fn() = || {}; | ^^^^^^^^^ @@ -235,11 +241,24 @@ LL | let _in_local_variable: impl Fn() = || {}; = help: add `#![feature(impl_trait_in_bindings)]` to the crate attributes to enable error[E0562]: `impl Trait` not allowed outside of function and inherent method return types - --> $DIR/where-allowed.rs:222:46 + --> $DIR/where-allowed.rs:224:46 | LL | let _in_return_in_local_variable = || -> impl Fn() { || {} }; | ^^^^^^^^^ -error: aborting due to 39 previous errors +error: could not find defining uses + --> $DIR/where-allowed.rs:158:1 + | +LL | type InTypeAlias<R> = impl Debug; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: could not find defining uses + --> $DIR/where-allowed.rs:122:5 + | +LL | type Out = impl Debug; + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 41 previous errors -For more information about this error, try `rustc --explain E0562`. +Some errors have detailed explanations: E0562, E0658. +For more information about an error, try `rustc --explain E0562`. diff --git a/src/test/ui/in-band-lifetimes.rs b/src/test/ui/in-band-lifetimes.rs index c9f7d28699e..9b2e1fe83c1 100644 --- a/src/test/ui/in-band-lifetimes.rs +++ b/src/test/ui/in-band-lifetimes.rs @@ -77,19 +77,19 @@ fn impl_trait_in_band(x: &impl MyTrait<'a>) {} trait FunkyTrait<'a> { } impl<'a, T> FunkyTrait<'a> for T { } -fn existential_impl_trait_in_band_outlives(x: &'a u32) -> impl ::std::fmt::Debug + 'a { +fn ret_pos_impl_trait_in_band_outlives(x: &'a u32) -> impl ::std::fmt::Debug + 'a { x } -fn existential_impl_trait_in_band_param(x: &'a u32) -> impl FunkyTrait<'a> { +fn ret_pos_impl_trait_in_band_param(x: &'a u32) -> impl FunkyTrait<'a> { x } -fn existential_impl_trait_in_band_param_static(x: &'a u32) -> impl FunkyTrait<'static> + 'a { +fn ret_pos_impl_trait_in_band_param_static(x: &'a u32) -> impl FunkyTrait<'static> + 'a { x } -fn existential_impl_trait_in_band_param_outlives(x: &'a u32) -> impl FunkyTrait<'a> + 'a { +fn ret_pos_impl_trait_in_band_param_outlives(x: &'a u32) -> impl FunkyTrait<'a> + 'a { x } -fn existential_impl_trait_in_band_higher_ranked(x: &'a u32) -> impl for<'b> FunkyTrait<'b> + 'a { +fn ret_pos_impl_trait_in_band_higher_ranked(x: &'a u32) -> impl for<'b> FunkyTrait<'b> + 'a { x } diff --git a/src/test/ui/issues/issue-58856-2.rs b/src/test/ui/issues/issue-58856-2.rs index acc38e4c201..745f0300bd5 100644 --- a/src/test/ui/issues/issue-58856-2.rs +++ b/src/test/ui/issues/issue-58856-2.rs @@ -9,6 +9,6 @@ impl Howness for () { Empty } } -//~^ ERROR expected one of `async`, `const`, `crate`, `default`, `existential`, `extern`, `fn`, +//~^ ERROR expected one of `async`, `const`, `crate`, `default`, `extern`, `fn`, fn main() {} diff --git a/src/test/ui/issues/issue-58856-2.stderr b/src/test/ui/issues/issue-58856-2.stderr index b760fd6768a..a83dd674a87 100644 --- a/src/test/ui/issues/issue-58856-2.stderr +++ b/src/test/ui/issues/issue-58856-2.stderr @@ -7,11 +7,11 @@ LL | fn how_are_you(&self -> Empty { | | help: `)` may belong here | unclosed delimiter -error: expected one of `async`, `const`, `crate`, `default`, `existential`, `extern`, `fn`, `pub`, `type`, `unsafe`, or `}`, found `)` +error: expected one of `async`, `const`, `crate`, `default`, `extern`, `fn`, `pub`, `type`, `unsafe`, or `}`, found `)` --> $DIR/issue-58856-2.rs:11:1 | LL | } - | - expected one of 11 possible tokens here + | - expected one of 10 possible tokens here LL | } | ^ unexpected token diff --git a/src/test/ui/issues/issue-60662.rs b/src/test/ui/issues/issue-60662.rs index dca1e5979ef..dcf935c5780 100644 --- a/src/test/ui/issues/issue-60662.rs +++ b/src/test/ui/issues/issue-60662.rs @@ -1,11 +1,11 @@ // build-pass (FIXME(62277): could be check-pass?) // compile-flags: -Z unpretty=hir -#![feature(existential_type)] +#![feature(type_alias_impl_trait)] trait Animal { } fn main() { - pub existential type ServeFut: Animal; + pub type ServeFut = impl Animal; } diff --git a/src/test/ui/issues/issue-60662.stdout b/src/test/ui/issues/issue-60662.stdout index 139808974c6..e2a88dec97f 100644 --- a/src/test/ui/issues/issue-60662.stdout +++ b/src/test/ui/issues/issue-60662.stdout @@ -1,7 +1,7 @@ // build-pass (FIXME(62277): could be check-pass?) // compile-flags: -Z unpretty=hir -#![feature(existential_type)] +#![feature(type_alias_impl_trait)] #[prelude_import] use ::std::prelude::v1::*; #[macro_use] @@ -10,5 +10,5 @@ extern crate std; trait Animal { } fn main() { - pub existential type ServeFut : Animal; + pub type ServeFut = impl Animal; } diff --git a/src/test/ui/parser/default.stderr b/src/test/ui/parser/default.stderr index ded088acfc4..e199045134e 100644 --- a/src/test/ui/parser/default.stderr +++ b/src/test/ui/parser/default.stderr @@ -1,8 +1,8 @@ -error: expected one of `async`, `const`, `existential`, `extern`, `fn`, `type`, or `unsafe`, found `pub` +error: expected one of `async`, `const`, `extern`, `fn`, `type`, or `unsafe`, found `pub` --> $DIR/default.rs:22:13 | LL | default pub fn foo<T: Default>() -> T { T::default() } - | ^^^ expected one of 7 possible tokens here + | ^^^ expected one of `async`, `const`, `extern`, `fn`, `type`, or `unsafe` here error[E0449]: unnecessary visibility qualifier --> $DIR/default.rs:16:5 diff --git a/src/test/ui/parser/issue-20711-2.rs b/src/test/ui/parser/issue-20711-2.rs index 49b8de03c37..0063a334182 100644 --- a/src/test/ui/parser/issue-20711-2.rs +++ b/src/test/ui/parser/issue-20711-2.rs @@ -1,11 +1,9 @@ -// ignore-tidy-linelength - struct Foo; impl Foo { fn foo() {} #[stable(feature = "rust1", since = "1.0.0")] -} //~ ERROR expected one of `async`, `const`, `crate`, `default`, `existential`, `extern`, `fn`, `pub`, `type`, or +} //~ ERROR expected one of `async`, `const`, `crate`, `default`, `extern`, `fn`, `pub`, `type`, or fn main() {} diff --git a/src/test/ui/parser/issue-20711-2.stderr b/src/test/ui/parser/issue-20711-2.stderr index f67dfa09aca..56749c107d1 100644 --- a/src/test/ui/parser/issue-20711-2.stderr +++ b/src/test/ui/parser/issue-20711-2.stderr @@ -1,8 +1,8 @@ -error: expected one of `async`, `const`, `crate`, `default`, `existential`, `extern`, `fn`, `pub`, `type`, or `unsafe`, found `}` - --> $DIR/issue-20711-2.rs:9:1 +error: expected one of `async`, `const`, `crate`, `default`, `extern`, `fn`, `pub`, `type`, or `unsafe`, found `}` + --> $DIR/issue-20711-2.rs:7:1 | LL | #[stable(feature = "rust1", since = "1.0.0")] - | - expected one of 10 possible tokens here + | - expected one of 9 possible tokens here LL | } | ^ unexpected token diff --git a/src/test/ui/parser/issue-20711.rs b/src/test/ui/parser/issue-20711.rs index 8d8401da61a..dc216167b8a 100644 --- a/src/test/ui/parser/issue-20711.rs +++ b/src/test/ui/parser/issue-20711.rs @@ -1,9 +1,7 @@ -// ignore-tidy-linelength - struct Foo; impl Foo { #[stable(feature = "rust1", since = "1.0.0")] -} //~ ERROR expected one of `async`, `const`, `crate`, `default`, `existential`, `extern`, `fn`, `pub`, `type`, or +} //~ ERROR expected one of `async`, `const`, `crate`, `default`, `extern`, `fn`, `pub`, `type`, or fn main() {} diff --git a/src/test/ui/parser/issue-20711.stderr b/src/test/ui/parser/issue-20711.stderr index 26b819fa298..f7b99a91b51 100644 --- a/src/test/ui/parser/issue-20711.stderr +++ b/src/test/ui/parser/issue-20711.stderr @@ -1,8 +1,8 @@ -error: expected one of `async`, `const`, `crate`, `default`, `existential`, `extern`, `fn`, `pub`, `type`, or `unsafe`, found `}` - --> $DIR/issue-20711.rs:7:1 +error: expected one of `async`, `const`, `crate`, `default`, `extern`, `fn`, `pub`, `type`, or `unsafe`, found `}` + --> $DIR/issue-20711.rs:5:1 | LL | #[stable(feature = "rust1", since = "1.0.0")] - | - expected one of 10 possible tokens here + | - expected one of 9 possible tokens here LL | } | ^ unexpected token diff --git a/src/test/ui/parser/issue-41155.stderr b/src/test/ui/parser/issue-41155.stderr index 719845e6999..624d1a3d11e 100644 --- a/src/test/ui/parser/issue-41155.stderr +++ b/src/test/ui/parser/issue-41155.stderr @@ -1,8 +1,8 @@ -error: expected one of `(`, `async`, `const`, `default`, `existential`, `extern`, `fn`, `type`, or `unsafe`, found `}` +error: expected one of `(`, `async`, `const`, `default`, `extern`, `fn`, `type`, or `unsafe`, found `}` --> $DIR/issue-41155.rs:5:1 | LL | pub - | - expected one of 9 possible tokens here + | - expected one of 8 possible tokens here LL | } | ^ unexpected token diff --git a/src/test/ui/parser/removed-syntax-static-fn.rs b/src/test/ui/parser/removed-syntax-static-fn.rs index df3964196b8..0caddb9855d 100644 --- a/src/test/ui/parser/removed-syntax-static-fn.rs +++ b/src/test/ui/parser/removed-syntax-static-fn.rs @@ -1,10 +1,8 @@ -// ignore-tidy-linelength - struct S; impl S { static fn f() {} + //~^ ERROR expected one of `async`, `const`, `crate`, `default`, `extern`, `fn`, `pub`, `type`, } -//~^^ ERROR expected one of `async`, `const`, `crate`, `default`, `existential`, `extern`, `fn`, `pub`, `type`, fn main() {} diff --git a/src/test/ui/parser/removed-syntax-static-fn.stderr b/src/test/ui/parser/removed-syntax-static-fn.stderr index 84e0432c48c..21cb71df657 100644 --- a/src/test/ui/parser/removed-syntax-static-fn.stderr +++ b/src/test/ui/parser/removed-syntax-static-fn.stderr @@ -1,8 +1,8 @@ -error: expected one of `async`, `const`, `crate`, `default`, `existential`, `extern`, `fn`, `pub`, `type`, `unsafe`, or `}`, found `static` - --> $DIR/removed-syntax-static-fn.rs:6:5 +error: expected one of `async`, `const`, `crate`, `default`, `extern`, `fn`, `pub`, `type`, `unsafe`, or `}`, found `static` + --> $DIR/removed-syntax-static-fn.rs:4:5 | LL | impl S { - | - expected one of 11 possible tokens here + | - expected one of 10 possible tokens here LL | static fn f() {} | ^^^^^^ unexpected token diff --git a/src/test/ui/privacy/private-in-public-assoc-ty.rs b/src/test/ui/privacy/private-in-public-assoc-ty.rs index 81d23959fd4..3c42f24d5ff 100644 --- a/src/test/ui/privacy/private-in-public-assoc-ty.rs +++ b/src/test/ui/privacy/private-in-public-assoc-ty.rs @@ -1,7 +1,8 @@ // Private types and traits are not allowed in interfaces of associated types. // This test also ensures that the checks are performed even inside private modules. -#![feature(associated_type_defaults, existential_type)] +#![feature(associated_type_defaults)] +#![feature(type_alias_impl_trait)] mod m { struct Priv; @@ -31,7 +32,7 @@ mod m { type Alias1 = Priv; //~^ ERROR private type `m::Priv` in public interface - existential type Exist: PrivTr; + type Exist = impl PrivTr; //~^ ERROR private trait `m::PrivTr` in public interface fn infer_exist() -> Self::Exist { Priv } } diff --git a/src/test/ui/privacy/private-in-public-assoc-ty.stderr b/src/test/ui/privacy/private-in-public-assoc-ty.stderr index 0b32e4cd306..158862f9228 100644 --- a/src/test/ui/privacy/private-in-public-assoc-ty.stderr +++ b/src/test/ui/privacy/private-in-public-assoc-ty.stderr @@ -1,5 +1,5 @@ warning: private trait `m::PrivTr` in public interface (error E0445) - --> $DIR/private-in-public-assoc-ty.rs:15:5 + --> $DIR/private-in-public-assoc-ty.rs:16:5 | LL | / pub trait PubTr { LL | | @@ -15,7 +15,7 @@ LL | | } = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537> warning: private type `m::Priv` in public interface (error E0446) - --> $DIR/private-in-public-assoc-ty.rs:15:5 + --> $DIR/private-in-public-assoc-ty.rs:16:5 | LL | / pub trait PubTr { LL | | @@ -30,7 +30,7 @@ LL | | } = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537> error[E0446]: private type `m::Priv` in public interface - --> $DIR/private-in-public-assoc-ty.rs:24:9 + --> $DIR/private-in-public-assoc-ty.rs:25:9 | LL | struct Priv; | - `m::Priv` declared as private @@ -39,7 +39,7 @@ LL | type Alias4 = Priv; | ^^^^^^^^^^^^^^^^^^^ can't leak private type error[E0446]: private type `m::Priv` in public interface - --> $DIR/private-in-public-assoc-ty.rs:31:9 + --> $DIR/private-in-public-assoc-ty.rs:32:9 | LL | struct Priv; | - `m::Priv` declared as private @@ -48,13 +48,13 @@ LL | type Alias1 = Priv; | ^^^^^^^^^^^^^^^^^^^ can't leak private type error[E0445]: private trait `m::PrivTr` in public interface - --> $DIR/private-in-public-assoc-ty.rs:34:9 + --> $DIR/private-in-public-assoc-ty.rs:35:9 | LL | trait PrivTr {} | - `m::PrivTr` declared as private ... -LL | existential type Exist: PrivTr; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private trait +LL | type Exist = impl PrivTr; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private trait error: aborting due to 3 previous errors diff --git a/src/test/ui/privacy/private-in-public-existential.rs b/src/test/ui/privacy/private-in-public-type-alias-impl-trait.rs index ef50875dcf6..40bba720b0f 100644 --- a/src/test/ui/privacy/private-in-public-existential.rs +++ b/src/test/ui/privacy/private-in-public-type-alias-impl-trait.rs @@ -1,9 +1,9 @@ // build-pass (FIXME(62277): could be check-pass?) -#![feature(existential_type)] +#![feature(type_alias_impl_trait)] #![deny(private_in_public)] -pub existential type Pub: Default; +pub type Pub = impl Default; #[derive(Default)] struct Priv; @@ -18,7 +18,7 @@ pub trait Trait { } impl Trait for u8 { - existential type Pub: Default; + type Pub = impl Default; fn method() -> Self::Pub { Priv } } diff --git a/src/test/ui/traits/trait-bounds-in-arc.rs b/src/test/ui/traits/trait-bounds-in-arc.rs index a45d834297e..941f66c0561 100644 --- a/src/test/ui/traits/trait-bounds-in-arc.rs +++ b/src/test/ui/traits/trait-bounds-in-arc.rs @@ -1,6 +1,6 @@ // run-pass #![allow(unused_must_use)] -// Tests that a heterogeneous list of existential types can be put inside an Arc +// Tests that a heterogeneous list of existential `dyn` types can be put inside an Arc // and shared between threads as long as all types fulfill Send. // ignore-emscripten no threads support diff --git a/src/test/ui/existential_types/existential-associated-type.rs b/src/test/ui/type-alias-impl-trait/associated-type-alias-impl-trait.rs index bfb91f68ffd..42f07d49ffe 100644 --- a/src/test/ui/existential_types/existential-associated-type.rs +++ b/src/test/ui/type-alias-impl-trait/associated-type-alias-impl-trait.rs @@ -1,4 +1,4 @@ -#![feature(existential_type)] +#![feature(type_alias_impl_trait)] // build-pass (FIXME(62277): could be check-pass?) trait Bar {} @@ -11,7 +11,7 @@ trait Foo { fn bar() -> Self::Assoc; } -existential type Helper: Bar; +type Helper = impl Bar; impl Foo for i32 { type Assoc = Helper; diff --git a/src/test/ui/type-alias-impl-trait/auxiliary/cross_crate_ice.rs b/src/test/ui/type-alias-impl-trait/auxiliary/cross_crate_ice.rs new file mode 100644 index 00000000000..f61807cbdbd --- /dev/null +++ b/src/test/ui/type-alias-impl-trait/auxiliary/cross_crate_ice.rs @@ -0,0 +1,11 @@ +// Crate that exports an opaque `impl Trait` type. Used for testing cross-crate. + +#![crate_type="rlib"] + +#![feature(type_alias_impl_trait)] + +pub type Foo = impl std::fmt::Debug; + +pub fn foo() -> Foo { + 5 +} diff --git a/src/test/ui/existential_types/auxiliary/cross_crate_ice2.rs b/src/test/ui/type-alias-impl-trait/auxiliary/cross_crate_ice2.rs index 39ec5394feb..00823456267 100644 --- a/src/test/ui/existential_types/auxiliary/cross_crate_ice2.rs +++ b/src/test/ui/type-alias-impl-trait/auxiliary/cross_crate_ice2.rs @@ -1,8 +1,8 @@ -// Crate that exports an existential type. Used for testing cross-crate. +// Crate that exports an opaque `impl Trait` type. Used for testing cross-crate. #![crate_type="rlib"] -#![feature(existential_type)] +#![feature(type_alias_impl_trait)] pub trait View { type Tmp: Iterator<Item = u32>; @@ -13,7 +13,7 @@ pub trait View { pub struct X; impl View for X { - existential type Tmp: Iterator<Item = u32>; + type Tmp = impl Iterator<Item = u32>; fn test(&self) -> Self::Tmp { vec![1,2,3].into_iter() diff --git a/src/test/ui/existential_types/bound_reduction.rs b/src/test/ui/type-alias-impl-trait/bound_reduction.rs index 46bc17293bc..18c840d8ed9 100644 --- a/src/test/ui/existential_types/bound_reduction.rs +++ b/src/test/ui/type-alias-impl-trait/bound_reduction.rs @@ -2,12 +2,12 @@ #![allow(warnings)] -#![feature(existential_type)] +#![feature(type_alias_impl_trait)] fn main() { } -existential type Foo<V>: std::fmt::Debug; +type Foo<V> = impl std::fmt::Debug; trait Trait<U> {} diff --git a/src/test/ui/existential_types/bound_reduction2.rs b/src/test/ui/type-alias-impl-trait/bound_reduction2.rs index 542e076d88d..919446877a1 100644 --- a/src/test/ui/existential_types/bound_reduction2.rs +++ b/src/test/ui/type-alias-impl-trait/bound_reduction2.rs @@ -1,4 +1,4 @@ -#![feature(existential_type)] +#![feature(type_alias_impl_trait)] fn main() { } @@ -7,7 +7,7 @@ trait TraitWithAssoc { type Assoc; } -existential type Foo<V>: Trait<V>; +type Foo<V> = impl Trait<V>; //~^ ERROR could not find defining uses trait Trait<U> {} diff --git a/src/test/ui/existential_types/bound_reduction2.stderr b/src/test/ui/type-alias-impl-trait/bound_reduction2.stderr index b8bad7db6b6..886d17aca36 100644 --- a/src/test/ui/existential_types/bound_reduction2.stderr +++ b/src/test/ui/type-alias-impl-trait/bound_reduction2.stderr @@ -1,4 +1,4 @@ -error: defining existential type use does not fully define existential type +error: defining opaque type use does not fully define opaque type --> $DIR/bound_reduction2.rs:17:1 | LL | / fn foo_desugared<T: TraitWithAssoc>(_: T) -> Foo<T::Assoc> { @@ -9,8 +9,8 @@ LL | | } error: could not find defining uses --> $DIR/bound_reduction2.rs:10:1 | -LL | existential type Foo<V>: Trait<V>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | type Foo<V> = impl Trait<V>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/src/test/ui/existential_types/cross_crate_ice.rs b/src/test/ui/type-alias-impl-trait/cross_crate_ice.rs index c30608176aa..c30608176aa 100644 --- a/src/test/ui/existential_types/cross_crate_ice.rs +++ b/src/test/ui/type-alias-impl-trait/cross_crate_ice.rs diff --git a/src/test/ui/existential_types/cross_crate_ice2.rs b/src/test/ui/type-alias-impl-trait/cross_crate_ice2.rs index 3a7e490260f..3a7e490260f 100644 --- a/src/test/ui/existential_types/cross_crate_ice2.rs +++ b/src/test/ui/type-alias-impl-trait/cross_crate_ice2.rs diff --git a/src/test/ui/type-alias-impl-trait/declared_but_never_defined.rs b/src/test/ui/type-alias-impl-trait/declared_but_never_defined.rs new file mode 100644 index 00000000000..c4bf56a9197 --- /dev/null +++ b/src/test/ui/type-alias-impl-trait/declared_but_never_defined.rs @@ -0,0 +1,6 @@ +#![feature(type_alias_impl_trait)] + +fn main() {} + +// declared but never defined +type Bar = impl std::fmt::Debug; //~ ERROR could not find defining uses diff --git a/src/test/ui/existential_types/declared_but_never_defined.stderr b/src/test/ui/type-alias-impl-trait/declared_but_never_defined.stderr index 7294a074db6..ae0fee4333b 100644 --- a/src/test/ui/existential_types/declared_but_never_defined.stderr +++ b/src/test/ui/type-alias-impl-trait/declared_but_never_defined.stderr @@ -1,8 +1,8 @@ error: could not find defining uses --> $DIR/declared_but_never_defined.rs:6:1 | -LL | existential type Bar: std::fmt::Debug; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | type Bar = impl std::fmt::Debug; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/type-alias-impl-trait/declared_but_not_defined_in_scope.rs b/src/test/ui/type-alias-impl-trait/declared_but_not_defined_in_scope.rs new file mode 100644 index 00000000000..09873a8c8c3 --- /dev/null +++ b/src/test/ui/type-alias-impl-trait/declared_but_not_defined_in_scope.rs @@ -0,0 +1,12 @@ +#![feature(type_alias_impl_trait)] + +fn main() {} + +mod boo { + // declared in module but not defined inside of it + pub type Boo = impl ::std::fmt::Debug; //~ ERROR could not find defining uses +} + +fn bomp() -> boo::Boo { + "" +} diff --git a/src/test/ui/existential_types/declared_but_not_defined_in_scope.stderr b/src/test/ui/type-alias-impl-trait/declared_but_not_defined_in_scope.stderr index a72709f7194..0642407aba3 100644 --- a/src/test/ui/existential_types/declared_but_not_defined_in_scope.stderr +++ b/src/test/ui/type-alias-impl-trait/declared_but_not_defined_in_scope.stderr @@ -1,8 +1,8 @@ error: could not find defining uses --> $DIR/declared_but_not_defined_in_scope.rs:7:5 | -LL | pub existential type Boo: ::std::fmt::Debug; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | pub type Boo = impl ::std::fmt::Debug; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/existential_types/different_defining_uses.rs b/src/test/ui/type-alias-impl-trait/different_defining_uses.rs index a8670cc07f2..2d7780a126c 100644 --- a/src/test/ui/existential_types/different_defining_uses.rs +++ b/src/test/ui/type-alias-impl-trait/different_defining_uses.rs @@ -1,9 +1,9 @@ -#![feature(existential_type)] +#![feature(type_alias_impl_trait)] fn main() {} // two definitions with different types -existential type Foo: std::fmt::Debug; +type Foo = impl std::fmt::Debug; fn foo() -> Foo { "" diff --git a/src/test/ui/existential_types/different_defining_uses.stderr b/src/test/ui/type-alias-impl-trait/different_defining_uses.stderr index fddba584798..87ed997ec59 100644 --- a/src/test/ui/existential_types/different_defining_uses.stderr +++ b/src/test/ui/type-alias-impl-trait/different_defining_uses.stderr @@ -1,4 +1,4 @@ -error: concrete type differs from previous defining existential type use +error: concrete type differs from previous defining opaque type use --> $DIR/different_defining_uses.rs:12:1 | LL | / fn bar() -> Foo { diff --git a/src/test/ui/existential_types/different_defining_uses_never_type.rs b/src/test/ui/type-alias-impl-trait/different_defining_uses_never_type.rs index 13ada63e4bc..289b97b00ad 100644 --- a/src/test/ui/existential_types/different_defining_uses_never_type.rs +++ b/src/test/ui/type-alias-impl-trait/different_defining_uses_never_type.rs @@ -1,9 +1,9 @@ -#![feature(existential_type)] +#![feature(type_alias_impl_trait)] fn main() {} // two definitions with different types -existential type Foo: std::fmt::Debug; +type Foo = impl std::fmt::Debug; fn foo() -> Foo { "" diff --git a/src/test/ui/existential_types/different_defining_uses_never_type.stderr b/src/test/ui/type-alias-impl-trait/different_defining_uses_never_type.stderr index 14b7a810be2..5be656e8f44 100644 --- a/src/test/ui/existential_types/different_defining_uses_never_type.stderr +++ b/src/test/ui/type-alias-impl-trait/different_defining_uses_never_type.stderr @@ -1,4 +1,4 @@ -error: concrete type differs from previous defining existential type use +error: concrete type differs from previous defining opaque type use --> $DIR/different_defining_uses_never_type.rs:12:1 | LL | / fn bar() -> Foo { @@ -14,7 +14,7 @@ LL | | "" LL | | } | |_^ -error: concrete type differs from previous defining existential type use +error: concrete type differs from previous defining opaque type use --> $DIR/different_defining_uses_never_type.rs:16:1 | LL | / fn boo() -> Foo { diff --git a/src/test/ui/existential_types/different_defining_uses_never_type2.rs b/src/test/ui/type-alias-impl-trait/different_defining_uses_never_type2.rs index 0f02cfaad7e..8549687ea78 100644 --- a/src/test/ui/existential_types/different_defining_uses_never_type2.rs +++ b/src/test/ui/type-alias-impl-trait/different_defining_uses_never_type2.rs @@ -1,11 +1,11 @@ // build-pass (FIXME(62277): could be check-pass?) -#![feature(existential_type)] +#![feature(type_alias_impl_trait)] fn main() {} // two definitions with different types -existential type Foo: std::fmt::Debug; +type Foo = impl std::fmt::Debug; fn foo() -> Foo { "" diff --git a/src/test/ui/existential_types/generic_different_defining_uses.rs b/src/test/ui/type-alias-impl-trait/generic_different_defining_uses.rs index ce3ab88a1c0..ac87c2d446a 100644 --- a/src/test/ui/existential_types/generic_different_defining_uses.rs +++ b/src/test/ui/type-alias-impl-trait/generic_different_defining_uses.rs @@ -1,8 +1,8 @@ -#![feature(existential_type)] +#![feature(type_alias_impl_trait)] fn main() {} -existential type MyIter<T>: Iterator<Item = T>; +type MyIter<T> = impl Iterator<Item = T>; fn my_iter<T>(t: T) -> MyIter<T> { std::iter::once(t) diff --git a/src/test/ui/existential_types/generic_different_defining_uses.stderr b/src/test/ui/type-alias-impl-trait/generic_different_defining_uses.stderr index e5b1539ccbb..4bcd2e1cb12 100644 --- a/src/test/ui/existential_types/generic_different_defining_uses.stderr +++ b/src/test/ui/type-alias-impl-trait/generic_different_defining_uses.stderr @@ -1,4 +1,4 @@ -error: concrete type differs from previous defining existential type use +error: concrete type differs from previous defining opaque type use --> $DIR/generic_different_defining_uses.rs:11:1 | LL | / fn my_iter2<T>(t: T) -> MyIter<T> { diff --git a/src/test/ui/type-alias-impl-trait/generic_duplicate_lifetime_param.rs b/src/test/ui/type-alias-impl-trait/generic_duplicate_lifetime_param.rs new file mode 100644 index 00000000000..c18a7116758 --- /dev/null +++ b/src/test/ui/type-alias-impl-trait/generic_duplicate_lifetime_param.rs @@ -0,0 +1,9 @@ +#![feature(type_alias_impl_trait)] + +fn main() {} + +type Two<'a, 'b> = impl std::fmt::Debug; + +fn one<'a>(t: &'a ()) -> Two<'a, 'a> { //~ ERROR non-defining opaque type use + t +} diff --git a/src/test/ui/existential_types/generic_duplicate_lifetime_param.stderr b/src/test/ui/type-alias-impl-trait/generic_duplicate_lifetime_param.stderr index 29bd252babe..a4d9a672154 100644 --- a/src/test/ui/existential_types/generic_duplicate_lifetime_param.stderr +++ b/src/test/ui/type-alias-impl-trait/generic_duplicate_lifetime_param.stderr @@ -1,4 +1,4 @@ -error: non-defining existential type use in defining scope +error: non-defining opaque type use in defining scope --> $DIR/generic_duplicate_lifetime_param.rs:7:1 | LL | / fn one<'a>(t: &'a ()) -> Two<'a, 'a> { @@ -7,10 +7,10 @@ LL | | } | |_^ | note: lifetime used multiple times - --> $DIR/generic_duplicate_lifetime_param.rs:5:22 + --> $DIR/generic_duplicate_lifetime_param.rs:5:10 | -LL | existential type Two<'a, 'b>: std::fmt::Debug; - | ^^ ^^ +LL | type Two<'a, 'b> = impl std::fmt::Debug; + | ^^ ^^ error: aborting due to previous error diff --git a/src/test/ui/existential_types/generic_duplicate_param_use.rs b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use.rs index 3f8753333aa..165e320be5e 100644 --- a/src/test/ui/existential_types/generic_duplicate_param_use.rs +++ b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use.rs @@ -1,14 +1,14 @@ -#![feature(existential_type)] +#![feature(type_alias_impl_trait)] use std::fmt::Debug; fn main() {} // test that unused generic parameters are ok -existential type Two<T, U>: Debug; +type Two<T, U> = impl Debug; //~^ could not find defining uses fn one<T: Debug>(t: T) -> Two<T, T> { -//~^ ERROR defining existential type use restricts existential type +//~^ ERROR defining opaque type use restricts opaque type t } diff --git a/src/test/ui/existential_types/generic_duplicate_param_use.stderr b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use.stderr index a3827943b6d..e1794034e20 100644 --- a/src/test/ui/existential_types/generic_duplicate_param_use.stderr +++ b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use.stderr @@ -1,4 +1,4 @@ -error: defining existential type use restricts existential type by using the generic parameter `T` twice +error: defining opaque type use restricts opaque 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> { @@ -10,8 +10,8 @@ LL | | } error: could not find defining uses --> $DIR/generic_duplicate_param_use.rs:8:1 | -LL | existential type Two<T, U>: Debug; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | type Two<T, U> = impl Debug; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/src/test/ui/existential_types/generic_duplicate_param_use10.rs b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use10.rs index 0d9c7cdfe71..898dab1b0b9 100644 --- a/src/test/ui/existential_types/generic_duplicate_param_use10.rs +++ b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use10.rs @@ -1,11 +1,11 @@ // build-pass (FIXME(62277): could be check-pass?) -#![feature(existential_type)] +#![feature(type_alias_impl_trait)] use std::fmt::Debug; fn main() {} -existential type Two<T, U>: Debug; +type Two<T, U> = impl Debug; fn two<T: Debug, U: Debug>(t: T, _: U) -> Two<T, U> { (t, 4u32) diff --git a/src/test/ui/existential_types/generic_duplicate_param_use2.rs b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use2.rs index 3842292decd..0adce817c5c 100644 --- a/src/test/ui/existential_types/generic_duplicate_param_use2.rs +++ b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use2.rs @@ -1,14 +1,14 @@ -#![feature(existential_type)] +#![feature(type_alias_impl_trait)] use std::fmt::Debug; fn main() {} // test that unused generic parameters are ok -existential type Two<T, U>: Debug; +type Two<T, U> = impl Debug; fn one<T: Debug>(t: T) -> Two<T, T> { -//~^ defining existential type use restricts existential type +//~^ defining opaque type use restricts opaque type t } diff --git a/src/test/ui/existential_types/generic_duplicate_param_use2.stderr b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use2.stderr index 74f2802449a..a9a51fa0b4b 100644 --- a/src/test/ui/existential_types/generic_duplicate_param_use2.stderr +++ b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use2.stderr @@ -1,4 +1,4 @@ -error: defining existential type use restricts existential type by using the generic parameter `T` twice +error: defining opaque type use restricts opaque 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> { diff --git a/src/test/ui/existential_types/generic_duplicate_param_use3.rs b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use3.rs index 05c77c89473..8d3e7f9f424 100644 --- a/src/test/ui/existential_types/generic_duplicate_param_use3.rs +++ b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use3.rs @@ -1,14 +1,14 @@ -#![feature(existential_type)] +#![feature(type_alias_impl_trait)] use std::fmt::Debug; fn main() {} // test that unused generic parameters are ok -existential type Two<T, U>: Debug; +type Two<T, U> = impl Debug; fn one<T: Debug>(t: T) -> Two<T, T> { -//~^ defining existential type use restricts existential type +//~^ defining opaque type use restricts opaque type t } diff --git a/src/test/ui/existential_types/generic_duplicate_param_use3.stderr b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use3.stderr index 22d5467c363..04dcdc295f9 100644 --- a/src/test/ui/existential_types/generic_duplicate_param_use3.stderr +++ b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use3.stderr @@ -1,4 +1,4 @@ -error: defining existential type use restricts existential type by using the generic parameter `T` twice +error: defining opaque type use restricts opaque 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> { diff --git a/src/test/ui/existential_types/generic_duplicate_param_use4.rs b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use4.rs index 609dbe06cd7..65f7d7f485d 100644 --- a/src/test/ui/existential_types/generic_duplicate_param_use4.rs +++ b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use4.rs @@ -1,14 +1,14 @@ -#![feature(existential_type)] +#![feature(type_alias_impl_trait)] use std::fmt::Debug; fn main() {} // test that unused generic parameters are ok -existential type Two<T, U>: Debug; +type Two<T, U> = impl Debug; fn one<T: Debug>(t: T) -> Two<T, T> { -//~^ ERROR defining existential type use restricts existential type +//~^ ERROR defining opaque type use restricts opaque type t } diff --git a/src/test/ui/existential_types/generic_duplicate_param_use4.stderr b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use4.stderr index d7e695578d3..082177b8212 100644 --- a/src/test/ui/existential_types/generic_duplicate_param_use4.stderr +++ b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use4.stderr @@ -1,4 +1,4 @@ -error: defining existential type use restricts existential type by using the generic parameter `T` twice +error: defining opaque type use restricts opaque 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> { diff --git a/src/test/ui/existential_types/generic_duplicate_param_use5.rs b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use5.rs index 3f4a23b8b41..ac877310414 100644 --- a/src/test/ui/existential_types/generic_duplicate_param_use5.rs +++ b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use5.rs @@ -1,11 +1,11 @@ -#![feature(existential_type)] +#![feature(type_alias_impl_trait)] use std::fmt::Debug; fn main() {} // test that unused generic parameters are ok -existential type Two<T, U>: Debug; +type Two<T, U> = impl Debug; fn two<T: Debug, U: Debug>(t: T, u: U) -> Two<T, U> { (t, u) diff --git a/src/test/ui/existential_types/generic_duplicate_param_use5.stderr b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use5.stderr index cf4535d6c2c..589ea749319 100644 --- a/src/test/ui/existential_types/generic_duplicate_param_use5.stderr +++ b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use5.stderr @@ -1,4 +1,4 @@ -error: concrete type differs from previous defining existential type use +error: concrete type differs from previous defining opaque type use --> $DIR/generic_duplicate_param_use5.rs:14:1 | LL | / fn three<T: Debug, U: Debug>(t: T, u: U) -> Two<T, U> { diff --git a/src/test/ui/existential_types/generic_duplicate_param_use6.rs b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use6.rs index 3b8c56352bd..59e7de413a2 100644 --- a/src/test/ui/existential_types/generic_duplicate_param_use6.rs +++ b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use6.rs @@ -1,11 +1,11 @@ -#![feature(existential_type)] +#![feature(type_alias_impl_trait)] use std::fmt::Debug; fn main() {} // test that unused generic parameters are ok -existential type Two<T, U>: Debug; +type Two<T, U> = impl Debug; fn two<T: Debug, U: Debug>(t: T, u: U) -> Two<T, U> { (t, t) diff --git a/src/test/ui/existential_types/generic_duplicate_param_use6.stderr b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use6.stderr index 1f767dacea8..66649413d38 100644 --- a/src/test/ui/existential_types/generic_duplicate_param_use6.stderr +++ b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use6.stderr @@ -1,4 +1,4 @@ -error: concrete type differs from previous defining existential type use +error: concrete type differs from previous defining opaque type use --> $DIR/generic_duplicate_param_use6.rs:14:1 | LL | / fn three<T: Debug, U: Debug>(t: T, u: U) -> Two<T, U> { diff --git a/src/test/ui/existential_types/generic_duplicate_param_use7.rs b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use7.rs index 56e1528c213..712a6539f01 100644 --- a/src/test/ui/existential_types/generic_duplicate_param_use7.rs +++ b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use7.rs @@ -1,11 +1,11 @@ // build-pass (FIXME(62277): could be check-pass?) -#![feature(existential_type)] +#![feature(type_alias_impl_trait)] use std::fmt::Debug; fn main() {} -existential type Two<A, B>: Debug; +type Two<A, B> = impl Debug; fn two<T: Debug + Copy, U>(t: T, u: U) -> Two<T, U> { (t, t) diff --git a/src/test/ui/existential_types/generic_duplicate_param_use8.rs b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use8.rs index 83501ad8c41..777ded52609 100644 --- a/src/test/ui/existential_types/generic_duplicate_param_use8.rs +++ b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use8.rs @@ -1,10 +1,10 @@ -#![feature(existential_type)] +#![feature(type_alias_impl_trait)] use std::fmt::Debug; fn main() {} -existential type Two<T, U>: Debug; +type Two<T, U> = impl Debug; fn two<T: Debug, U: Debug>(t: T, _: U) -> Two<T, U> { (t, 4u32) diff --git a/src/test/ui/existential_types/generic_duplicate_param_use8.stderr b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use8.stderr index 58f4f97b241..8f4cf4c6084 100644 --- a/src/test/ui/existential_types/generic_duplicate_param_use8.stderr +++ b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use8.stderr @@ -1,4 +1,4 @@ -error: concrete type differs from previous defining existential type use +error: concrete type differs from previous defining opaque type use --> $DIR/generic_duplicate_param_use8.rs:13:1 | LL | / fn three<T: Debug, U: Debug>(_: T, u: U) -> Two<T, U> { diff --git a/src/test/ui/existential_types/generic_duplicate_param_use9.rs b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use9.rs index 4c6897298c4..491e6647f45 100644 --- a/src/test/ui/existential_types/generic_duplicate_param_use9.rs +++ b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use9.rs @@ -1,10 +1,10 @@ -#![feature(existential_type)] +#![feature(type_alias_impl_trait)] use std::fmt::Debug; fn main() {} -existential type Two<A, B>: Debug; +type Two<A, B> = impl Debug; trait Foo { type Bar: Debug; diff --git a/src/test/ui/existential_types/generic_duplicate_param_use9.stderr b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use9.stderr index fe4ae6cfdd0..4d0b03ba5ed 100644 --- a/src/test/ui/existential_types/generic_duplicate_param_use9.stderr +++ b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use9.stderr @@ -1,4 +1,4 @@ -error: concrete type differs from previous defining existential type use +error: concrete type differs from previous defining opaque type use --> $DIR/generic_duplicate_param_use9.rs:18:1 | LL | / fn three<T: Debug, U: Debug>(t: T, u: U) -> Two<T, U> { diff --git a/src/test/ui/existential_types/generic_lifetime_param.rs b/src/test/ui/type-alias-impl-trait/generic_lifetime_param.rs index 1ea01f17b70..e109c38c986 100644 --- a/src/test/ui/existential_types/generic_lifetime_param.rs +++ b/src/test/ui/type-alias-impl-trait/generic_lifetime_param.rs @@ -1,10 +1,10 @@ // build-pass (FIXME(62277): could be check-pass?) -#![feature(existential_type)] +#![feature(type_alias_impl_trait)] fn main() {} -existential type Region<'a>: std::fmt::Debug; +type Region<'a> = impl std::fmt::Debug; fn region<'b>(a: &'b ()) -> Region<'b> { a diff --git a/src/test/ui/existential_types/generic_nondefining_use.rs b/src/test/ui/type-alias-impl-trait/generic_nondefining_use.rs index ffc965aca47..60106eba175 100644 --- a/src/test/ui/existential_types/generic_nondefining_use.rs +++ b/src/test/ui/type-alias-impl-trait/generic_nondefining_use.rs @@ -1,13 +1,13 @@ -#![feature(existential_type)] +#![feature(type_alias_impl_trait)] fn main() {} -existential type Cmp<T>: 'static; +type Cmp<T> = impl '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 +fn cmp() -> Cmp<u32> { //~ ERROR defining opaque type use does not fully define 5u32 } diff --git a/src/test/ui/existential_types/generic_nondefining_use.stderr b/src/test/ui/type-alias-impl-trait/generic_nondefining_use.stderr index d205d44c68c..d98d349be3c 100644 --- a/src/test/ui/existential_types/generic_nondefining_use.stderr +++ b/src/test/ui/type-alias-impl-trait/generic_nondefining_use.stderr @@ -1,10 +1,10 @@ error: at least one trait must be specified - --> $DIR/generic_nondefining_use.rs:5:26 + --> $DIR/generic_nondefining_use.rs:5:20 | -LL | existential type Cmp<T>: 'static; - | ^^^^^^^ +LL | type Cmp<T> = impl 'static; + | ^^^^^^^ -error: defining existential type use does not fully define existential type +error: defining opaque type use does not fully define opaque type --> $DIR/generic_nondefining_use.rs:11:1 | LL | / fn cmp() -> Cmp<u32> { @@ -15,8 +15,8 @@ LL | | } error: could not find defining uses --> $DIR/generic_nondefining_use.rs:5:1 | -LL | existential type Cmp<T>: 'static; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | type Cmp<T> = impl 'static; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 3 previous errors diff --git a/src/test/ui/existential_types/generic_not_used.rs b/src/test/ui/type-alias-impl-trait/generic_not_used.rs index 054e6f5f2ad..ace52dc83ad 100644 --- a/src/test/ui/existential_types/generic_not_used.rs +++ b/src/test/ui/type-alias-impl-trait/generic_not_used.rs @@ -1,8 +1,8 @@ -#![feature(existential_type)] +#![feature(type_alias_impl_trait)] fn main() {} -existential type WrongGeneric<T: 'static>: 'static; +type WrongGeneric<T: 'static> = impl 'static; //~^ ERROR: at least one trait must be specified fn wrong_generic<U: 'static, V: 'static>(_: U, v: V) -> WrongGeneric<U> { diff --git a/src/test/ui/existential_types/generic_not_used.stderr b/src/test/ui/type-alias-impl-trait/generic_not_used.stderr index d243233992b..fe353f6e3d2 100644 --- a/src/test/ui/existential_types/generic_not_used.stderr +++ b/src/test/ui/type-alias-impl-trait/generic_not_used.stderr @@ -1,10 +1,10 @@ error: at least one trait must be specified - --> $DIR/generic_not_used.rs:5:44 + --> $DIR/generic_not_used.rs:5:38 | -LL | existential type WrongGeneric<T: 'static>: 'static; - | ^^^^^^^ +LL | type WrongGeneric<T: 'static> = impl 'static; + | ^^^^^^^ -error: type parameter `V` is part of concrete type but not used in parameter list for existential type +error: type parameter `V` is part of concrete type but not used in parameter list for the `impl Trait` type alias --> $DIR/generic_not_used.rs:8:73 | LL | fn wrong_generic<U: 'static, V: 'static>(_: U, v: V) -> WrongGeneric<U> { diff --git a/src/test/ui/existential_types/generic_type_does_not_live_long_enough.nll.stderr b/src/test/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.nll.stderr index f316644156d..3f25d5fbd9c 100644 --- a/src/test/ui/existential_types/generic_type_does_not_live_long_enough.nll.stderr +++ b/src/test/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.nll.stderr @@ -1,8 +1,8 @@ error: at least one trait must be specified - --> $DIR/generic_type_does_not_live_long_enough.rs:9:35 + --> $DIR/generic_type_does_not_live_long_enough.rs:9:29 | -LL | existential type WrongGeneric<T>: 'static; - | ^^^^^^^ +LL | type WrongGeneric<T> = impl 'static; + | ^^^^^^^ error[E0308]: mismatched types --> $DIR/generic_type_does_not_live_long_enough.rs:6:18 diff --git a/src/test/ui/existential_types/generic_type_does_not_live_long_enough.rs b/src/test/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.rs index d9eedd6dca7..c0f939a5048 100644 --- a/src/test/ui/existential_types/generic_type_does_not_live_long_enough.rs +++ b/src/test/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.rs @@ -1,4 +1,4 @@ -#![feature(existential_type)] +#![feature(type_alias_impl_trait)] fn main() { let y = 42; @@ -6,7 +6,7 @@ fn main() { let z: i32 = x; //~ ERROR mismatched types } -existential type WrongGeneric<T>: 'static; +type WrongGeneric<T> = impl 'static; //~^ ERROR the parameter type `T` may not live long enough //~^^ ERROR: at least one trait must be specified diff --git a/src/test/ui/existential_types/generic_type_does_not_live_long_enough.stderr b/src/test/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.stderr index 2f76eea4460..12569211df3 100644 --- a/src/test/ui/existential_types/generic_type_does_not_live_long_enough.stderr +++ b/src/test/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.stderr @@ -1,8 +1,8 @@ error: at least one trait must be specified - --> $DIR/generic_type_does_not_live_long_enough.rs:9:35 + --> $DIR/generic_type_does_not_live_long_enough.rs:9:29 | -LL | existential type WrongGeneric<T>: 'static; - | ^^^^^^^ +LL | type WrongGeneric<T> = impl 'static; + | ^^^^^^^ error[E0308]: mismatched types --> $DIR/generic_type_does_not_live_long_enough.rs:6:18 @@ -16,8 +16,8 @@ LL | let z: i32 = x; error[E0310]: the parameter type `T` may not live long enough --> $DIR/generic_type_does_not_live_long_enough.rs:9:1 | -LL | existential type WrongGeneric<T>: 'static; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | type WrongGeneric<T> = impl 'static; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ... LL | fn wrong_generic<T>(t: T) -> WrongGeneric<T> { | - help: consider adding an explicit lifetime bound `T: 'static`... @@ -25,8 +25,8 @@ LL | fn wrong_generic<T>(t: T) -> WrongGeneric<T> { note: ...so that the type `T` will meet its required lifetime bounds --> $DIR/generic_type_does_not_live_long_enough.rs:9:1 | -LL | existential type WrongGeneric<T>: 'static; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | type WrongGeneric<T> = impl 'static; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 3 previous errors diff --git a/src/test/ui/existential_types/generic_underconstrained.rs b/src/test/ui/type-alias-impl-trait/generic_underconstrained.rs index cc0db893c6a..589612d5ed6 100644 --- a/src/test/ui/existential_types/generic_underconstrained.rs +++ b/src/test/ui/type-alias-impl-trait/generic_underconstrained.rs @@ -1,9 +1,9 @@ -#![feature(existential_type)] +#![feature(type_alias_impl_trait)] fn main() {} trait Trait {} -existential type Underconstrained<T: Trait>: 'static; //~ ERROR the trait bound `T: Trait` +type Underconstrained<T: Trait> = impl 'static; //~ ERROR the trait bound `T: Trait` //~^ ERROR: at least one trait must be specified // no `Trait` bound diff --git a/src/test/ui/existential_types/generic_underconstrained.stderr b/src/test/ui/type-alias-impl-trait/generic_underconstrained.stderr index 35083a53eb3..dd90dd1b06f 100644 --- a/src/test/ui/existential_types/generic_underconstrained.stderr +++ b/src/test/ui/type-alias-impl-trait/generic_underconstrained.stderr @@ -1,14 +1,14 @@ error: at least one trait must be specified - --> $DIR/generic_underconstrained.rs:6:46 + --> $DIR/generic_underconstrained.rs:6:40 | -LL | existential type Underconstrained<T: Trait>: 'static; - | ^^^^^^^ +LL | type Underconstrained<T: Trait> = impl 'static; + | ^^^^^^^ error[E0277]: the trait bound `T: Trait` is not satisfied --> $DIR/generic_underconstrained.rs:6:1 | -LL | existential type Underconstrained<T: Trait>: 'static; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `T` +LL | type Underconstrained<T: Trait> = impl 'static; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `T` | = help: consider adding a `where T: Trait` bound = note: the return type of a function must have a statically known size diff --git a/src/test/ui/existential_types/generic_underconstrained2.rs b/src/test/ui/type-alias-impl-trait/generic_underconstrained2.rs index c6263eacd53..87b8aaad957 100644 --- a/src/test/ui/existential_types/generic_underconstrained2.rs +++ b/src/test/ui/type-alias-impl-trait/generic_underconstrained2.rs @@ -1,8 +1,8 @@ -#![feature(existential_type)] +#![feature(type_alias_impl_trait)] fn main() {} -existential type Underconstrained<T: std::fmt::Debug>: 'static; +type Underconstrained<T: std::fmt::Debug> = impl 'static; //~^ ERROR `U` doesn't implement `std::fmt::Debug` //~^^ ERROR: at least one trait must be specified @@ -11,7 +11,7 @@ fn underconstrained<U>(_: U) -> Underconstrained<U> { 5u32 } -existential type Underconstrained2<T: std::fmt::Debug>: 'static; +type Underconstrained2<T: std::fmt::Debug> = impl 'static; //~^ ERROR `V` doesn't implement `std::fmt::Debug` //~^^ ERROR: at least one trait must be specified diff --git a/src/test/ui/existential_types/generic_underconstrained2.stderr b/src/test/ui/type-alias-impl-trait/generic_underconstrained2.stderr index 6ff783f33b9..574432bdcf6 100644 --- a/src/test/ui/existential_types/generic_underconstrained2.stderr +++ b/src/test/ui/type-alias-impl-trait/generic_underconstrained2.stderr @@ -1,20 +1,20 @@ error: at least one trait must be specified - --> $DIR/generic_underconstrained2.rs:5:56 + --> $DIR/generic_underconstrained2.rs:5:50 | -LL | existential type Underconstrained<T: std::fmt::Debug>: 'static; - | ^^^^^^^ +LL | type Underconstrained<T: std::fmt::Debug> = impl 'static; + | ^^^^^^^ error: at least one trait must be specified - --> $DIR/generic_underconstrained2.rs:14:57 + --> $DIR/generic_underconstrained2.rs:14:51 | -LL | existential type Underconstrained2<T: std::fmt::Debug>: 'static; - | ^^^^^^^ +LL | type Underconstrained2<T: std::fmt::Debug> = impl 'static; + | ^^^^^^^ error[E0277]: `U` doesn't implement `std::fmt::Debug` --> $DIR/generic_underconstrained2.rs:5:1 | -LL | existential type Underconstrained<T: std::fmt::Debug>: 'static; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `U` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug` +LL | type Underconstrained<T: std::fmt::Debug> = impl 'static; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `U` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug` | = help: the trait `std::fmt::Debug` is not implemented for `U` = help: consider adding a `where U: std::fmt::Debug` bound @@ -23,8 +23,8 @@ LL | existential type Underconstrained<T: std::fmt::Debug>: 'static; error[E0277]: `V` doesn't implement `std::fmt::Debug` --> $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` +LL | type Underconstrained2<T: std::fmt::Debug> = impl 'static; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `V` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug` | = help: the trait `std::fmt::Debug` is not implemented for `V` = help: consider adding a `where V: std::fmt::Debug` bound diff --git a/src/test/ui/type-alias-impl-trait/issue-52843-closure-constrain.rs b/src/test/ui/type-alias-impl-trait/issue-52843-closure-constrain.rs new file mode 100644 index 00000000000..a102d16078b --- /dev/null +++ b/src/test/ui/type-alias-impl-trait/issue-52843-closure-constrain.rs @@ -0,0 +1,13 @@ +// Checks to ensure that we properly detect when a closure constrains an opaque type + +#![feature(type_alias_impl_trait)] + +use std::fmt::Debug; + +fn main() { + type Opaque = impl Debug; + fn _unused() -> Opaque { String::new() } + //~^ ERROR: concrete type differs from previous defining opaque type use + let null = || -> Opaque { 0 }; + println!("{:?}", null()); +} diff --git a/src/test/ui/type-alias-impl-trait/issue-52843-closure-constrain.stderr b/src/test/ui/type-alias-impl-trait/issue-52843-closure-constrain.stderr new file mode 100644 index 00000000000..c994eb5986c --- /dev/null +++ b/src/test/ui/type-alias-impl-trait/issue-52843-closure-constrain.stderr @@ -0,0 +1,20 @@ +error: concrete type differs from previous defining opaque type use + --> $DIR/issue-52843-closure-constrain.rs:9:5 + | +LL | fn _unused() -> Opaque { String::new() } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, got `std::string::String` + | +note: previous use here + --> $DIR/issue-52843-closure-constrain.rs:7:1 + | +LL | / fn main() { +LL | | type Opaque = impl Debug; +LL | | fn _unused() -> Opaque { String::new() } +LL | | +LL | | let null = || -> Opaque { 0 }; +LL | | println!("{:?}", null()); +LL | | } + | |_^ + +error: aborting due to previous error + diff --git a/src/test/ui/existential_types/issue-53678-generator-and-const-fn.rs b/src/test/ui/type-alias-impl-trait/issue-53678-generator-and-const-fn.rs index d964f2b74ff..e7f93732430 100644 --- a/src/test/ui/existential_types/issue-53678-generator-and-const-fn.rs +++ b/src/test/ui/type-alias-impl-trait/issue-53678-generator-and-const-fn.rs @@ -1,10 +1,10 @@ // check-pass -#![feature(const_fn, generators, generator_trait, existential_type)] +#![feature(const_fn, generators, generator_trait, type_alias_impl_trait)] use std::ops::Generator; -existential type GenOnce<Y, R>: Generator<Yield = Y, Return = R>; +type GenOnce<Y, R> = impl Generator<Yield = Y, Return = R>; const fn const_generator<Y, R>(yielding: Y, returning: R) -> GenOnce<Y, R> { move || { diff --git a/src/test/ui/existential_types/issue-58887.rs b/src/test/ui/type-alias-impl-trait/issue-58887.rs index f038648ec21..92ba50ae6cf 100644 --- a/src/test/ui/existential_types/issue-58887.rs +++ b/src/test/ui/type-alias-impl-trait/issue-58887.rs @@ -1,4 +1,4 @@ -#![feature(existential_type)] +#![feature(type_alias_impl_trait)] trait UnwrapItemsExt { type Iter; @@ -10,7 +10,7 @@ where I: Iterator<Item = Result<T, E>>, E: std::fmt::Debug, { - existential type Iter: Iterator<Item = T>; + type Iter = impl Iterator<Item = T>; //~^ ERROR: could not find defining uses fn unwrap_items(self) -> Self::Iter { diff --git a/src/test/ui/existential_types/issue-58887.stderr b/src/test/ui/type-alias-impl-trait/issue-58887.stderr index 800f4b7e059..7e2895711d3 100644 --- a/src/test/ui/existential_types/issue-58887.stderr +++ b/src/test/ui/type-alias-impl-trait/issue-58887.stderr @@ -1,4 +1,4 @@ -error: type parameter `T` is part of concrete type but not used in parameter list for existential type +error: type parameter `T` is part of concrete type but not used in parameter list for the `impl Trait` type alias --> $DIR/issue-58887.rs:16:41 | LL | fn unwrap_items(self) -> Self::Iter { @@ -9,7 +9,7 @@ LL | | self.map(|x| x.unwrap()) LL | | } | |_____^ -error: type parameter `E` is part of concrete type but not used in parameter list for existential type +error: type parameter `E` is part of concrete type but not used in parameter list for the `impl Trait` type alias --> $DIR/issue-58887.rs:16:41 | LL | fn unwrap_items(self) -> Self::Iter { @@ -23,8 +23,8 @@ LL | | } error: could not find defining uses --> $DIR/issue-58887.rs:13:5 | -LL | existential type Iter: Iterator<Item = T>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | type Iter = impl Iterator<Item = T>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 3 previous errors diff --git a/src/test/ui/existential_types/issue-58951.rs b/src/test/ui/type-alias-impl-trait/issue-58951.rs index 410dcdfe347..3416c6745bb 100644 --- a/src/test/ui/existential_types/issue-58951.rs +++ b/src/test/ui/type-alias-impl-trait/issue-58951.rs @@ -1,8 +1,11 @@ // check-pass -#![feature(existential_type)] -existential type A: Iterator; +#![feature(type_alias_impl_trait)] + +type A = impl Iterator; + fn def_a() -> A { 0..1 } + pub fn use_a() { def_a().map(|x| x); } diff --git a/src/test/ui/existential_types/issue-60371.rs b/src/test/ui/type-alias-impl-trait/issue-60371.rs index f9def11d193..50b9d1ac793 100644 --- a/src/test/ui/existential_types/issue-60371.rs +++ b/src/test/ui/type-alias-impl-trait/issue-60371.rs @@ -5,7 +5,7 @@ trait Bug { } impl Bug for &() { - existential type Item: Bug; //~ ERROR existential types are unstable + type Item = impl Bug; //~ ERROR `impl Trait` in type aliases is unstable //~^ ERROR the trait bound `(): Bug` is not satisfied //~^^ ERROR could not find defining uses diff --git a/src/test/ui/existential_types/issue-60371.stderr b/src/test/ui/type-alias-impl-trait/issue-60371.stderr index 092cb31f97d..1e9b12ebc39 100644 --- a/src/test/ui/existential_types/issue-60371.stderr +++ b/src/test/ui/type-alias-impl-trait/issue-60371.stderr @@ -1,17 +1,17 @@ -error[E0658]: existential types are unstable +error[E0658]: `impl Trait` in type aliases is unstable --> $DIR/issue-60371.rs:8:5 | -LL | existential type Item: Bug; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | type Item = impl Bug; + | ^^^^^^^^^^^^^^^^^^^^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/63063 - = help: add `#![feature(existential_type)]` to the crate attributes to enable + = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable error[E0277]: the trait bound `(): Bug` is not satisfied --> $DIR/issue-60371.rs:8:5 | -LL | existential type Item: Bug; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Bug` is not implemented for `()` +LL | type Item = impl Bug; + | ^^^^^^^^^^^^^^^^^^^^^ the trait `Bug` is not implemented for `()` | = help: the following implementations were found: <&() as Bug> @@ -20,8 +20,8 @@ LL | existential type Item: Bug; error: could not find defining uses --> $DIR/issue-60371.rs:8:5 | -LL | existential type Item: Bug; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | type Item = impl Bug; + | ^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 3 previous errors diff --git a/src/test/ui/existential_types/issue-60407.rs b/src/test/ui/type-alias-impl-trait/issue-60407.rs index 52162c491b5..7d462f057cb 100644 --- a/src/test/ui/existential_types/issue-60407.rs +++ b/src/test/ui/type-alias-impl-trait/issue-60407.rs @@ -1,8 +1,8 @@ // check-pass -#![feature(existential_type)] +#![feature(type_alias_impl_trait)] -existential type Debuggable: core::fmt::Debug; +type Debuggable = impl core::fmt::Debug; static mut TEST: Option<Debuggable> = None; diff --git a/src/test/ui/existential_types/issue-60564.rs b/src/test/ui/type-alias-impl-trait/issue-60564.rs index cb3914ddd1d..91c4576597e 100644 --- a/src/test/ui/existential_types/issue-60564.rs +++ b/src/test/ui/type-alias-impl-trait/issue-60564.rs @@ -1,11 +1,11 @@ -#![feature(existential_type)] +#![feature(type_alias_impl_trait)] trait IterBits { type BitsIter: Iterator<Item = u8>; fn iter_bits(self, n: u8) -> Self::BitsIter; } -existential type IterBitsIter<T, E, I>: std::iter::Iterator<Item = I>; +type IterBitsIter<T, E, I> = impl std::iter::Iterator<Item = I>; //~^ ERROR could not find defining uses impl<T, E> IterBits for T diff --git a/src/test/ui/existential_types/issue-60564.stderr b/src/test/ui/type-alias-impl-trait/issue-60564.stderr index d8480b52157..ebb13fca1da 100644 --- a/src/test/ui/existential_types/issue-60564.stderr +++ b/src/test/ui/type-alias-impl-trait/issue-60564.stderr @@ -2,7 +2,7 @@ error[E0601]: `main` function not found in crate `issue_60564` | = note: consider adding a `main` function to `$DIR/issue-60564.rs` -error: type parameter `E` is part of concrete type but not used in parameter list for existential type +error: type parameter `E` is part of concrete type but not used in parameter list for the `impl Trait` type alias --> $DIR/issue-60564.rs:20:49 | LL | fn iter_bits(self, n: u8) -> Self::BitsIter { @@ -17,8 +17,8 @@ LL | | } error: could not find defining uses --> $DIR/issue-60564.rs:8:1 | -LL | existential type IterBitsIter<T, E, I>: std::iter::Iterator<Item = I>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | type IterBitsIter<T, E, I> = impl std::iter::Iterator<Item = I>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 3 previous errors diff --git a/src/test/ui/existential_types/nested_existential_types.rs b/src/test/ui/type-alias-impl-trait/nested_type_alias_impl_trait.rs index de52e88bae2..82c9ecd2ac6 100644 --- a/src/test/ui/existential_types/nested_existential_types.rs +++ b/src/test/ui/type-alias-impl-trait/nested_type_alias_impl_trait.rs @@ -1,10 +1,10 @@ -#![feature(existential_type)] +#![feature(type_alias_impl_trait)] // build-pass (FIXME(62277): could be check-pass?) mod my_mod { use std::fmt::Debug; - pub existential type Foo: Debug; - pub existential type Foot: Debug; + pub type Foo = impl Debug; + pub type Foot = impl Debug; pub fn get_foo() -> Foo { 5i32 diff --git a/src/test/ui/existential_types/never_reveal_concrete_type.rs b/src/test/ui/type-alias-impl-trait/never_reveal_concrete_type.rs index 04da394848e..8787c023eb0 100644 --- a/src/test/ui/existential_types/never_reveal_concrete_type.rs +++ b/src/test/ui/type-alias-impl-trait/never_reveal_concrete_type.rs @@ -1,9 +1,9 @@ -#![feature(existential_type)] +#![feature(type_alias_impl_trait)] fn main() {} // don't reveal the concrete type -existential type NoReveal: std::fmt::Debug; +type NoReveal = impl std::fmt::Debug; fn define_no_reveal() -> NoReveal { "" diff --git a/src/test/ui/existential_types/never_reveal_concrete_type.stderr b/src/test/ui/type-alias-impl-trait/never_reveal_concrete_type.stderr index 7c195f1fad0..7c195f1fad0 100644 --- a/src/test/ui/existential_types/never_reveal_concrete_type.stderr +++ b/src/test/ui/type-alias-impl-trait/never_reveal_concrete_type.stderr diff --git a/src/test/ui/existential_types/no_inferrable_concrete_type.rs b/src/test/ui/type-alias-impl-trait/no_inferrable_concrete_type.rs index eec8a4be63d..c9ca504f780 100644 --- a/src/test/ui/existential_types/no_inferrable_concrete_type.rs +++ b/src/test/ui/type-alias-impl-trait/no_inferrable_concrete_type.rs @@ -1,9 +1,9 @@ -// Issue 52985: user code provides no use case that allows an existential type +// Issue 52985: user code provides no use case that allows a type alias `impl Trait` // We now emit a 'could not find defining uses' error -#![feature(existential_type)] +#![feature(type_alias_impl_trait)] -existential type Foo: Copy; //~ could not find defining uses +type Foo = impl Copy; //~ could not find defining uses // make compiler happy about using 'Foo' fn bar(x: Foo) -> Foo { x } diff --git a/src/test/ui/existential_types/no_inferrable_concrete_type.stderr b/src/test/ui/type-alias-impl-trait/no_inferrable_concrete_type.stderr index bc9a883c836..444e6e8214f 100644 --- a/src/test/ui/existential_types/no_inferrable_concrete_type.stderr +++ b/src/test/ui/type-alias-impl-trait/no_inferrable_concrete_type.stderr @@ -1,8 +1,8 @@ error: could not find defining uses --> $DIR/no_inferrable_concrete_type.rs:6:1 | -LL | existential type Foo: Copy; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | type Foo = impl Copy; + | ^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/existential_types/no_revealing_outside_defining_module.rs b/src/test/ui/type-alias-impl-trait/no_revealing_outside_defining_module.rs index 04793c67b56..61153b1e171 100644 --- a/src/test/ui/existential_types/no_revealing_outside_defining_module.rs +++ b/src/test/ui/type-alias-impl-trait/no_revealing_outside_defining_module.rs @@ -1,9 +1,9 @@ -#![feature(existential_type)] +#![feature(type_alias_impl_trait)] fn main() {} mod boo { - pub existential type Boo: ::std::fmt::Debug; + pub type Boo = impl ::std::fmt::Debug; fn bomp() -> Boo { "" } diff --git a/src/test/ui/existential_types/no_revealing_outside_defining_module.stderr b/src/test/ui/type-alias-impl-trait/no_revealing_outside_defining_module.stderr index 5e5826978fc..5e5826978fc 100644 --- a/src/test/ui/existential_types/no_revealing_outside_defining_module.stderr +++ b/src/test/ui/type-alias-impl-trait/no_revealing_outside_defining_module.stderr diff --git a/src/test/ui/existential_types/not_a_defining_use.rs b/src/test/ui/type-alias-impl-trait/not_a_defining_use.rs index 3f81f5177d0..ca00e582d34 100644 --- a/src/test/ui/existential_types/not_a_defining_use.rs +++ b/src/test/ui/type-alias-impl-trait/not_a_defining_use.rs @@ -1,13 +1,13 @@ -#![feature(existential_type)] +#![feature(type_alias_impl_trait)] use std::fmt::Debug; fn main() {} -existential type Two<T, U>: Debug; +type Two<T, U> = impl Debug; fn two<T: Debug>(t: T) -> Two<T, u32> { - //~^ ERROR defining existential type use does not fully define existential type + //~^ ERROR defining opaque type use does not fully define opaque type (t, 4i8) } diff --git a/src/test/ui/existential_types/not_a_defining_use.stderr b/src/test/ui/type-alias-impl-trait/not_a_defining_use.stderr index f315811cdb4..7bb8939ccf5 100644 --- a/src/test/ui/existential_types/not_a_defining_use.stderr +++ b/src/test/ui/type-alias-impl-trait/not_a_defining_use.stderr @@ -1,4 +1,4 @@ -error: defining existential type use does not fully define existential type +error: defining opaque type use does not fully define opaque type --> $DIR/not_a_defining_use.rs:9:1 | LL | / fn two<T: Debug>(t: T) -> Two<T, u32> { @@ -7,7 +7,7 @@ LL | | (t, 4i8) LL | | } | |_^ -error: concrete type differs from previous defining existential type use +error: concrete type differs from previous defining opaque type use --> $DIR/not_a_defining_use.rs:30:1 | LL | / fn four<T: Debug, U: Bar>(t: T) -> Two<T, U> { diff --git a/src/test/ui/existential_types/not_well_formed.rs b/src/test/ui/type-alias-impl-trait/not_well_formed.rs index 073fa90cb35..36ec9b34ebd 100644 --- a/src/test/ui/existential_types/not_well_formed.rs +++ b/src/test/ui/type-alias-impl-trait/not_well_formed.rs @@ -1,4 +1,4 @@ -#![feature(existential_type)] +#![feature(type_alias_impl_trait)] fn main() { } @@ -7,7 +7,7 @@ trait TraitWithAssoc { type Assoc; } -existential type Foo<V>: Trait<V::Assoc>; //~ associated type `Assoc` not found for `V` +type Foo<V> = impl Trait<V::Assoc>; //~ associated type `Assoc` not found for `V` trait Trait<U> {} diff --git a/src/test/ui/existential_types/not_well_formed.stderr b/src/test/ui/type-alias-impl-trait/not_well_formed.stderr index 05f84d57623..d374d6d33ee 100644 --- a/src/test/ui/existential_types/not_well_formed.stderr +++ b/src/test/ui/type-alias-impl-trait/not_well_formed.stderr @@ -1,8 +1,8 @@ error[E0220]: associated type `Assoc` not found for `V` - --> $DIR/not_well_formed.rs:10:32 + --> $DIR/not_well_formed.rs:10:26 | -LL | existential type Foo<V>: Trait<V::Assoc>; - | ^^^^^^^^ associated type `Assoc` not found +LL | type Foo<V> = impl Trait<V::Assoc>; + | ^^^^^^^^ associated type `Assoc` not found error: aborting due to previous error diff --git a/src/test/ui/existential_types/private_unused.rs b/src/test/ui/type-alias-impl-trait/private_unused.rs index 92268f1861d..92268f1861d 100644 --- a/src/test/ui/existential_types/private_unused.rs +++ b/src/test/ui/type-alias-impl-trait/private_unused.rs diff --git a/src/test/ui/existential_types/existential_type_const.rs b/src/test/ui/type-alias-impl-trait/type-alias-impl-trait-const.rs index 646e9a73424..0fd4d26ef60 100644 --- a/src/test/ui/existential_types/existential_type_const.rs +++ b/src/test/ui/type-alias-impl-trait/type-alias-impl-trait-const.rs @@ -1,18 +1,18 @@ // check-pass -#![feature(existential_type)] -// Currently, the `existential_type` feature implicitly +#![feature(type_alias_impl_trait)] +// Currently, the `type_alias_impl_trait` feature implicitly // depends on `impl_trait_in_bindings` in order to work properly. // Specifically, this line requires `impl_trait_in_bindings` to be enabled: // https://github.com/rust-lang/rust/blob/481068a707679257e2a738b40987246e0420e787/src/librustc_typeck/check/mod.rs#L856 #![feature(impl_trait_in_bindings)] //~^ WARN the feature `impl_trait_in_bindings` is incomplete and may cause the compiler to crash -// Ensures that `const` items can constrain an `existential type`. +// Ensures that `const` items can constrain an opaque `impl Trait`. use std::fmt::Debug; -pub existential type Foo: Debug; +pub type Foo = impl Debug; const _FOO: Foo = 5; diff --git a/src/test/ui/existential_types/existential_type_const.stderr b/src/test/ui/type-alias-impl-trait/type-alias-impl-trait-const.stderr index 81754c8f706..691de82c9d8 100644 --- a/src/test/ui/existential_types/existential_type_const.stderr +++ b/src/test/ui/type-alias-impl-trait/type-alias-impl-trait-const.stderr @@ -1,5 +1,5 @@ warning: the feature `impl_trait_in_bindings` is incomplete and may cause the compiler to crash - --> $DIR/existential_type_const.rs:8:12 + --> $DIR/type-alias-impl-trait-const.rs:8:12 | LL | #![feature(impl_trait_in_bindings)] | ^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/existential_types/existential_type_fns.rs b/src/test/ui/type-alias-impl-trait/type-alias-impl-trait-fns.rs index 6f22eef2849..a22b12cae6b 100644 --- a/src/test/ui/existential_types/existential_type_fns.rs +++ b/src/test/ui/type-alias-impl-trait/type-alias-impl-trait-fns.rs @@ -1,6 +1,6 @@ // check-pass -#![feature(existential_type)] +#![feature(type_alias_impl_trait)] // Regression test for issue #61863 @@ -22,6 +22,6 @@ pub fn bla2() -> TE { } -existential type TE: MyTrait; +type TE = impl MyTrait; fn main() {} diff --git a/src/test/ui/existential_types/existential_type_tuple.rs b/src/test/ui/type-alias-impl-trait/type-alias-impl-trait-tuple.rs index 0f134a52897..86c9d482143 100644 --- a/src/test/ui/existential_types/existential_type_tuple.rs +++ b/src/test/ui/type-alias-impl-trait/type-alias-impl-trait-tuple.rs @@ -1,6 +1,6 @@ // check-pass -#![feature(existential_type)] +#![feature(type_alias_impl_trait)] #![allow(dead_code)] pub trait MyTrait {} @@ -28,6 +28,6 @@ fn make_foo() -> Foo { true } -existential type Foo: MyTrait; +type Foo = impl MyTrait; fn main() {} diff --git a/src/test/ui/existential_types/existential-types-with-cycle-error.rs b/src/test/ui/type-alias-impl-trait/type-alias-impl-trait-with-cycle-error.rs index 38fcabb5cc1..c009952eab7 100644 --- a/src/test/ui/existential_types/existential-types-with-cycle-error.rs +++ b/src/test/ui/type-alias-impl-trait/type-alias-impl-trait-with-cycle-error.rs @@ -1,6 +1,6 @@ -#![feature(existential_type)] +#![feature(type_alias_impl_trait)] -existential type Foo: Fn() -> Foo; +type Foo = impl Fn() -> Foo; //~^ ERROR: could not find defining uses fn crash(x: Foo) -> Foo { diff --git a/src/test/ui/type-alias-impl-trait/type-alias-impl-trait-with-cycle-error.stderr b/src/test/ui/type-alias-impl-trait/type-alias-impl-trait-with-cycle-error.stderr new file mode 100644 index 00000000000..02ab3399ea6 --- /dev/null +++ b/src/test/ui/type-alias-impl-trait/type-alias-impl-trait-with-cycle-error.stderr @@ -0,0 +1,8 @@ +error: could not find defining uses + --> $DIR/type-alias-impl-trait-with-cycle-error.rs:3:1 + | +LL | type Foo = impl Fn() -> Foo; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/existential_types/existential-types-with-cycle-error2.rs b/src/test/ui/type-alias-impl-trait/type-alias-impl-trait-with-cycle-error2.rs index f9e6bdb67d4..32ecc366618 100644 --- a/src/test/ui/existential_types/existential-types-with-cycle-error2.rs +++ b/src/test/ui/type-alias-impl-trait/type-alias-impl-trait-with-cycle-error2.rs @@ -1,10 +1,10 @@ -#![feature(existential_type)] +#![feature(type_alias_impl_trait)] pub trait Bar<T> { type Item; } -existential type Foo: Bar<Foo, Item = Foo>; +type Foo = impl Bar<Foo, Item = Foo>; //~^ ERROR: could not find defining uses fn crash(x: Foo) -> Foo { diff --git a/src/test/ui/type-alias-impl-trait/type-alias-impl-trait-with-cycle-error2.stderr b/src/test/ui/type-alias-impl-trait/type-alias-impl-trait-with-cycle-error2.stderr new file mode 100644 index 00000000000..e9abb795886 --- /dev/null +++ b/src/test/ui/type-alias-impl-trait/type-alias-impl-trait-with-cycle-error2.stderr @@ -0,0 +1,8 @@ +error: could not find defining uses + --> $DIR/type-alias-impl-trait-with-cycle-error2.rs:7:1 + | +LL | type Foo = impl Bar<Foo, Item = Foo>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/existential_types/existential-types-with-no-traits.rs b/src/test/ui/type-alias-impl-trait/type-alias-impl-trait-with-no-traits.rs index 46339c73b1f..8ca279eec92 100644 --- a/src/test/ui/existential_types/existential-types-with-no-traits.rs +++ b/src/test/ui/type-alias-impl-trait/type-alias-impl-trait-with-no-traits.rs @@ -1,6 +1,6 @@ -#![feature(existential_type)] +#![feature(type_alias_impl_trait)] -existential type Foo: 'static; +type Foo = impl 'static; //~^ ERROR: at least one trait must be specified fn foo() -> Foo { diff --git a/src/test/ui/existential_types/existential-types-with-no-traits.stderr b/src/test/ui/type-alias-impl-trait/type-alias-impl-trait-with-no-traits.stderr index 4b2fbc79d3b..58028bd0861 100644 --- a/src/test/ui/existential_types/existential-types-with-no-traits.stderr +++ b/src/test/ui/type-alias-impl-trait/type-alias-impl-trait-with-no-traits.stderr @@ -1,11 +1,11 @@ error: at least one trait must be specified - --> $DIR/existential-types-with-no-traits.rs:3:23 + --> $DIR/type-alias-impl-trait-with-no-traits.rs:3:17 | -LL | existential type Foo: 'static; - | ^^^^^^^ +LL | type Foo = impl 'static; + | ^^^^^^^ error: at least one trait must be specified - --> $DIR/existential-types-with-no-traits.rs:10:13 + --> $DIR/type-alias-impl-trait-with-no-traits.rs:10:13 | LL | fn bar() -> impl 'static { | ^^^^^^^^^^^^ diff --git a/src/test/ui/existential_types/existential_type-pass.rs b/src/test/ui/type-alias-impl-trait/type-alias-impl-trait.rs index c2cf0eeed3d..209134acf01 100644 --- a/src/test/ui/existential_types/existential_type-pass.rs +++ b/src/test/ui/type-alias-impl-trait/type-alias-impl-trait.rs @@ -3,7 +3,7 @@ #![allow(dead_code)] #![allow(unused_assignments)] #![allow(unused_variables)] -#![feature(existential_type)] +#![feature(type_alias_impl_trait)] fn main() { assert_eq!(foo().to_string(), "foo"); @@ -16,14 +16,14 @@ fn main() { } // single definition -existential type Foo: std::fmt::Display; +type Foo = impl std::fmt::Display; fn foo() -> Foo { "foo" } // two definitions -existential type Bar: std::fmt::Display; +type Bar = impl std::fmt::Display; fn bar1() -> Bar { "bar1" @@ -34,7 +34,7 @@ fn bar2() -> Bar { } // definition in submodule -existential type Boo: std::fmt::Display; +type Boo = impl std::fmt::Display; mod boo { pub fn boo() -> super::Boo { @@ -42,7 +42,7 @@ mod boo { } } -existential type MyIter<T>: Iterator<Item = T>; +type MyIter<T> = impl Iterator<Item = T>; fn my_iter<T>(t: T) -> MyIter<T> { std::iter::once(t) @@ -63,21 +63,21 @@ fn my_iter4<U, V>(_: U, v: V) -> MyIter<V> { } // param names should not have an effect! -existential type MyOtherIter<T>: Iterator<Item = T>; +type MyOtherIter<T> = impl Iterator<Item = T>; fn my_other_iter<U>(u: U) -> MyOtherIter<U> { std::iter::once(u) } trait Trait {} -existential type GenericBound<'a, T: Trait>: Sized + 'a; +type GenericBound<'a, T: Trait> = impl Sized + 'a; fn generic_bound<'a, T: Trait + 'a>(t: T) -> GenericBound<'a, T> { t } mod pass_through { - pub existential type Passthrough<T>: Sized + 'static; + pub type Passthrough<T> = impl Sized + 'static; fn define_passthrough<T: 'static>(t: T) -> Passthrough<T> { t diff --git a/src/test/ui/existential_types/unused_generic_param.rs b/src/test/ui/type-alias-impl-trait/unused_generic_param.rs index 5455b39f4cb..a9ab727b193 100644 --- a/src/test/ui/existential_types/unused_generic_param.rs +++ b/src/test/ui/type-alias-impl-trait/unused_generic_param.rs @@ -1,16 +1,16 @@ -#![feature(existential_type)] +#![feature(type_alias_impl_trait)] fn main() { } -existential type PartiallyDefined<T>: 'static; +type PartiallyDefined<T> = impl 'static; //~^ ERROR: at least one trait must be specified fn partially_defined<T: std::fmt::Debug>(_: T) -> PartiallyDefined<T> { 4u32 } -existential type PartiallyDefined2<T>: 'static; +type PartiallyDefined2<T> = impl 'static; //~^ ERROR: at least one trait must be specified fn partially_defined2<T: std::fmt::Debug>(_: T) -> PartiallyDefined2<T> { diff --git a/src/test/ui/type-alias-impl-trait/unused_generic_param.stderr b/src/test/ui/type-alias-impl-trait/unused_generic_param.stderr new file mode 100644 index 00000000000..23105026964 --- /dev/null +++ b/src/test/ui/type-alias-impl-trait/unused_generic_param.stderr @@ -0,0 +1,14 @@ +error: at least one trait must be specified + --> $DIR/unused_generic_param.rs:6:33 + | +LL | type PartiallyDefined<T> = impl 'static; + | ^^^^^^^ + +error: at least one trait must be specified + --> $DIR/unused_generic_param.rs:13:34 + | +LL | type PartiallyDefined2<T> = impl 'static; + | ^^^^^^^ + +error: aborting due to 2 previous errors + |
