From 8a0ebca97eabaed14a36d90aa25327dcec2fa8b1 Mon Sep 17 00:00:00 2001 From: Bryan Garza <1396101+bryangarza@users.noreply.github.com> Date: Tue, 4 Oct 2022 23:35:49 +0000 Subject: [PATCH] Update static AFIT tests based on feedback --- .../in-trait/async-associated-types.rs | 2 +- .../async-associated-types2-desugared.rs | 31 --------- .../async-associated-types2-desugared.stderr | 42 ------------- .../in-trait/async-associated-types2.rs | 10 ++- .../in-trait/async-associated-types2.stderr | 63 ------------------- .../in-trait/fn-not-async-err2-rpitit.rs | 22 +++++++ .../async-await/in-trait/fn-not-async-err2.rs | 2 +- 7 files changed, 28 insertions(+), 144 deletions(-) delete mode 100644 src/test/ui/async-await/in-trait/async-associated-types2-desugared.rs delete mode 100644 src/test/ui/async-await/in-trait/async-associated-types2-desugared.stderr delete mode 100644 src/test/ui/async-await/in-trait/async-associated-types2.stderr create mode 100644 src/test/ui/async-await/in-trait/fn-not-async-err2-rpitit.rs diff --git a/src/test/ui/async-await/in-trait/async-associated-types.rs b/src/test/ui/async-await/in-trait/async-associated-types.rs index 0269f00bbab..8f679190d7a 100644 --- a/src/test/ui/async-await/in-trait/async-associated-types.rs +++ b/src/test/ui/async-await/in-trait/async-associated-types.rs @@ -6,7 +6,7 @@ use std::fmt::Debug; trait MyTrait<'a, 'b, T> where Self: 'a, T: Debug + Sized + 'b { - type MyAssoc;// = (&'a T, &'b U); + type MyAssoc; async fn foo(&'a self, key: &'b T) -> Self::MyAssoc; } diff --git a/src/test/ui/async-await/in-trait/async-associated-types2-desugared.rs b/src/test/ui/async-await/in-trait/async-associated-types2-desugared.rs deleted file mode 100644 index 85d29eb703e..00000000000 --- a/src/test/ui/async-await/in-trait/async-associated-types2-desugared.rs +++ /dev/null @@ -1,31 +0,0 @@ -// edition: 2021 - -#![feature(async_fn_in_trait)] -#![allow(incomplete_features)] - -use std::future::Future; - -trait MyTrait { - type Fut<'a>: Future - where - Self: 'a; - - async fn foo(&self) -> Self::Fut<'a>; - //~^ ERROR use of undeclared lifetime name `'a` - //~| ERROR the parameter type `Self` may not live long enough -} - -impl MyTrait for i32 { - type Fut<'a> = impl Future + 'a - where - Self: 'a; - //~^^^ ERROR `impl Trait` in type aliases is unstable - - fn foo<'a>(&'a self) -> Self::Fut<'a> { - async { - *self - } - } -} - -fn main() {} diff --git a/src/test/ui/async-await/in-trait/async-associated-types2-desugared.stderr b/src/test/ui/async-await/in-trait/async-associated-types2-desugared.stderr deleted file mode 100644 index 6bc553b2635..00000000000 --- a/src/test/ui/async-await/in-trait/async-associated-types2-desugared.stderr +++ /dev/null @@ -1,42 +0,0 @@ -error[E0261]: use of undeclared lifetime name `'a` - --> $DIR/async-associated-types2-desugared.rs:13:38 - | -LL | async fn foo(&self) -> Self::Fut<'a>; - | ^^ undeclared lifetime - | -help: consider introducing lifetime `'a` here - | -LL | async fn foo<'a>(&self) -> Self::Fut<'a>; - | ++++ -help: consider introducing lifetime `'a` here - | -LL | trait MyTrait<'a> { - | ++++ - -error[E0658]: `impl Trait` in type aliases is unstable - --> $DIR/async-associated-types2-desugared.rs:19:20 - | -LL | type Fut<'a> = impl Future + 'a - | ^^^^^^^^^^^^^^^^ - | - = note: see issue #63063 for more information - = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable - -error[E0310]: the parameter type `Self` may not live long enough - --> $DIR/async-associated-types2-desugared.rs:13:28 - | -LL | async fn foo(&self) -> Self::Fut<'a>; - | ^^^^^^^^^^^^^ - | - = help: consider adding an explicit lifetime bound `Self: 'static`... - = note: ...so that the type `Self` will meet its required lifetime bounds... -note: ...that is required by this bound - --> $DIR/async-associated-types2-desugared.rs:11:15 - | -LL | Self: 'a; - | ^^ - -error: aborting due to 3 previous errors - -Some errors have detailed explanations: E0261, E0310, E0658. -For more information about an error, try `rustc --explain E0261`. diff --git a/src/test/ui/async-await/in-trait/async-associated-types2.rs b/src/test/ui/async-await/in-trait/async-associated-types2.rs index c2133b04bc8..e546a0579c6 100644 --- a/src/test/ui/async-await/in-trait/async-associated-types2.rs +++ b/src/test/ui/async-await/in-trait/async-associated-types2.rs @@ -1,6 +1,8 @@ +// check-pass // edition: 2021 #![feature(async_fn_in_trait)] +#![feature(type_alias_impl_trait)] #![allow(incomplete_features)] use std::future::Future; @@ -10,19 +12,15 @@ trait MyTrait { where Self: 'a; - fn foo(&self) -> Self::Fut<'a>; - //~^ ERROR use of undeclared lifetime name `'a` + fn foo<'a>(&'a self) -> Self::Fut<'a>; } impl MyTrait for i32 { - type Fut<'a> = impl Future + 'a + type Fut<'a> = impl Future + 'a where Self: 'a; - //~^^^ ERROR `impl Trait` in type aliases is unstable - //~| ERROR expected `::Fut<'a>` to be a future that resolves to `i32`, but it resolves to `<::Fut<'a> as Future>::Output` fn foo<'a>(&'a self) -> Self::Fut<'a> { - //~^ ERROR `impl` item signature doesn't match `trait` item signature async { *self } diff --git a/src/test/ui/async-await/in-trait/async-associated-types2.stderr b/src/test/ui/async-await/in-trait/async-associated-types2.stderr deleted file mode 100644 index f3343852fa0..00000000000 --- a/src/test/ui/async-await/in-trait/async-associated-types2.stderr +++ /dev/null @@ -1,63 +0,0 @@ -error[E0261]: use of undeclared lifetime name `'a` - --> $DIR/async-associated-types2.rs:13:32 - | -LL | fn foo(&self) -> Self::Fut<'a>; - | ^^ undeclared lifetime - | -help: consider introducing lifetime `'a` here - | -LL | fn foo<'a>(&self) -> Self::Fut<'a>; - | ++++ -help: consider introducing lifetime `'a` here - | -LL | trait MyTrait<'a> { - | ++++ - -error[E0658]: `impl Trait` in type aliases is unstable - --> $DIR/async-associated-types2.rs:18:20 - | -LL | type Fut<'a> = impl Future + 'a - | ^^^^^^^^^^^^^^^^ - | - = note: see issue #63063 for more information - = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable - -error[E0271]: expected `::Fut<'a>` to be a future that resolves to `i32`, but it resolves to `<::Fut<'a> as Future>::Output` - --> $DIR/async-associated-types2.rs:18:20 - | -LL | type Fut<'a> = impl Future + 'a - | ^^^^^^^^^^^^^^^^ expected `i32`, found associated type - | - = note: expected type `i32` - found associated type `<::Fut<'a> as Future>::Output` -note: required by a bound in `MyTrait::Fut` - --> $DIR/async-associated-types2.rs:9:26 - | -LL | type Fut<'a>: Future - | ^^^^^^^^^^^^ required by this bound in `MyTrait::Fut` -help: consider constraining the associated type `<::Fut<'a> as Future>::Output` to `i32` - | -LL | type Fut<'a> = impl Future + 'a - | ++++++++++++++ - -error: `impl` item signature doesn't match `trait` item signature - --> $DIR/async-associated-types2.rs:24:5 - | -LL | fn foo(&self) -> Self::Fut<'a>; - | ------------------------------- expected `fn(&'1 i32) -> ::Fut<'static>` -... -LL | fn foo<'a>(&'a self) -> Self::Fut<'a> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&'1 i32) -> ::Fut<'1>` - | - = note: expected `fn(&'1 i32) -> ::Fut<'static>` - found `fn(&'1 i32) -> ::Fut<'1>` -help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait` - --> $DIR/async-associated-types2.rs:13:22 - | -LL | fn foo(&self) -> Self::Fut<'a>; - | ^^^^ consider borrowing this type parameter in the trait - -error: aborting due to 4 previous errors - -Some errors have detailed explanations: E0261, E0271, E0658. -For more information about an error, try `rustc --explain E0261`. diff --git a/src/test/ui/async-await/in-trait/fn-not-async-err2-rpitit.rs b/src/test/ui/async-await/in-trait/fn-not-async-err2-rpitit.rs new file mode 100644 index 00000000000..faf9a43d352 --- /dev/null +++ b/src/test/ui/async-await/in-trait/fn-not-async-err2-rpitit.rs @@ -0,0 +1,22 @@ +// check-pass +// edition: 2021 + +#![feature(async_fn_in_trait)] +#![feature(return_position_impl_trait_in_trait)] +#![allow(incomplete_features)] + +use std::future::Future; + +trait MyTrait { + async fn foo(&self) -> i32; +} + +impl MyTrait for i32 { + fn foo(&self) -> impl Future + '_ { + async { + *self + } + } +} + +fn main() {} diff --git a/src/test/ui/async-await/in-trait/fn-not-async-err2.rs b/src/test/ui/async-await/in-trait/fn-not-async-err2.rs index f617a19ab34..594baa91ad8 100644 --- a/src/test/ui/async-await/in-trait/fn-not-async-err2.rs +++ b/src/test/ui/async-await/in-trait/fn-not-async-err2.rs @@ -8,7 +8,7 @@ use std::future::Future; trait MyTrait { async fn foo(&self) -> i32; } - + impl MyTrait for i32 { fn foo(&self) -> impl Future { //~^ ERROR `impl Trait` only allowed in function and inherent method return types, not in `impl` method return [E0562]