<p dir="auto"><code class="notranslate">#[derive(Default)]</code> fails on objects that contain a field of an associated type, even if that field is Default.</p>
<p dir="auto">For example (also <a href="https://gist.github.com/4c85bcab2cf9f8c56dc2">https://gist.github.com/4c85bcab2cf9f8c56dc2</a>):</p>
<div class="highlight highlight-source-rust notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="trait TR {
  type Assoc : Clone + Copy + Default;
}

#[derive(Clone, Copy, Default)]
struct Foo&lt;T: TR&gt; {
  thing : T::Assoc,
}

impl &lt;T: TR&gt; Foo&lt;T&gt; {
    fn bar() {
        // This works
        let _ : T::Assoc = Default::default();
        // This does not.
        let _ : Foo&lt;T&gt; = Default::default();
    }
}"><pre class="notranslate"><span class="pl-k">trait</span> <span class="pl-smi">TR</span> <span class="pl-kos">{</span>
  <span class="pl-k">type</span> <span class="pl-smi">Assoc</span> <span class="pl-kos">:</span> <span class="pl-smi">Clone</span> + <span class="pl-smi">Copy</span> + <span class="pl-smi">Default</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>

<span class="pl-c1">#<span class="pl-kos">[</span>derive<span class="pl-kos">(</span><span class="pl-v">Clone</span><span class="pl-kos">,</span> <span class="pl-v">Copy</span><span class="pl-kos">,</span> <span class="pl-v">Default</span><span class="pl-kos">)</span><span class="pl-kos">]</span></span>
<span class="pl-k">struct</span> <span class="pl-smi">Foo</span><span class="pl-kos">&lt;</span><span class="pl-smi">T</span><span class="pl-kos">:</span> <span class="pl-smi">TR</span><span class="pl-kos">&gt;</span> <span class="pl-kos">{</span>
  <span class="pl-c1">thing</span> <span class="pl-kos">:</span> <span class="pl-smi">T</span><span class="pl-kos">::</span><span class="pl-smi">Assoc</span><span class="pl-kos">,</span>
<span class="pl-kos">}</span>

<span class="pl-k">impl</span> <span class="pl-kos">&lt;</span><span class="pl-smi">T</span><span class="pl-kos">:</span> <span class="pl-smi">TR</span><span class="pl-kos">&gt;</span> <span class="pl-smi">Foo</span><span class="pl-kos">&lt;</span><span class="pl-smi">T</span><span class="pl-kos">&gt;</span> <span class="pl-kos">{</span>
    <span class="pl-k">fn</span> <span class="pl-en">bar</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
        <span class="pl-c">// This works</span>
        <span class="pl-k">let</span> _ <span class="pl-kos">:</span> <span class="pl-smi">T</span><span class="pl-kos">::</span><span class="pl-smi">Assoc</span> = <span class="pl-smi">Default</span><span class="pl-kos">::</span><span class="pl-en">default</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
        <span class="pl-c">// This does not.</span>
        <span class="pl-k">let</span> _ <span class="pl-kos">:</span> <span class="pl-smi">Foo</span><span class="pl-kos">&lt;</span><span class="pl-smi">T</span><span class="pl-kos">&gt;</span> = <span class="pl-smi">Default</span><span class="pl-kos">::</span><span class="pl-en">default</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-kos">}</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto">This fails with "error: the trait <code class="notranslate">core::default::Default</code> is not implemented for the type <code class="notranslate">T</code> [E0277]". Except that we don't <em>want</em> a default T, we want a default Node.</p>
<p dir="auto">Manually implementing Default works as a workaround:</p>
<div class="highlight highlight-source-rust notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="impl&lt;T: TR&gt; Default for Foo&lt;T&gt; {
    fn default() -&gt; Self { Foo { thing : Default::default() } }
}"><pre class="notranslate"><span class="pl-k">impl</span><span class="pl-kos">&lt;</span><span class="pl-smi">T</span><span class="pl-kos">:</span> <span class="pl-smi">TR</span><span class="pl-kos">&gt;</span> <span class="pl-smi">Default</span> <span class="pl-k">for</span> <span class="pl-smi">Foo</span><span class="pl-kos">&lt;</span><span class="pl-smi">T</span><span class="pl-kos">&gt;</span> <span class="pl-kos">{</span>
    <span class="pl-k">fn</span> <span class="pl-en">default</span><span class="pl-kos">(</span><span class="pl-kos">)</span> -&gt; <span class="pl-smi">Self</span> <span class="pl-kos">{</span> <span class="pl-smi">Foo</span> <span class="pl-kos">{</span> <span class="pl-c1">thing</span> <span class="pl-kos">:</span> <span class="pl-smi">Default</span><span class="pl-kos">::</span><span class="pl-en">default</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">}</span> <span class="pl-kos">}</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto">Happens in 1.3, beta, and nightly as of Sep. 20.</p>
<p dir="auto">In the following code:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="#[derive(Copy, Clone)]
struct Y&lt;T&gt;(&amp;'static fn(T));"><pre class="notranslate"><code class="notranslate">#[derive(Copy, Clone)]
struct Y&lt;T&gt;(&amp;'static fn(T));
</code></pre></div>
<p dir="auto">both derives expand to impls that require the corresponding trait to be implemented on the type parameter, e.g.:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="#[automatically_derived]
impl &lt;T: ::std::marker::Copy&gt; ::std::marker::Copy for Y&lt;T&gt; where
 T: ::std::marker::Copy {
}"><pre class="notranslate"><code class="notranslate">#[automatically_derived]
impl &lt;T: ::std::marker::Copy&gt; ::std::marker::Copy for Y&lt;T&gt; where
 T: ::std::marker::Copy {
}
</code></pre></div>
<p dir="auto">However, this isn't actually necessary, as <code class="notranslate">Y&lt;T&gt;</code> will still be eligible for <code class="notranslate">Copy</code> regardless of whether <code class="notranslate">T</code> is.</p>
<p dir="auto">This may be hard to fix, given the compilation phase at which <code class="notranslate">#[derive]</code> works...</p>