title: Error: Could not find main or io in tokio, invalid return type `impl Future`
body: <p>I'm on my way of converting to Rust from the ML family, but I'm finding it hard at some strange places I'm not used to having problems.</p>
  <p>I'm trying to use <code>hyper</code> for http handling but can't seem to get <code>tokio</code> to work.</p>
  <p>I have tried to copy paste this <a href="https://github.com/hyperium/hyper/blob/master/examples/client.rs" rel="nofollow noreferrer">example</a>:</p>
  <pre class="lang-rust prettyprint-override"><code>use hyper::{body::HttpBody as _, Client};
  use tokio::io::{self, AsyncWriteExt as _};
  
  type Result&lt;T&gt; = std::result::Result&lt;T, Box&lt;dyn std::error::Error + Send + Sync&gt;&gt;;
  
  #[tokio::main]
  async fn main() -&gt; Result&lt;()&gt; {
      // ...
      fetch_url(url).await
  }
  
  
  async fn fetch_url(url: hyper::Uri) -&gt; Result&lt;()&gt; {
      // ...
      Ok(())
  }
  </code></pre>
  <p>Here is my <code>Cargo.toml</code>:</p>
  <pre><code>[package]
  name = &quot;projectname&quot;
  version = &quot;0.1.0&quot;
  authors = [&quot;username&quot;]
  edition = &quot;2018&quot;
      
  [dependencies]
  hyper = &quot;0.14.4&quot;
  tokio = &quot;1.2.0&quot;
  </code></pre>
  <p>It is complaining that it can't find the <code>io</code> crate, and that <code>main</code> has an invalid type <code>impl Future</code>, and that it can't find <code>main</code> in <code>tokio</code>:</p>
  <pre class="lang-none prettyprint-override"><code>error[E0433]: failed to resolve: could not find `main` in `tokio`
   --&gt; src/main.rs:9:10
    |
  9 | #[tokio::main]
    |          ^^^^ could not find `main` in `tokio`
  
  error[E0277]: `main` has invalid return type `impl Future`
    --&gt; src/main.rs:10:20
     |
  10 | async fn main() -&gt; Result&lt;()&gt; {
     |                    ^^^^^^^^^^ `main` can only return types that implement `Termination`
  
  error[E0432]: unresolved import `hyper::Client`
   --&gt; src/main.rs:3:34
    |
  3 | use hyper::{body::HttpBody as _, Client};
    |                                  ^^^^^^ no `Client` in the root
  
  error[E0425]: cannot find function `stdout` in module `io`
    --&gt; src/main.rs:45:13
     |
  45 |         io::stdout().write_all(&amp;chunk).await?;
     |             ^^^^^^ not found in `io`
     |
  
  error[E0432]: unresolved import `tokio::io::AsyncWriteExt`
   --&gt; src/main.rs:4:23
    |
  4 | use tokio::io::{self, AsyncWriteExt as _};
    |                       -------------^^^^^
    |                       |
    |                       no `AsyncWriteExt` in `io`
    |                       help: a similar name exists in the module: `AsyncWrite`
  </code></pre>
  <p>Is <code>#[tokio::main]</code> and <code>client</code> not in hyper?</p>