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

lowering: extend temporary lifetimes around await #64292

Merged

Commits on Sep 10, 2019

  1. lowering: extend temporary lifetimes around await

    This commit changes the HIR lowering around `await` so that temporary
    lifetimes are extended. Previously, await was lowered as:
    
    ```rust
    {
        let mut pinned = future;
        loop {
            match ::std::future::poll_with_tls_context(unsafe {
                <::std::pin::Pin>::new_unchecked(&mut pinned)
            }) {
                ::std::task::Poll::Ready(result) => break result,
                ::std::task::Poll::Pending => {}
            }
            yield ();
        }
    }
    ```
    
    With this commit, await is lowered as:
    
    ```rust
    match future {
        mut pinned => loop {
            match ::std::future::poll_with_tls_context(unsafe {
                <::std::pin::Pin>::new_unchecked(&mut pinned)
            }) {
                ::std::task::Poll::Ready(result) => break result,
                ::std::task::Poll::Pending => {}
            }
            yield ();
        }
    }
    ```
    
    However, this change has the following side-effects:
    
    - All temporaries in future will be considered to live across a
      yield for the purpose of auto-traits.
    - Borrowed temporaries in future are likely to be considered to be live
      across the yield for the purpose of the generator transform.
    
    Signed-off-by: David Wood <david@davidtw.co>
    davidtwco committed Sep 10, 2019
    Configuration menu
    Copy the full SHA
    63fad69 View commit details
    Browse the repository at this point in the history