Skip to content

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

Closed

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.

Activity

  1. added
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    C-bugCategory: This is a bug.
    on Mar 7, 2019
  2. jethrogb commented on Mar 8, 2019

    @jethrogb
    ContributorAuthor

    @csmoe what do you mean "not needed"? You changed the signature of the function.

  3. Matthias247 commented on Mar 10, 2019

    @Matthias247
    Contributor

    @jethrogb This compiles for me on on playground.

  4. jethrogb commented on Mar 10, 2019

    @jethrogb
    ContributorAuthor

    @Matthias247 that's strange. The playground appears broken currently, but when I compile that locally with the latest nightly I still get the original error.

  5. csmoe commented on Mar 11, 2019

    @csmoe
    Contributor
  6. cramertj commented on Mar 11, 2019

    @cramertj
    Member

    Yes, this is a bug I'm currently working on fixing.

  7. self-assigned this
    on Mar 11, 2019
  8. nikomatsakis commented on Mar 12, 2019

    @nikomatsakis
    Contributor

    Marking this as blocking as it is part of the lifetime refactoring work that @cramertj has already started doing and should be addressed by that (as discussed here).

  9. added a commit that references this issue on Apr 2, 2019
    ec4a7ca
  10. added a commit that references this issue on Apr 2, 2019
    d86a8f3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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