<div class="highlight highlight-source-rust notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="trait TA { fn ta(&amp;self) { println!(&quot;Default TA&quot;); } }
trait TB: TA { fn tb(&amp;self) { println!(&quot;Default TB&quot;); } }

trait AutoTA: TB {}
impl&lt;T:AutoTA&gt; TA for T { fn ta(&amp;self) { println!(&quot;AutoTA&quot;); } }

struct A;
impl TB for A {}"><pre class="notranslate"><span class="pl-k">trait</span> <span class="pl-smi">TA</span> <span class="pl-kos">{</span> <span class="pl-k">fn</span> <span class="pl-en">ta</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-en">println</span><span class="pl-en">!</span><span class="pl-kos">(</span><span class="pl-s">"Default TA"</span><span class="pl-kos">)</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">TB</span><span class="pl-kos">:</span> <span class="pl-smi">TA</span> <span class="pl-kos">{</span> <span class="pl-k">fn</span> <span class="pl-en">tb</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-en">println</span><span class="pl-en">!</span><span class="pl-kos">(</span><span class="pl-s">"Default TB"</span><span class="pl-kos">)</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">AutoTA</span><span class="pl-kos">:</span> <span class="pl-smi">TB</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">AutoTA</span><span class="pl-kos">&gt;</span> <span class="pl-smi">TA</span> <span class="pl-k">for</span> <span class="pl-smi">T</span> <span class="pl-kos">{</span> <span class="pl-k">fn</span> <span class="pl-en">ta</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-en">println</span><span class="pl-en">!</span><span class="pl-kos">(</span><span class="pl-s">"AutoTA"</span><span class="pl-kos">)</span><span class="pl-kos">;</span> <span class="pl-kos">}</span> <span class="pl-kos">}</span>

<span class="pl-k">struct</span> <span class="pl-smi">A</span><span class="pl-kos">;</span>
<span class="pl-k">impl</span> <span class="pl-smi">TB</span> <span class="pl-k">for</span> <span class="pl-smi">A</span> <span class="pl-kos">{</span><span class="pl-kos">}</span></pre></div>
<p dir="auto">The above code misses impl  <code class="notranslate">TA</code> for <code class="notranslate">A</code>, but the compiler reports<br>
<code class="notranslate">error: the trait </code>AutoTA<code class="notranslate">is not implemented for the type</code>A<code class="notranslate"> [E0277]</code></p>
<p dir="auto">Even worse, when a new piece of code is added:</p>
<div class="highlight highlight-source-rust notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="trait AutoAutoTA: TB {}
impl&lt;T: AutoAutoTA&gt; AutoTA for T {}"><pre class="notranslate"><span class="pl-k">trait</span> <span class="pl-smi">AutoAutoTA</span><span class="pl-kos">:</span> <span class="pl-smi">TB</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">AutoAutoTA</span><span class="pl-kos">&gt;</span> <span class="pl-smi">AutoTA</span> <span class="pl-k">for</span> <span class="pl-smi">T</span> <span class="pl-kos">{</span><span class="pl-kos">}</span></pre></div>
<p dir="auto">the comiler reports:<br>
<code class="notranslate">error: the trait </code>AutoAutoTA<code class="notranslate">is not implemented for the type</code>A<code class="notranslate"> [E0277]</code></p>
<p dir="auto">These error messages aren't accurate. example, the last implies that the only way to fix it is to impl the AutoAutoTA.</p>
<p dir="auto">I hope the compiler just report the direct reason. it should report:<br>
<code class="notranslate">error: the trait </code>TA<code class="notranslate">is not implemented for the type</code>A<code class="notranslate"> [E0277]</code></p>
<p dir="auto">This is a more general version of <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="58024867" data-permission-text="Title is private" data-url="https://github.com/rust-lang/rust/issues/22478" data-hovercard-type="issue" data-hovercard-url="/rust-lang/rust/issues/22478/hovercard" href="https://github.com/rust-lang/rust/issues/22478">#22478</a>. (i.e. probably should be considered to supersede it)</p>
<div class="highlight highlight-source-rust notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="trait A {
    fn a(self);
}

trait B {
    fn b(self);
}

impl&lt;T: B&gt; A for T {
    fn a(self) {
        B::b(self)
    }
}

struct C;

fn main() {
    A::a(C);
}"><pre class="notranslate"><span class="pl-k">trait</span> <span class="pl-smi">A</span> <span class="pl-kos">{</span>
    <span class="pl-k">fn</span> <span class="pl-en">a</span><span class="pl-kos">(</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">B</span> <span class="pl-kos">{</span>
    <span class="pl-k">fn</span> <span class="pl-en">b</span><span class="pl-kos">(</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">impl</span><span class="pl-kos">&lt;</span><span class="pl-smi">T</span><span class="pl-kos">:</span> <span class="pl-smi">B</span><span class="pl-kos">&gt;</span> <span class="pl-smi">A</span> <span class="pl-k">for</span> <span class="pl-smi">T</span> <span class="pl-kos">{</span>
    <span class="pl-k">fn</span> <span class="pl-en">a</span><span class="pl-kos">(</span><span class="pl-smi">self</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
        <span class="pl-smi">B</span><span class="pl-kos">::</span><span class="pl-en">b</span><span class="pl-kos">(</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">struct</span> <span class="pl-smi">C</span><span class="pl-kos">;</span>

<span class="pl-k">fn</span> <span class="pl-en">main</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-smi">A</span><span class="pl-kos">::</span><span class="pl-en">a</span><span class="pl-kos">(</span><span class="pl-v">C</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto">Compiling this will result in</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="t.rs:18:5: 18:9 error: the trait `B` is not implemented for the type `C` [E0277]
t.rs:18     A::a(C);
            ^~~~
error: aborting due to previous error"><pre class="notranslate"><code class="notranslate">t.rs:18:5: 18:9 error: the trait `B` is not implemented for the type `C` [E0277]
t.rs:18     A::a(C);
            ^~~~
error: aborting due to previous error
</code></pre></div>
<p dir="auto">but <code class="notranslate">impl&lt;T: B&gt; A for T</code>, <code class="notranslate">T = C</code> and <code class="notranslate">C</code> does not implement <code class="notranslate">B</code> and therefore the impl in question should not even be taken into consideration, even if it is the only implementation of a trait.</p>