-
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 fn trait's method's future does not implement Send trait bound #114142
Comments
I'm like 72.5% sure that this is a duplicate of #109924. |
Yes I am sorry. Totally missed that, was looking for it, but couldn't immediately spot it. What 's the status on #109924? Is that do-able to fix, or is it a can of worms situation? And can I help to progress this, as this is one of few problems that really is a blocker, as until then I cannot really spawn tasks for each incoming connection? Or is there a work around available? |
I'm just noting for the record. It's not obvious what the root cause is from the error message, since it kinda sucks.
It's essentially impossible to fix in the old trait solver. It's one of the reasons we are working on the new trait solver -- because we need deferred projection equality (#107507) to solve this problem in general. You can probably work around this by turbofishing |
Very cool. I can confirm that this indeed works in my actual code as well. Not ideal, but okay, this does unblock me. |
Not soon is all I can say, unfortunately. It takes a lot of work to rewrite one of the most delicate + fundamental parts of Rust 😃 |
Hahaha, got you. That's def. a nasty one. Thanks, appreciate it. |
For now I added the workaround to my FAQ pages, eg https://github.com/plabayo/tower-async#faq Is there btw somewhere where I can follow progress on the active work regarding the trait resolver rewrite? |
I'm gonna close this as a dupe of #109924 (edit: wrong issue, sorry), since that's the exact same root cause. |
For a second you got my hopes up, thought it was fixed :') |
I tried this code:
I expected to see this happen: it should work and print
"Hello, World!"
to the stdout.Instead, this happened: I get a compile error:
and
E0277
refers to:which is not really more helpful then the error msg itself.
Meta
Playground:
Local version:
rustc --version --verbose
:Background
I also track this issue in plabayo/tower-async#9, an issue in the
tower-async
repo, which is a monorepo of a fork of the https://github.com/tower-rs/tower and https://github.com/tower-rs/tower-http libraries that I made and maintain, making use of the new upcoming async support as advertised in https://blog.rust-lang.org/inside-rust/2023/05/03/stabilizing-async-fn-in-trait.html, which got me very excited and very invested in starting to prepare for that future.tower-async
is then used by me in another project of mine, https://github.com/plabayo/rama, which is a going to be a general proxy framework with data extraction in mind.Problem is however that it seems that the futures produced by the
tower-async
Service
does not implement Send. And without my higher order functions requiring themethod(): Send
trait bound it won't compile either.So:
Similar to the other F-async_fn_in_traitStatic async fn in traits
issues I am more then willing to help out where you can make use of me, as I am invested in making this work and thus also be able to run one day this kind of code back in the safer Rust lands of stable
rustc
:)Thanks upfront!
The text was updated successfully, but these errors were encountered: