Update static AFIT tests based on feedback
This commit is contained in:
parent
97423d331f
commit
8a0ebca97e
@ -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;
|
||||
}
|
||||
|
@ -1,31 +0,0 @@
|
||||
// edition: 2021
|
||||
|
||||
#![feature(async_fn_in_trait)]
|
||||
#![allow(incomplete_features)]
|
||||
|
||||
use std::future::Future;
|
||||
|
||||
trait MyTrait {
|
||||
type Fut<'a>: Future<Output = i32>
|
||||
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() {}
|
@ -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 <https://github.com/rust-lang/rust/issues/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`.
|
@ -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<Output = i32> + 'a
|
||||
where
|
||||
Self: 'a;
|
||||
//~^^^ ERROR `impl Trait` in type aliases is unstable
|
||||
//~| ERROR expected `<i32 as MyTrait>::Fut<'a>` to be a future that resolves to `i32`, but it resolves to `<<i32 as MyTrait>::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
|
||||
}
|
||||
|
@ -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 <https://github.com/rust-lang/rust/issues/63063> for more information
|
||||
= help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable
|
||||
|
||||
error[E0271]: expected `<i32 as MyTrait>::Fut<'a>` to be a future that resolves to `i32`, but it resolves to `<<i32 as MyTrait>::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 `<<i32 as MyTrait>::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<Output = i32>
|
||||
| ^^^^^^^^^^^^ required by this bound in `MyTrait::Fut`
|
||||
help: consider constraining the associated type `<<i32 as MyTrait>::Fut<'a> as Future>::Output` to `i32`
|
||||
|
|
||||
LL | type Fut<'a> = impl Future<Output = i32> + '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) -> <i32 as MyTrait>::Fut<'static>`
|
||||
...
|
||||
LL | fn foo<'a>(&'a self) -> Self::Fut<'a> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&'1 i32) -> <i32 as MyTrait>::Fut<'1>`
|
||||
|
|
||||
= note: expected `fn(&'1 i32) -> <i32 as MyTrait>::Fut<'static>`
|
||||
found `fn(&'1 i32) -> <i32 as MyTrait>::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`.
|
22
src/test/ui/async-await/in-trait/fn-not-async-err2-rpitit.rs
Normal file
22
src/test/ui/async-await/in-trait/fn-not-async-err2-rpitit.rs
Normal file
@ -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<Output = i32> + '_ {
|
||||
async {
|
||||
*self
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
@ -8,7 +8,7 @@ use std::future::Future;
|
||||
trait MyTrait {
|
||||
async fn foo(&self) -> i32;
|
||||
}
|
||||
|
||||
|
||||
impl MyTrait for i32 {
|
||||
fn foo(&self) -> impl Future<Output = i32> {
|
||||
//~^ ERROR `impl Trait` only allowed in function and inherent method return types, not in `impl` method return [E0562]
|
||||
|
Loading…
x
Reference in New Issue
Block a user