title: How can structs in separate files reference each other?
body: <p>Using structs that reference each other is common in a single file, but when I separate the structs into two files, I get an error.</p>
  
  <p><strong><code>mod_1.rs</code></strong></p>
  
  <pre><code>mod mod_2;
  use mod_2::Haha;
  
  pub struct Hehe {
      obj: Haha,
  }
  
  fn main() {
      Hehe(Haha);
  }
  </code></pre>
  
  <p><strong><code>mod_2.rs</code></strong></p>
  
  <pre><code>mod mod_1;
  use mod_1::Hehe;
  
  pub struct Haha {
      obj: Hehe,
  }
  
  fn main() {
      Haha(Hehe);
  }
  </code></pre>
  
  <p>This will produce an error. When compiling the <code>mod_1.rs</code>:</p>
  
  <pre class="lang-none prettyprint-override"><code>error: cannot declare a new module at this location
   --&gt; mod_2.rs:1:5
    |
  1 | mod mod_1;
    |     ^^^^^
    |
  note: maybe move this module `mod_2` to its own directory via `mod_2/mod.rs`
   --&gt; mod_2.rs:1:5
    |
  1 | mod mod_1;
    |     ^^^^^
  note: ... or maybe `use` the module `mod_1` instead of possibly redeclaring it
   --&gt; mod_2.rs:1:5
    |
  1 | mod mod_1;
    |     ^^^^^
  </code></pre>
  
  <p>When compiling the <code>mod_2.rs</code>:</p>
  
  <pre class="lang-none prettyprint-override"><code>error: cannot declare a new module at this location
   --&gt; mod_1.rs:1:5
    |
  1 | mod mod_2;
    |     ^^^^^
    |
  note: maybe move this module `mod_1` to its own directory via `mod_1/mod.rs`
   --&gt; mod_1.rs:1:5
    |
  1 | mod mod_2;
    |     ^^^^^
  note: ... or maybe `use` the module `mod_2` instead of possibly redeclaring it
   --&gt; mod_1.rs:1:5
    |
  1 | mod mod_2;
    |     ^^^^^
  </code></pre>
  
  <p>In <strong><code>mod_1.rs</code></strong> I use something from <strong><code>mod_2.rs</code></strong> and in <strong><code>mod_2.rs</code></strong>, I use <strong><code>mod_1.rs</code></strong>'s thing, so I'd like to find a way to get rid of the cycle reference module problem.</p>
  
  <p><a href="https://stackoverflow.com/questions/40443963/trying-to-get-rust-to-load-files">Trying to get Rust to load files</a> is a similar but different problem.</p>