title: Rust cannot infer type without annotation
body: <p>The code below cannot compile due to the type error <code>error[E0283]: type annotations required: cannot resolve _: std::cmp::Eq</code>. What type annotation is needed in order to compile this code?</p>
  
  <p>This example code is taken from a much larger program where <code>MyHashGenerator::hash_node()</code> is used to hash nodes in an AST (the type <code>T</code> relates to a value that is held inside AST nodes, but the definition of the AST is not needed to reproduce the type error).  </p>
  
  <pre><code>use std::hash::Hash;
  
  pub trait HashGenerator&lt;T: Clone + Eq + Hash + ToString&gt; {
      fn hash(&amp;self, msg: &amp;str) -&gt; u64;  // Hash a string.
      fn hash_node(&amp;self) -&gt; u64;  // Hash an AST node.
  }
  
  struct MyHashGenerator {}
  
  impl&lt;T: Clone + Eq + Hash + ToString&gt; HashGenerator&lt;T&gt; for MyHashGenerator {
      fn hash(&amp;self, msg: &amp;str) -&gt; u64 {
          0
      }
  
      fn hash_node(&amp;self) -&gt; u64 {
          // error[E0283]: type annotations required: cannot resolve `_: std::cmp::Eq`
          self.hash("")
      }
  }
  </code></pre>
  
  <p><a href="https://play.rust-lang.org/?gist=6859b1d018ce301d87c2207f69397b3b&amp;version=nightly" rel="nofollow noreferrer">Code on Playground.</a></p>
  
  <p>This question is similar to <a href="https://stackoverflow.com/questions/39104236/how-to-resolve-type-annotations-required-cannot-resolve-when-calling-generi">the one here</a>, which has not been answered. </p>