title: Compiler warns about unused code for private functions that are actually used
body: <p>I started grouping code for one of my projects into module files. I encountered a lot of warnings about unused code for functions in those modules, but the functions are actually used (privately within the module).</p>
  
  <p>An example from <a href="https://github.com/kodecheck/kodecheck/blob/master/lib-spellcheck/src/spellcheck/corrections.rs#L46" rel="nofollow noreferrer">my project</a>:</p>
  
  <pre><code>// ...
  
  // Line 46:
  
  fn calc_p(word: &amp;str, dict: &amp;Dictionary) -&gt; f32
  {
      if !dict.contains_key(word) {
          return 0.0;
      }
  
      let total: u32 = dict.values().sum();
      dict[word] as f32 / total as f32
  }
  
  ...
  </code></pre>
  
  <p>But <a href="https://github.com/kodecheck/kodecheck/blob/master/lib-spellcheck/src/spellcheck/corrections.rs#L13" rel="nofollow noreferrer">at line 13 in the same file</a>, same module the function is clearly used:</p>
  
  <pre><code>// ...
  
  pub fn suggest_corrections(to_be_corrected: &amp;str, dict: &amp;Dictionary) -&gt; Vec&lt;(f32, String)&gt;
  {
      let candidates = create_candidates(to_be_corrected, dict);
  
      let mut weighted_candidates = candidates
          .into_iter()
          .map(|w| (calc_p(&amp;w, dict), w)) // Line 13 - calc_p used here
          .collect::&lt;Vec&lt;_&gt;&gt;();
  
      weighted_candidates.sort_by(|a, b| b.partial_cmp(a).unwrap());
  
      weighted_candidates
  }
  
  // ...
  </code></pre>
  
  <p>Yet I get the compiler warning:</p>
  
  <pre class="lang-none prettyprint-override"><code>warning: function is never used: `calc_p`, #[warn(dead_code)] on by default
    --&gt; src/spellcheck/corrections.rs:46:1
     |
  46 |   fn calc_p(word: &amp;str, dict: &amp;Dictionary) -&gt; f32
     |  _^ starting here...
  47 | | {
  48 | |     if !dict.contains_key(word) {
  49 | |         return 0.0;
  50 | |     }
  51 | |
  52 | |     let total: u32 = dict.values().sum();
  53 | |     dict[word] as f32 / total as f32
  54 | | }
     | |_^ ...ending here
  </code></pre>
  
  <p>I thought maybe it's because the module <code>corrections</code> is not public, but I also <a href="https://github.com/kodecheck/kodecheck/blob/master/lib-spellcheck/src/spellcheck/mod.rs" rel="nofollow noreferrer">marked the module as public</a> and still get the same warning.</p>
  
  <p>I tried to reproduce the behaviour using <a href="https://play.rust-lang.org/?gist=91e73fbec7c7e28337ff8279e112e873&amp;version=stable&amp;backtrace=0" rel="nofollow noreferrer">the playground</a>, but if the module is defined in the same file it seems to work. The warnings also happen for me during <a href="https://travis-ci.org/kodecheck/kodecheck/jobs/212329539" rel="nofollow noreferrer">a TravisCI build</a>.</p>
  
  <p>Why is the function marked as unused although it's actually used in the same file in the same module?</p>
  
  <p>I'm using Rust 1.15 / 1.16.</p>