-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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/await regression regarding borrows across yields #65436
Comments
I'm also running into this error using Tide and a DB Pool from Diesel I've managed to get a slightly simpler/different version of the above code - I'd expect this to work because I'd expect the #![feature(optin_builtin_traits)]
struct Foo;
impl Foo {
fn v(&self) -> () {}
}
impl !Send for Foo {}
fn assert_send<T: Send>(_: T) {}
async fn take<T>(_: T) {}
fn main() {
// This compiles fine
assert_send(async {
let v = Foo.v();
take(v).await;
});
// This used to work but now doesn't
assert_send(async {
take(Foo.v()).await;
});
} I've managed to track it down to happening somewhere between these - but I'm not sure how to go about figuring this out any further (I've never built the compiler, let alone actually debugged it)
https://github.com/rust-lang/rust/compare/0b36e9dea..34e82a7b7 |
This was an intentional change to match the drop order in synchronous code: #64512 |
This was an intentional change but these errors also look like they are caused by "overapproximation" of the set of captured values. We are working to improve that; separately, we are also working on improving the diagnostics here. |
I found a similar problem: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=58544a49de7d2272ba66616ef4a0d48b Is this the same bug? |
Unassigning myself since #65345 has landed. |
It's a matter of having consistent language semantics for async and non-async code. The lang team discussed this and decided the drop order should be consistent (i.e. we shouldn't drop temporaries until the end of the statement, even if the statement contains |
The following code was working in nightly-2019-09-05, but no longer works in nightly-2019-10-15. The workaround is not quite intuitive.
(Playground)
Errors:
The text was updated successfully, but these errors were encountered: