-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
lowering: extend temporary lifetimes around await #64292
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.)?
src/test/ui/async-await/issue-63832-await-short-temporary-lifetime-1.rs
Outdated
Show resolved
Hide resolved
Signed-off-by: David Wood <david@davidtw.co>
78ea5f5
to
2f3c957
Compare
Thanks @Centril, fixed those comments and opened rust-lang/reference#674. |
2f3c957
to
8e3fb22
Compare
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
63fad69
Compare
@bors r+ |
📌 Commit 63fad69 has been approved by |
…ry-lifetimes, r=matthewjasper lowering: extend temporary lifetimes around await Fixes rust-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
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.
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? |
So are the above examples a regression? |
Depends... can you create a minimal reproducer for before/after? |
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: async fn add(x: u32, y: u32) -> u32 {
async { x + y }.await
} After: async fn add(x: u32, y: u32) -> u32 {
let a = async { x + y };
a.await
} |
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? |
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