title: Compiling an application using actix-web + mongo runs out of memory on Linux
body: <p>I am unable to compile the following on Linux (Ubuntu 18 Bionic Beaver). I have tried both Docker and VirtualBox VMs, but <code>rustc</code> eventually runs out of memory on both. The code compiles without issue on macOS, and compiled on Linux until roughly 5 days ago.</p>
  <pre class="lang-rust prettyprint-override"><code>use {
      actix_web::{
          get,
          web::{self},
          App, HttpResponse, HttpServer,
      },
      mongodb::{
          options::{ClientOptions, StreamAddress},
          Client, Database,
      },
  };
  
  #[actix_rt::main]
  async fn main() -&gt; std::io::Result&lt;()&gt; {
      let options = ClientOptions::builder()
          .hosts(vec![StreamAddress {
              hostname: &quot;localhost&quot;.into(),
              port: Some(27017),
          }])
          .build();
      let client = Client::with_options(options).unwrap();
  
      HttpServer::new(move || {
          App::new()
              .data(AppState {
                  db: client.database(&quot;mydb&quot;),
              })
              .service(hi)
      })
      .bind(&quot;localhost:3000&quot;)
      .unwrap()
      .run()
      .await;
  
      Ok(())
  }
  
  #[get(&quot;/hi&quot;)]
  async fn hi(state: web::Data&lt;AppState&gt;) -&gt; actix_web::Result&lt;HttpResponse&gt; {
      state.db.collection(&quot;mycoll&quot;).find(None, None).await;
  
      HttpResponse::Ok().await
  }
  
  struct AppState {
      db: Database,
  }
  </code></pre>
  <p>Dependencies in Cargo.toml:</p>
  <pre><code>[dependencies]
  actix-rt = &quot;1.1.1&quot;
  actix-web = &quot;2.0.0&quot;
  mongodb = &quot;1.1.0&quot;
  </code></pre>
  <p>The only thing that changed between the last CI build that succeeded and the first one that started failing was adding an endpoint to the server (which was essentially a copy/paste of an existing one), and a minor version bump on the time crate (indirect dependency). Checking out the last working commit and attempting to build that doesn't work.</p>
  <p>If I remove the <code>await</code> on the <code>find()</code> call it will compile on Linux, but it will also compile if I put that <code>find</code> call (with the <code>await</code>) in a non-Actix <code>async fn</code>.</p>
  <p>It also works if I use the <code>sync</code> feature of mongo, which wouldn't be ideal.</p>
  <p>Downgrading to Rust 1.45 allows it to compile, so apparently something in the 1.46 release broke the actix or mongo crates in some way.</p>
  <p>Because this code works on macOS, and worked on Linux last week, I'm assuming there is not a fundamental issue with using Mongo in an Actix-web route handler like this. Am I missing something?</p>