title: How *exactly* does rust look up modules?
body: <p>What is the exact set of rules that rust uses to look up a module from a file?</p>
  <p>Every explanation I have found online about modules says, &quot;this is the purpose of modules, here is an example of one, ...&quot; None give the complete, comprehensive, 100% accurate explanation for <em>how rust looks up modules</em>. Even the rust <a href="https://doc.rust-lang.org/reference/items/modules.html" rel="nofollow noreferrer">reference</a> doesn't tell you whether both the crate root and the importing file need to declare <code>mod</code>! There is no simple ruleset I can use to tell whether it will work.</p>
  <p>I'm looking for something <em>I</em> can follow, like:</p>
  <ol>
  <li>Rust looks at the name, parsing <code>::</code> like <code>subdir::subdir::name</code></li>
  <li>Rust looks to see if there is a file <code>name.rs</code> in the same directory and <code>name/mod.rs</code></li>
  <li>There is not allowed to be both a <code>name.rs</code> and a <code>name/mod.rs</code>.</li>
  <li>Then, Rust...???</li>
  </ol>