title: How do I resolve the error "no module in the root" when using a module in Rust 2018?
body: <p>I'm working on a project that is utilizing some local modules in folders under <code>src/</code>. I'm currently using Rust 2018 edition and one of the major changes for that is the <a href="https://doc.rust-lang.org/edition-guide/rust-2018/module-system/path-clarity.html" rel="noreferrer">handling of imports/<code>use</code> statements</a>.</p>
  
  <p>My module code is all working correctly, but as I started to pull it together to be used for the project as a whole I started getting this error:</p>
  
  <pre class="lang-none prettyprint-override"><code>error[E0432]: unresolved import `crate::lexer`
   --&gt; src/main.rs:1:5
    |
  1 | use crate::lexer;
    |     ^^^^^^^^^^^^ no `lexer` in the root
  </code></pre>
  
  <p>Currently, my code is set up like this:</p>
  
  <pre><code>src/
   | main.rs
   | lexer/
      | mod.rs
      | lexer.rs
  </code></pre>
  
  <p><strong>lexer/lexer.rs</strong></p>
  
  <pre><code>pub fn lex_stuff() -&gt; Vec&lt;String&gt; { vec![String::new("test")] }
  </code></pre>
  
  <p><strong>lexer/mod.rs</strong></p>
  
  <pre><code>pub mod lexer;
  </code></pre>
  
  <p><strong>main.rs</strong></p>
  
  <pre><code>use crate::lexer;
  
  fn main() {
      println!("Hello, world!");
      lexer::lexer::lex_stuff();
  }
  </code></pre>
  
  <p>I've attempted to resolve this by changing the statement to <code>use lexer</code> as well as <code>use self::lexer</code> and adding <code>extern crate lexer</code> (which obviously doesn't work, but what the heck, figured I'd try it). However, none of these have worked.</p>
  
  <p>What can I do to resolve the <code>no 'lexer' in the root</code> error?</p>