title: expected type parameter, found struct
body: <p>I've encountered a problem which I reduced to the following code:</p>
  
  <pre><code>trait Logger {}
  
  struct DefaultLogger;
  
  impl Logger for DefaultLogger {}
  
  struct A&lt;L&gt; where L: Logger {
      logger: Box&lt;L&gt;,
  }
  
  impl&lt;L&gt; A&lt;L&gt; where L: Logger {
      fn new() -&gt; Self {
          let logger = DefaultLogger;
  
          A {
              logger: Box::new(logger),
                            // ^^^^^^ Here is the problem
          }
      }
  }
  
  fn main() {
      let a = A::new();
  }
  </code></pre>
  
  <p>which produces the following error:</p>
  
  <pre class="lang-none prettyprint-override"><code>error[E0308]: mismatched types
    --&gt; src/main.rs:16:30
     |
  16 |             logger: Box::new(logger),
     |                              ^^^^^^ expected type parameter, found struct `DefaultLogger`
     |
     = note: expected type `L`
                found type `DefaultLogger`
  </code></pre>
  
  <p>When I construct trait <code>A</code> in a normal function (like <code>main</code>), like I expected it to work. Example:</p>
  
  <pre><code>trait Logger {}
  
  struct DefaultLogger;
  
  impl Logger for DefaultLogger {}
  
  struct A&lt;L&gt; where L: Logger {
      logger: Box&lt;L&gt;,
  }
  
  fn main() {
          let logger = DefaultLogger;
  
          let _a = A {
              logger: Box::new(logger),
          };
  }
  </code></pre>