Skip to content

async: hidden type for impl Trait captures lifetime that does not appear in bounds #59001

Closed
@jethrogb

Description

@jethrogb
#![feature(async_await, futures_api, await_macro)]

use std::future::Future;

async fn enter<'a, F, R>(mut callback: F)
where
    F: FnMut(&'a mut i32) -> R,
    R: Future<Output = ()> + 'a
{
    unimplemented!()
}
error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds
 --> src/lib.rs:6:1
  |
6 | where
  | ^
  |
note: hidden type `impl std::future::Future` captures the lifetime 'a as defined on the function body at 5:16
 --> src/lib.rs:5:16
  |
5 | async fn enter<'a, F, R>(mut callback: F)
  |                ^^

I think this is a bug? The RFC says

All of the input lifetimes to this function are captured in the future returned by the async function

so I'd expect the function to return impl Future<...> + 'a.

Metadata

Metadata

Assignees

Labels

A-async-awaitArea: Async & AwaitAsyncAwait-PolishAsync-await issues that are part of the "polish" areaC-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions