Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jethrogb opened this Issue Mar 7, 2019 · 7 comments

Comments

Projects
None yet
6 participants
@jethrogb
Copy link
Contributor

jethrogb commented Mar 7, 2019

#![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.

@jethrogb

This comment has been minimized.

Copy link
Contributor Author

jethrogb commented Mar 8, 2019

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

@Matthias247

This comment has been minimized.

Copy link
Contributor

Matthias247 commented Mar 10, 2019

@jethrogb This compiles for me on on playground.

@jethrogb

This comment has been minimized.

Copy link
Contributor Author

jethrogb commented Mar 10, 2019

@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.

@csmoe

This comment has been minimized.

Copy link
Member

csmoe commented Mar 11, 2019

@cramertj

This comment has been minimized.

Copy link
Member

cramertj commented Mar 11, 2019

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

@nikomatsakis

This comment has been minimized.

Copy link
Contributor

nikomatsakis commented Mar 12, 2019

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.