Skip to content
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

Tokio 0.2.4 not playing well with latest stable version of Rust #1941

Closed
seguidor777 opened this issue Dec 10, 2019 · 2 comments
Closed

Tokio 0.2.4 not playing well with latest stable version of Rust #1941

seguidor777 opened this issue Dec 10, 2019 · 2 comments

Comments

@seguidor777
Copy link

Rust 1.39.0 (latest stable)

Crates:

tokio 0.2.4
futures 0.3.1

Platform

Linux latitude 4.19.0-kali5-amd64 #1 SMP Debian 4.19.37-6kali1 (2019-07-22) x86_64 GNU/Linux

Description

I created a project using the proxy example
After running cargo build I see the following errors:

   Compiling proxy v0.1.0 (/home/seguidor777/Rust/proxy)
error[E0432]: unresolved imports `tokio::net::TcpListener`, `tokio::net::TcpStream`
  --> src/main.rs:26:18
   |
26 | use tokio::net::{TcpListener, TcpStream};
   |                  ^^^^^^^^^^^  ^^^^^^^^^ no `TcpStream` in `net`
   |                  |
   |                  no `TcpListener` in `net`

error[E0433]: failed to resolve: could not find `main` in `tokio`
  --> src/main.rs:33:10
   |
33 | #[tokio::main]
   |          ^^^^ could not find `main` in `tokio`

error[E0425]: cannot find function `spawn` in crate `tokio`
  --> src/main.rs:50:16
   |
50 |         tokio::spawn(transfer);
   |                ^^^^^ not found in `tokio`
help: possible candidate is found in another module, you can import it into scope
   |
25 | use std::thread::spawn;
   |

error[E0425]: cannot find function `copy` in module `io`
  --> src/main.rs:62:32
   |
62 |     let client_to_server = io::copy(&mut ri, &mut wo);
   |                                ^^^^ not found in `io`
help: possible candidates are found in other modules, you can import them into scope
   |
25 | use core::intrinsics::copy;
   |
25 | use core::ptr::copy;
   |
25 | use futures::core_reexport::intrinsics::copy;
   |
25 | use futures::core_reexport::ptr::copy;
   |
and 5 other candidates

error[E0425]: cannot find function `copy` in module `io`
  --> src/main.rs:63:32
   |
63 |     let server_to_client = io::copy(&mut ro, &mut wi);
   |                                ^^^^ not found in `io`
help: possible candidates are found in other modules, you can import them into scope
   |
25 | use core::intrinsics::copy;
   |
25 | use core::ptr::copy;
   |
25 | use futures::core_reexport::intrinsics::copy;
   |
25 | use futures::core_reexport::ptr::copy;
   |
and 5 other candidates

error[E0277]: `main` has invalid return type `impl core::future::future::Future`
  --> src/main.rs:34:20
   |
34 | async fn main() -> Result<(), Box<dyn Error>> {
   |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^ `main` can only return types that implement `std::process::Termination`
   |
   = help: consider using `()`, or a `Result`

error: aborting due to 6 previous errors

Some errors have detailed explanations: E0277, E0425, E0432, E0433.
For more information about an error, try `rustc --explain E0277`.
error: could not compile `proxy`.

To learn more, run the command again with --verbose.

Could you please let me know if there really is a problem with the versions or if there are others that I should use?

@asonix
Copy link
Contributor

asonix commented Dec 10, 2019

it looks to me like you haven't added any features to your tokio dependency.

try

tokio = { version = "0.2.4", features = ["full"] }

It also looks like Result<(), Box<dyn Error>> doesn't implement Termination, which is unfortunate. You could try replacing Box<dyn Error> with anyhow::Error (docs) and see if that gets you where you need.

@seguidor777
Copy link
Author

You are absolutely right, I am new to Rust and did not know of the features addition.

Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants