Update tests based on feedback

This commit is contained in:
Bryan Garza 2022-10-07 16:08:56 +00:00
parent 8a0ebca97e
commit 11b1439380
10 changed files with 48 additions and 33 deletions

View File

@ -1,3 +1,5 @@
// check-fail
// known-bug: #102682
// edition: 2021
#![feature(async_fn_in_trait)]
@ -18,7 +20,5 @@ impl<'a, 'b, T: Debug + Sized + 'b, U: 'a> MyTrait<'a, 'b, T> for U {
(self, key)
}
}
//~^^^^ ERROR cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements
//~| ERROR cannot infer an appropriate lifetime for lifetime parameter `'b` due to conflicting requirements
fn main() {}

View File

@ -1,16 +1,16 @@
error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements
--> $DIR/async-associated-types.rs:17:43
--> $DIR/async-associated-types.rs:19:43
|
LL | async fn foo(&'a self, key: &'b T) -> (&'a U, &'b T) {
| ^^^^^^^^^^^^^^
|
note: first, the lifetime cannot outlive the lifetime `'a` as defined here...
--> $DIR/async-associated-types.rs:14:6
--> $DIR/async-associated-types.rs:16:6
|
LL | impl<'a, 'b, T: Debug + Sized + 'b, U: 'a> MyTrait<'a, 'b, T> for U {
| ^^
note: ...so that the types are compatible
--> $DIR/async-associated-types.rs:17:43
--> $DIR/async-associated-types.rs:19:43
|
LL | async fn foo(&'a self, key: &'b T) -> (&'a U, &'b T) {
| ^^^^^^^^^^^^^^
@ -18,7 +18,7 @@ LL | async fn foo(&'a self, key: &'b T) -> (&'a U, &'b T) {
found `(&U, &T)`
= note: but, the lifetime must be valid for the static lifetime...
note: ...so that the types are compatible
--> $DIR/async-associated-types.rs:17:43
--> $DIR/async-associated-types.rs:19:43
|
LL | async fn foo(&'a self, key: &'b T) -> (&'a U, &'b T) {
| ^^^^^^^^^^^^^^
@ -26,18 +26,18 @@ LL | async fn foo(&'a self, key: &'b T) -> (&'a U, &'b T) {
found `MyTrait<'_, '_, T>`
error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'b` due to conflicting requirements
--> $DIR/async-associated-types.rs:17:43
--> $DIR/async-associated-types.rs:19:43
|
LL | async fn foo(&'a self, key: &'b T) -> (&'a U, &'b T) {
| ^^^^^^^^^^^^^^
|
note: first, the lifetime cannot outlive the lifetime `'b` as defined here...
--> $DIR/async-associated-types.rs:14:10
--> $DIR/async-associated-types.rs:16:10
|
LL | impl<'a, 'b, T: Debug + Sized + 'b, U: 'a> MyTrait<'a, 'b, T> for U {
| ^^
note: ...so that the types are compatible
--> $DIR/async-associated-types.rs:17:43
--> $DIR/async-associated-types.rs:19:43
|
LL | async fn foo(&'a self, key: &'b T) -> (&'a U, &'b T) {
| ^^^^^^^^^^^^^^
@ -45,7 +45,7 @@ LL | async fn foo(&'a self, key: &'b T) -> (&'a U, &'b T) {
found `(&U, &T)`
= note: but, the lifetime must be valid for the static lifetime...
note: ...so that the types are compatible
--> $DIR/async-associated-types.rs:17:43
--> $DIR/async-associated-types.rs:19:43
|
LL | async fn foo(&'a self, key: &'b T) -> (&'a U, &'b T) {
| ^^^^^^^^^^^^^^

View File

@ -6,12 +6,27 @@
trait MyTrait {
async fn foo(&self) -> i32;
async fn bar(&self) -> i32;
}
impl MyTrait for i32 {
async fn foo(&self) -> i32 {
*self
}
async fn bar(&self) -> i32 {
self.foo().await
}
}
fn main() {}
fn main() {
let x = 5;
// Calling from non-async context
let _ = x.foo();
let _ = x.bar();
// Calling from async block in non-async context
async {
let _ = x.foo();
let _ = x.bar();
};
}

View File

@ -1,3 +1,5 @@
// check-fail
// known-bug: #102682
// edition: 2021
#![feature(async_fn_in_trait)]
@ -9,8 +11,6 @@ use std::hash::Hash;
trait MyTrait<T, U> {
async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash;
}
//~^^ ERROR the parameter type `U` may not live long enough
//~| ERROR the parameter type `T` may not live long enough
impl<T, U> MyTrait<T, U> for (T, U) {
async fn foo(&self) -> &(T, U) {

View File

@ -1,33 +1,33 @@
error[E0311]: the parameter type `U` may not live long enough
--> $DIR/async-generics-and-bounds.rs:10:28
--> $DIR/async-generics-and-bounds.rs:12:28
|
LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash;
| ^^^^^^^
|
note: the parameter type `U` must be valid for the anonymous lifetime as defined here...
--> $DIR/async-generics-and-bounds.rs:10:18
--> $DIR/async-generics-and-bounds.rs:12:18
|
LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash;
| ^
note: ...so that the reference type `&(T, U)` does not outlive the data it points at
--> $DIR/async-generics-and-bounds.rs:10:28
--> $DIR/async-generics-and-bounds.rs:12:28
|
LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash;
| ^^^^^^^
error[E0311]: the parameter type `T` may not live long enough
--> $DIR/async-generics-and-bounds.rs:10:28
--> $DIR/async-generics-and-bounds.rs:12:28
|
LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash;
| ^^^^^^^
|
note: the parameter type `T` must be valid for the anonymous lifetime as defined here...
--> $DIR/async-generics-and-bounds.rs:10:18
--> $DIR/async-generics-and-bounds.rs:12:18
|
LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash;
| ^
note: ...so that the reference type `&(T, U)` does not outlive the data it points at
--> $DIR/async-generics-and-bounds.rs:10:28
--> $DIR/async-generics-and-bounds.rs:12:28
|
LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash;
| ^^^^^^^

View File

@ -1,3 +1,5 @@
// check-fail
// known-bug: #102682
// edition: 2021
#![feature(async_fn_in_trait)]
@ -6,8 +8,6 @@
trait MyTrait<T, U> {
async fn foo(&self) -> &(T, U);
}
//~^^ ERROR the parameter type `U` may not live long enough
//~| ERROR the parameter type `T` may not live long enough
impl<T, U> MyTrait<T, U> for (T, U) {
async fn foo(&self) -> &(T, U) {

View File

@ -1,33 +1,33 @@
error[E0311]: the parameter type `U` may not live long enough
--> $DIR/async-generics.rs:7:28
--> $DIR/async-generics.rs:9:28
|
LL | async fn foo(&self) -> &(T, U);
| ^^^^^^^
|
note: the parameter type `U` must be valid for the anonymous lifetime as defined here...
--> $DIR/async-generics.rs:7:18
--> $DIR/async-generics.rs:9:18
|
LL | async fn foo(&self) -> &(T, U);
| ^
note: ...so that the reference type `&(T, U)` does not outlive the data it points at
--> $DIR/async-generics.rs:7:28
--> $DIR/async-generics.rs:9:28
|
LL | async fn foo(&self) -> &(T, U);
| ^^^^^^^
error[E0311]: the parameter type `T` may not live long enough
--> $DIR/async-generics.rs:7:28
--> $DIR/async-generics.rs:9:28
|
LL | async fn foo(&self) -> &(T, U);
| ^^^^^^^
|
note: the parameter type `T` must be valid for the anonymous lifetime as defined here...
--> $DIR/async-generics.rs:7:18
--> $DIR/async-generics.rs:9:18
|
LL | async fn foo(&self) -> &(T, U);
| ^
note: ...so that the reference type `&(T, U)` does not outlive the data it points at
--> $DIR/async-generics.rs:7:28
--> $DIR/async-generics.rs:9:28
|
LL | async fn foo(&self) -> &(T, U);
| ^^^^^^^

View File

@ -1,3 +1,5 @@
// check-fail
// known-bug: #102682
// edition: 2021
#![feature(async_fn_in_trait)]
@ -8,8 +10,6 @@ use std::fmt::Debug;
trait MyTrait<'a, 'b, T> {
async fn foo(&'a self, key: &'b T) -> (&'a Self, &'b T) where T: Debug + Sized;
}
//~^^ ERROR the parameter type `Self` may not live long enough
//~| ERROR the parameter type `T` may not live long enough
impl<'a, 'b, T, U> MyTrait<'a, 'b, T> for U {
async fn foo(&'a self, key: &'b T) -> (&'a U, &'b T) {

View File

@ -1,5 +1,5 @@
error[E0309]: the parameter type `Self` may not live long enough
--> $DIR/async-lifetimes-and-bounds.rs:9:43
--> $DIR/async-lifetimes-and-bounds.rs:11:43
|
LL | async fn foo(&'a self, key: &'b T) -> (&'a Self, &'b T) where T: Debug + Sized;
| ^^^^^^^^^^^^^^^^^
@ -8,7 +8,7 @@ LL | async fn foo(&'a self, key: &'b T) -> (&'a Self, &'b T) where T: Debug
= note: ...so that the reference type `&'a Self` does not outlive the data it points at
error[E0309]: the parameter type `T` may not live long enough
--> $DIR/async-lifetimes-and-bounds.rs:9:43
--> $DIR/async-lifetimes-and-bounds.rs:11:43
|
LL | async fn foo(&'a self, key: &'b T) -> (&'a Self, &'b T) where T: Debug + Sized;
| ^^^^^^^^^^^^^^^^^ ...so that the reference type `&'b T` does not outlive the data it points at

View File

@ -5,9 +5,9 @@
trait MyTrait<'a, 'b, T> {
async fn foo(&'a self, key: &'b T) -> (&'a Self, &'b T);
//~^ ERROR the parameter type `Self` may not live long enough
//~| ERROR the parameter type `T` may not live long enough
}
//~^^ ERROR the parameter type `Self` may not live long enough
//~| ERROR the parameter type `T` may not live long enough
impl<'a, 'b, T, U> MyTrait<'a, 'b, T> for U {
async fn foo(&'a self, key: &'b T) -> (&'a U, &'b T) {