title: Cannot find tokio::main macro?
body: <p>I am creating a sample Rust project in my Windows system to download a file by HTTP GET request in async mode.</p>
  <p>My code is as follows (same as <a href="https://rust-lang-nursery.github.io/rust-cookbook/web/clients/download.html" rel="noreferrer">the code</a> mentioned in the Rust Cookbook):</p>
  <pre class="lang-rust prettyprint-override"><code>extern crate error_chain;
  extern crate tempfile;
  extern crate tokio;
  extern crate reqwest;
  
  use error_chain::error_chain;
  use std::io::copy;
  use std::fs::File;
  use tempfile::Builder;
  
  error_chain! {
       foreign_links {
           Io(std::io::Error);
           HttpRequest(reqwest::Error);
       }
  }
  
  #[tokio::main]
  async fn main() -&gt; Result&lt;()&gt; {
      let tmp_dir = Builder::new().prefix(&quot;example&quot;).tempdir()?;
      let target = &quot;https://www.rust-lang.org/logos/rust-logo-512x512.png&quot;;
      let response = reqwest::get(target).await?;
  
      let mut dest = {
          let fname = response
              .url()
              .path_segments()
              .and_then(|segments| segments.last())
              .and_then(|name| if name.is_empty() { None } else { Some(name) })
              .unwrap_or(&quot;tmp.bin&quot;);
  
          println!(&quot;file to download: '{}'&quot;, fname);
          let fname = tmp_dir.path().join(fname);
          println!(&quot;will be located under: '{:?}'&quot;, fname);
          File::create(fname)?
      };
      let content =  response.text().await?;
      copy(&amp;mut content.as_bytes(), &amp;mut dest)?;
      Ok(())
  }
  
  </code></pre>
  <p>My Cargo.toml file is:</p>
  <pre><code>[package]
  name = &quot;abcdef&quot;
  version = &quot;0.1.0&quot;
  authors = [&quot;xyz&quot;]
  edition = &quot;2018&quot;
  
  # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
  
  [dependencies]
  error-chain = &quot;0.12.4&quot;
  tempfile = &quot;3.1.0&quot;
  tokio = &quot;0.2.22&quot;
  reqwest = &quot;0.10.8&quot;
  </code></pre>
  <p>When I execute <code>cargo run</code>, the following errors are displayed:</p>
  <pre class="lang-none prettyprint-override"><code>error[E0433]: failed to resolve: could not find `main` in `tokio`
    --&gt; src\main.rs:18:10
     |
  18 | #[tokio::main]
     |          ^^^^ could not find `main` in `tokio`
  
  error[E0277]: `main` has invalid return type `impl std::future::Future`
    --&gt; src\main.rs:19:20
     |
  19 | async fn main() -&gt; Result&lt;()&gt; {
     |                    ^^^^^^^^^^ `main` can only return types that implement `
  std::process::Termination`
     |
     = help: consider using `()`, or a `Result`
  
  error[E0752]: `main` function is not allowed to be `async`
    --&gt; src\main.rs:19:1
     |
  19 | async fn main() -&gt; Result&lt;()&gt; {
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `main` function is not allowed to be `async`
  </code></pre>
  <p>I cross-checked from the Cargo.toml file &amp; <code>edition = &quot;2018&quot;</code> was already there. I am unable to figure out the other errors.</p>