<div class="highlight highlight-source-rust notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="trait Bar&lt;T&gt; { fn dummy(&amp;self); }
trait Car&lt;T&gt; { fn dummy(&amp;self); }

trait Foo {
    type A;
    type B: Bar&lt;Self::A&gt;;
    type C: Car&lt;Self::A&gt;;

    fn get_b(&amp;self) -&gt; &amp;Self::B;
}

fn test_bar&lt;A, B: Bar&lt;A&gt;&gt;(_: &amp;B) {}

fn test&lt;A, F: Foo&lt;A=A&gt;&gt;(f: &amp;F) {
    test_bar(f.get_b());
}"><pre class="notranslate"><span class="pl-k">trait</span> <span class="pl-smi">Bar</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">dummy</span><span class="pl-kos">(</span><span class="pl-c1">&amp;</span><span class="pl-smi">self</span><span class="pl-kos">)</span><span class="pl-kos">;</span> <span class="pl-kos">}</span>
<span class="pl-k">trait</span> <span class="pl-smi">Car</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">dummy</span><span class="pl-kos">(</span><span class="pl-c1">&amp;</span><span class="pl-smi">self</span><span class="pl-kos">)</span><span class="pl-kos">;</span> <span class="pl-kos">}</span>

<span class="pl-k">trait</span> <span class="pl-smi">Foo</span> <span class="pl-kos">{</span>
    <span class="pl-k">type</span> <span class="pl-smi">A</span><span class="pl-kos">;</span>
    <span class="pl-k">type</span> <span class="pl-smi">B</span><span class="pl-kos">:</span> <span class="pl-smi">Bar</span><span class="pl-kos">&lt;</span><span class="pl-smi">Self</span><span class="pl-kos">::</span><span class="pl-smi">A</span><span class="pl-kos">&gt;</span><span class="pl-kos">;</span>
    <span class="pl-k">type</span> <span class="pl-smi">C</span><span class="pl-kos">:</span> <span class="pl-smi">Car</span><span class="pl-kos">&lt;</span><span class="pl-smi">Self</span><span class="pl-kos">::</span><span class="pl-smi">A</span><span class="pl-kos">&gt;</span><span class="pl-kos">;</span>

    <span class="pl-k">fn</span> <span class="pl-en">get_b</span><span class="pl-kos">(</span><span class="pl-c1">&amp;</span><span class="pl-smi">self</span><span class="pl-kos">)</span> -&gt; <span class="pl-c1">&amp;</span><span class="pl-smi">Self</span><span class="pl-kos">::</span><span class="pl-smi">B</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>

<span class="pl-k">fn</span> <span class="pl-en">test_bar</span><span class="pl-kos">&lt;</span><span class="pl-smi">A</span><span class="pl-kos">,</span> <span class="pl-smi">B</span><span class="pl-kos">:</span> <span class="pl-smi">Bar</span><span class="pl-kos">&lt;</span><span class="pl-smi">A</span><span class="pl-kos">&gt;</span><span class="pl-kos">&gt;</span><span class="pl-kos">(</span>_<span class="pl-kos">:</span> <span class="pl-c1">&amp;</span><span class="pl-smi">B</span><span class="pl-kos">)</span> <span class="pl-kos">{</span><span class="pl-kos">}</span>

<span class="pl-k">fn</span> <span class="pl-en">test</span><span class="pl-kos">&lt;</span><span class="pl-smi">A</span><span class="pl-kos">,</span> <span class="pl-smi">F</span><span class="pl-kos">:</span> <span class="pl-smi">Foo</span><span class="pl-kos">&lt;</span><span class="pl-smi">A</span>=<span class="pl-smi">A</span><span class="pl-kos">&gt;</span><span class="pl-kos">&gt;</span><span class="pl-kos">(</span><span class="pl-s1">f</span><span class="pl-kos">:</span> <span class="pl-c1">&amp;</span><span class="pl-smi">F</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-en">test_bar</span><span class="pl-kos">(</span>f<span class="pl-kos">.</span><span class="pl-en">get_b</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">Gives me:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&lt;anon&gt;:15:16: 15:23 error: the trait `Bar&lt;A&gt;` is not implemented for the type `&lt;F as Foo&gt;::B` [E0277]
&lt;anon&gt;:15     test_bar(f.get_b());
                         ^~~~~~~
&lt;anon&gt;:15:16: 15:23 error: the trait `Car&lt;A&gt;` is not implemented for the type `&lt;F as Foo&gt;::C` [E0277]
&lt;anon&gt;:15     test_bar(f.get_b());
                         ^~~~~~~
error: aborting due to 2 previous errors
playpen: application terminated with error code 101"><pre class="notranslate"><code class="notranslate">&lt;anon&gt;:15:16: 15:23 error: the trait `Bar&lt;A&gt;` is not implemented for the type `&lt;F as Foo&gt;::B` [E0277]
&lt;anon&gt;:15     test_bar(f.get_b());
                         ^~~~~~~
&lt;anon&gt;:15:16: 15:23 error: the trait `Car&lt;A&gt;` is not implemented for the type `&lt;F as Foo&gt;::C` [E0277]
&lt;anon&gt;:15     test_bar(f.get_b());
                         ^~~~~~~
error: aborting due to 2 previous errors
playpen: application terminated with error code 101
</code></pre></div>
<p dir="auto">There is a workaround:</p>
<div class="highlight highlight-source-rust notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="fn test&lt;A, B: Bar&lt;A&gt;, C: Car&lt;A&gt;, F: Foo&lt;A=A, B=B, C=C&gt;&gt;(f: &amp;F) {
    test_bar(f.get_b());
}"><pre class="notranslate"><span class="pl-k">fn</span> <span class="pl-en">test</span><span class="pl-kos">&lt;</span><span class="pl-smi">A</span><span class="pl-kos">,</span> <span class="pl-smi">B</span><span class="pl-kos">:</span> <span class="pl-smi">Bar</span><span class="pl-kos">&lt;</span><span class="pl-smi">A</span><span class="pl-kos">&gt;</span><span class="pl-kos">,</span> <span class="pl-smi">C</span><span class="pl-kos">:</span> <span class="pl-smi">Car</span><span class="pl-kos">&lt;</span><span class="pl-smi">A</span><span class="pl-kos">&gt;</span><span class="pl-kos">,</span> <span class="pl-smi">F</span><span class="pl-kos">:</span> <span class="pl-smi">Foo</span><span class="pl-kos">&lt;</span><span class="pl-smi">A</span>=<span class="pl-smi">A</span><span class="pl-kos">,</span> <span class="pl-smi">B</span>=<span class="pl-smi">B</span><span class="pl-kos">,</span> <span class="pl-smi">C</span>=<span class="pl-smi">C</span><span class="pl-kos">&gt;</span><span class="pl-kos">&gt;</span><span class="pl-kos">(</span><span class="pl-s1">f</span><span class="pl-kos">:</span> <span class="pl-c1">&amp;</span><span class="pl-smi">F</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-en">test_bar</span><span class="pl-kos">(</span>f<span class="pl-kos">.</span><span class="pl-en">get_b</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">But it's ugly and should not be necessary.</p>
<p dir="auto">We hit this problem a lot with <a href="https://github.com/gfx-rs/gfx-rs/blob/68298c260b8d420c9c1cfc8657c87462a84476a6/src/device/mod.rs#L233">gfx::Device</a>, and I'd like to see cleaner use of it without explicit <code class="notranslate">CommandBuffer</code> bounds that we use as a <a href="https://github.com/PistonDevelopers/gfx-debug-draw/blob/58e6d6206a0632492723566ce018ce5a85536c35/src/text_renderer.rs#L246">workaround</a>.</p>
<p dir="auto">I've been running into a linker error <code class="notranslate">undefined reference to 'panicking::panic::h98aad983367da335F7E'</code> while trying to build with <code class="notranslate">#![no_std]</code>. While trying to debug, I ended up with some code that looked like this:</p>
<p dir="auto"><a href="https://gist.github.com/anonymous/88c01ee6ee33e4bad656">https://gist.github.com/anonymous/88c01ee6ee33e4bad656</a></p>
<p dir="auto">When you try to compile, it fails saying that "panic" is a duplicate definition. This makes sense because it's defined in <code class="notranslate">libcore</code>, but the error explanation suggests that this <em>is</em> possible, and the correct way to to do it is to use <code class="notranslate">#![no_std]</code>, which I'm already doing.</p>
<p dir="auto">Seems like either a problem with the library or with the error explanation?</p>