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
Send marker compile error when trying to use tokio::run() on a trait method returning a Box<Future<...>> #670
Comments
You need You were close in recognizing that |
Indeed, thanks for pointing it out @tobz Just wondering, is there a good reason for |
That I personally do not know. :/ Technically, futures are maintained over in the rust-lang-nursery/futures-rs repository. It might be worth asking there, but Tokio uses futures 0.1 which is effectively deprecated, so it really doesn't get much TLC. Not sure how receptive they'd be to such a change, but that is based on the idea that there isn't already a good reason that they didn't add it in the first place. :P |
I just got hit by this particular footgun. Could someone please update the documentation here? https://tokio.rs/docs/going-deeper/returning/ |
@jeff-at-dwelo I opened tokio-rs/doc-push#87 to track the doc issue. I would greatly appreciate it if you could take a stab at updating the docs. Note that the "returning futures" section has actually moved (linked in the issue above). |
Opened tokio-rs/website#247 with some potential changes. It doesn't look like the "returning futures" has moved, as the old section is still there. I tweaked both. No issue with deleting the old page in a separate PR, but as long as it's there it should be a good example. |
Version 0.1.8
│ │ └── tokio-io v0.1.8
│ ├── tokio v0.1.8
│ │ ├── tokio-codec v0.1.0
│ │ │ └── tokio-io v0.1.8 ()
│ │ ├── tokio-current-thread v0.1.1
│ │ │ └── tokio-executor v0.1.4
│ │ ├── tokio-executor v0.1.4 ()
│ │ ├── tokio-fs v0.1.3
│ │ │ ├── tokio-io v0.1.8 ()
│ │ │ └── tokio-threadpool v0.1.6
│ │ │ └── tokio-executor v0.1.4 ()
│ │ │ └── tokio-io v0.1.8 ()
│ │ ├── tokio-io v0.1.8 ()
│ │ ├── tokio-reactor v0.1.5
│ │ │ ├── tokio-executor v0.1.4 ()
│ │ │ └── tokio-io v0.1.8 ()
│ │ ├── tokio-tcp v0.1.1
│ │ │ ├── tokio-io v0.1.8 ()
│ │ │ └── tokio-reactor v0.1.5 ()
│ │ ├── tokio-threadpool v0.1.6 ()
│ │ ├── tokio-timer v0.2.6
│ │ │ └── tokio-executor v0.1.4 ()
│ │ ├── tokio-udp v0.1.2
│ │ │ ├── tokio-codec v0.1.0 ()
│ │ │ ├── tokio-io v0.1.8 ()
│ │ │ └── tokio-reactor v0.1.5 ()
│ │ └── tokio-uds v0.2.1
│ │ ├── tokio-io v0.1.8 ()
│ │ └── tokio-reactor v0.1.5 ()
│ ├── tokio-executor v0.1.4 ()
│ ├── tokio-io v0.1.8 ()
│ ├── tokio-reactor v0.1.5 ()
│ ├── tokio-tcp v0.1.1 ()
│ ├── tokio-timer v0.2.6 ()
│ └── tokio-io v0.1.8 ()
└── tokio v0.1.8 ()
Platform
Darwin MBPR-de-Boris 17.7.0 Darwin Kernel Version 17.7.0: Thu Jun 21 22:53:14 PDT 2018; root:xnu-4570.71.2~1/RELEASE_X86_64 x86_64
Description
I am trying to build a library defining a generic datasource which can pull data from various sources, synchronously and asynchronously. When building the async piece, I ran into the following compilation issue which I don't understand how to address.
Here is my (simplified) code (playground link)
I got the following compilation error:
Yet when looking into the standard library, I found the following implementations:
impl<T: ?Sized> Send for Box<T> where T: Send
impl<T> Send for Option<T> where T: Send
impl<T> Send for Vec<T> where T: Send
impl Send for String
After further testing, I got rid of the Trait and replaced the
Box<Future<...>>
byimpl Future<...>
. Then it works (playground link for the new code); yet I don't understand what is wrong with the previous (i.e. Trait & Box) implementation?The text was updated successfully, but these errors were encountered: