-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Tracking issue for more precise coroutine captures #69663
Comments
I've created a "meta-issue" to track these improvements. |
This commit implements a workaround for an [issue within rustc]. The problem showed itself when using e.g. a `Vec<&str>` argument in an async route handler (but not `&str`), which resulted in a "implementation of `FromForm` is not general enough" error. The workaround itself works by gathering all invocations of `FromForm`'s methods inside a block without any `.await` points [ref]. [issue within rustc]: rust-lang/rust#69663 [ref]: rust-lang/rust#57478 (comment)
This commit implements a workaround for an [issue within rustc]. The problem showed itself when using e.g. a `Vec<&str>` argument in an async route handler (but not `&str`), which resulted in a "implementation of `FromForm` is not general enough" error. The workaround itself works by gathering all invocations of `FromForm`'s methods inside a block without any `.await` points [ref]. [issue within rustc]: rust-lang/rust#69663 [ref]: rust-lang/rust#57478 (comment)
This commit implements a workaround for an [issue within rustc]. The problem showed itself when using e.g. a `Vec<&str>` argument in an async route handler (but not `&str`), which resulted in a "implementation of `FromForm` is not general enough" error. The workaround itself works by gathering all invocations of `FromForm`'s methods inside a block without any `.await` points [ref]. [issue within rustc]: rust-lang/rust#69663 [ref]: rust-lang/rust#57478 (comment)
I think #94067 counts as another instance of this bug. |
Is this issue also tracking the case where the reference to the local struct SendButNotSync(std::cell::RefCell<String>);
async fn work() {}
fn more_work(owned: SendButNotSync) -> impl std::future::Future<Output = ()> + Send {
async move {
// Keeps a reference of `owned`.
let borrowed = owned.0.borrow();
// During the context switch, no one can mutate either `owned` or `borrowed`.
work().await;
// Regain `owned` and `borrowed` BOTH on the same but possibly another thread.
println!("{borrowed}");
}
} I can imagine that during |
Will the issue soon be fixed? I am really hoping on this one |
Today, valid programs using coroutines (and async/await) are rejected by the compiler because it thinks certain values may be held across yields when they are not.
Examples / to do: (please add more as they come up)
index
method and[idx]
sugar works differently inasync
blocks/functions #72956await
inasync fn
#87309Unresolved Questions
How should we implement this?
Are there any programs which could be accepted, but shouldn't be because they would depend too heavily on implementation details of the compiler?
Implementation notes
There's some discussion here: #57017 (comment)
This issue has been assigned to @eholk via this comment.
The text was updated successfully, but these errors were encountered: