Closed
Description
Encountered in these test cases:
async-generics.rs
async-generics-and-bounds.rs
async-lifetimes-and-bounds.rs
From #102642
Here is async-generics.rs
// edition: 2021
#![feature(async_fn_in_trait)]
#![allow(incomplete_features)]
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) {
self
}
}
fn main() {}
I expected to see this happen: Successful compilation
Instead, this happened:
error[E0311]: the parameter type `U` may not live long enough
--> $DIR/async-generics.rs:7: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
|
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
|
LL | async fn foo(&self) -> &(T, U);
| ^^^^^^^
error[E0311]: the parameter type `T` may not live long enough
--> $DIR/async-generics.rs:7: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
|
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
|
LL | async fn foo(&self) -> &(T, U);
| ^^^^^^^
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0311`.
Meta
rustc --version --verbose
:
rustc 1.66.0-nightly (092255976 2022-10-03)
binary: rustc
commit-hash: 092255976862c1f0121bb4446acd38336a860c4f
commit-date: 2022-10-03
host: x86_64-unknown-linux-gnu
release: 1.66.0-nightly
LLVM version: 15.0.2