Uh oh!
There was an error while loading. Please reload this page.
lowering: extend temporary lifetimes around await - #64292
Conversation
Centril
left a comment
There was a problem hiding this comment.
Could you please also update the doc comment on fn lower_expr_await to accurately reflect the new desugaring and then follow up with a PR against the reference (See rust-lang/reference#635 for @nikomatsakis's initial PR.)?
Uh oh!
There was an error while loading. Please reload this page.
Signed-off-by: David Wood <david@davidtw.co>
78ea5f5 to
2f3c957Comparedavidtwco
commented
Sep 8, 2019
Thanks @Centril, fixed those comments and opened rust-lang/reference#674. |
Uh oh!
There was an error while loading. Please reload this page.
2f3c957 to
8e3fb22CompareUh oh!
There was an error while loading. Please reload this page.
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>8e3fb22 to
63fad69Comparematthewjasper
commented
Sep 10, 2019
@bors r+ |
bors
commented
Sep 10, 2019
📌 Commit 63fad69 has been approved by |
…ry-lifetimes, r=matthewjasper lowering: extend temporary lifetimes around await Fixesrust-lang#63832. r? @matthewjasper cc @nikomatsakis
Rollup of 8 pull requests Successful merges: - #63786 (Make `abs`, `wrapping_abs`, `overflowing_abs` const functions) - #63989 (Add Yaah to clippy toolstain notification list) - #64256 (test/c-variadic: Fix patterns on powerpc64) - #64292 (lowering: extend temporary lifetimes around await) - #64311 (lldb: avoid mixing "Hit breakpoint" message with other output.) - #64330 (Clarify E0507 to note Fn/FnMut relationship to borrowing) - #64331 (Changed instant is earlier to instant is later) - #64344 (rustc_mir: buffer -Zdump-mir output instead of pestering the kernel constantly.) Failed merges: r? @ghost
RalfJung
commented
Sep 11, 2019
Is it expected that this is a breaking change? A Miri testcase is failing now: |
fix async test Test got broken by rust-lang/rust#64292.
yoshuawuyts
commented
Sep 11, 2019
Not sure if this was intended to cause breakage, but we had to patch our code in async-std likely because of this PR: https://github.com/async-rs/async-std/pull/182/files. before peer.send(format!("from {}: {}\n", from, msg)).await?after let msg = format!("from {}: {}\n", from, msg);
peer.send(msg).await? |
seanmonstar
commented
Sep 11, 2019
So are the above examples a regression? |
Centril
commented
Sep 11, 2019
Depends... can you create a minimal reproducer for before/after? |
tmandry
commented
Sep 11, 2019
This causes errors to crop up all over the Fuchsia code base. Based on #63832 (comment), it seems like this might have been expected, however. |
@Centril The change in miri is quite succinct, and the "before" doesn't appear to be bad... while the "after" seems odd? https://github.com/rust-lang/miri/pull/946/files#diff-ecc42d2008d431ab52ee698995abd41b Is something more needed? Inlined: Before: asyncfnadd(x:u32,y:u32) -> u32{async{ x + y }.await}After: asyncfnadd(x:u32,y:u32) -> u32{let a = async{ x + y };
a.await} |
davidtwco
commented
Sep 12, 2019
I've confirmed locally that this patch did cause these regressions. I'm not sure what the best way to proceed here is, @nikomatsakis@Centril@matthewjasper? |
pimeys
commented
Sep 12, 2019
Seems that this patch broke my test server with Tide. https://github.com/pimeys/blocking_test/ Works with 2019-09-10, broken in 2019-09-11. |
Update reference - Add macros in extern blocks and new proc-macro support. - Update for "modern" `meta` matcher. - Update await desugaring after rust-lang#64292
Update reference - Add macros in extern blocks and new proc-macro support. - Update for "modern" `meta` matcher. - Update await desugaring after rust-lang#64292
Signed-off-by: David Wood <david@davidtw.co>
Fixes#63832.
r? @matthewjasper
cc @nikomatsakis