-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Explanation for why future is not Send is wrong #68112
Comments
Some version of this is roughly the error message I'd want. |
@rustbot modify labels to +AsyncAwait-OnDeck +AsyncAwait-Triaged |
A few thoughts:
If you remove the second await, you get this error (playground):
Granted, also wrong, though it might be "correct" in the sense that the compiler thinks that |
yes, live-across-yield analysis inside generator should be more precise, a test case from #![feature(optin_builtin_traits)]
// edition:2018
struct Foo;
impl !Send for Foo {}
fn is_send<T: Send>(t: T) { }
async fn bar() {
let x = Foo;
baz().await;
}
async fn baz() { }
fn main() {
is_send(bar());
} this snippet will compile if the non-Send |
Improve async-await/generator obligation errors in some cases Fixes rust-lang#68112. This change is best read one commit at a time (I add a test at the beginning and update it in each change after). The `test2` function is a case I found while writing the test that we don't handle with this code yet. I don't attempt to fix it in this PR, but it's a good candidate for future work. r? @davidtwco, @nikomatsakis
The following code (playground):
Gives an error message stating that
non_send_fut
can live until the end of the scope, and that's whysend_fut
is notSend
:but it doesn't; it's consumed by value when it gets awaited. The problem is we're awaiting a non-
Send
future inside ofsend_fut
, which has to beSend
.Also, the text
is wrong;
main
doesn't return anything.Thanks to @kellerb for the reproducer and @JakeEhrlich for originally reporting this.
The text was updated successfully, but these errors were encountered: