<p dir="auto">Consider the <a href="http://is.gd/TOrGVM" rel="nofollow">following example</a>:</p>
<div class="highlight highlight-source-rust notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="trait Foo {
    fn foo(&amp;self);
    fn bar(&amp;self) where Self: Bar;
}

trait Bar {
}

struct Baz;

impl Foo for Baz {
    fn foo(&amp;self) {}
}"><pre class="notranslate"><span class="pl-k">trait</span> <span class="pl-smi">Foo</span> <span class="pl-kos">{</span>
    <span class="pl-k">fn</span> <span class="pl-en">foo</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-k">fn</span> <span class="pl-en">bar</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-k">where</span> <span class="pl-smi">Self</span><span class="pl-kos">:</span> <span class="pl-smi">Bar</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>

<span class="pl-k">trait</span> <span class="pl-smi">Bar</span> <span class="pl-kos">{</span>
<span class="pl-kos">}</span>

<span class="pl-k">struct</span> <span class="pl-smi">Baz</span><span class="pl-kos">;</span>

<span class="pl-k">impl</span> <span class="pl-smi">Foo</span> <span class="pl-k">for</span> <span class="pl-smi">Baz</span> <span class="pl-kos">{</span>
    <span class="pl-k">fn</span> <span class="pl-en">foo</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-kos">}</span></pre></div>
<p dir="auto">The example produces the following error:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&lt;anon&gt;:11:1: 13:2 error: not all trait items implemented, missing: `bar` [E0046]
&lt;anon&gt;:11 impl Foo for Baz {
&lt;anon&gt;:12     fn foo(&amp;self) {}
&lt;anon&gt;:13 }"><pre class="notranslate"><code class="notranslate">&lt;anon&gt;:11:1: 13:2 error: not all trait items implemented, missing: `bar` [E0046]
&lt;anon&gt;:11 impl Foo for Baz {
&lt;anon&gt;:12     fn foo(&amp;self) {}
&lt;anon&gt;:13 }
</code></pre></div>
<p dir="auto">However, <code class="notranslate">Baz</code> doesn’t implement <code class="notranslate">Bar</code>, and presumably it shouldn’t be required to implement <code class="notranslate">bar</code> when implementing <code class="notranslate">Foo</code>.</p>
<p dir="auto">Regards,<br>
Ivan</p>
<p dir="auto">There is a curious case with where clauses where sometimes we can show that a method in an impl could not possibly be called. This is because the impl has more precise information than the trait. Here is an example:</p>
<div class="highlight highlight-source-rust notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="    trait MyTrait&lt;T&gt; {
        fn method(&amp;self, t: &amp;T) where T : Eq;
    }

    struct Foo;
    struct Bar; // note that `Bar` does not derive `Eq`

    impl MyTrait&lt;Bar&gt; for Foo {
        fn method(&amp;self, t: &amp;T) where Bar : Eq { // &lt;-- `Bar : Eq` cannot be satisfied!
        }
    }"><pre class="notranslate">    <span class="pl-k">trait</span> <span class="pl-smi">MyTrait</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">method</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-s1">t</span><span class="pl-kos">:</span> <span class="pl-c1">&amp;</span><span class="pl-smi">T</span><span class="pl-kos">)</span> <span class="pl-k">where</span> <span class="pl-smi">T</span> <span class="pl-kos">:</span> <span class="pl-smi">Eq</span><span class="pl-kos">;</span>
    <span class="pl-kos">}</span>

    <span class="pl-k">struct</span> <span class="pl-smi">Foo</span><span class="pl-kos">;</span>
    <span class="pl-k">struct</span> <span class="pl-smi">Bar</span><span class="pl-kos">;</span> <span class="pl-c">// note that `Bar` does not derive `Eq`</span>

    <span class="pl-k">impl</span> <span class="pl-smi">MyTrait</span><span class="pl-kos">&lt;</span><span class="pl-smi">Bar</span><span class="pl-kos">&gt;</span> <span class="pl-k">for</span> <span class="pl-smi">Foo</span> <span class="pl-kos">{</span>
        <span class="pl-k">fn</span> <span class="pl-en">method</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-s1">t</span><span class="pl-kos">:</span> <span class="pl-c1">&amp;</span><span class="pl-smi">T</span><span class="pl-kos">)</span> <span class="pl-k">where</span> <span class="pl-smi">Bar</span> <span class="pl-kos">:</span> <span class="pl-smi">Eq</span> <span class="pl-kos">{</span> <span class="pl-c">// &lt;-- `Bar : Eq` cannot be satisfied!</span>
        <span class="pl-kos">}</span>
    <span class="pl-kos">}</span></pre></div>
<p dir="auto">We should permit the method body to be omitted in such a case. As a workaround, once <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="52468766" data-permission-text="Title is private" data-url="https://github.com/rust-lang/rust/issues/20020" data-hovercard-type="issue" data-hovercard-url="/rust-lang/rust/issues/20020/hovercard" href="https://github.com/rust-lang/rust/issues/20020">#20020</a> is fixed, I imagine it would be possible to write an impl like this:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="impl MyTrait&lt;Bar&gt; for Foo {
    fn method(&amp;self, t: &amp;T) { // no where clause at all
        panic!(&quot;Bar : Eq could not be satisfied&quot;);
    }
}"><pre class="notranslate"><code class="notranslate">impl MyTrait&lt;Bar&gt; for Foo {
    fn method(&amp;self, t: &amp;T) { // no where clause at all
        panic!("Bar : Eq could not be satisfied");
    }
}
</code></pre></div>
<p dir="auto">However, it is unfortunate to require that of the user. For one thing, perhaps it happens later that an impl of <code class="notranslate">Eq</code> is added for <code class="notranslate">Bar</code> -- now we have this method hanging around that will panic. It'd be nice to detect that statically.</p>
<p dir="auto">The plan then would be to permit:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="impl MyTrait&lt;Bar&gt; for Foo {
    fn method(&amp;self, t: &amp;T); // &lt;-- no body or where clauses needed
}"><pre class="notranslate"><code class="notranslate">impl MyTrait&lt;Bar&gt; for Foo {
    fn method(&amp;self, t: &amp;T); // &lt;-- no body or where clauses needed
}
</code></pre></div>
<p dir="auto">This serves as a declaration that you believe this method could never be called. At trans time, we will generate a body that simply does the equivalent of <code class="notranslate">panic!("unsatisfiable method</code>method<code class="notranslate">invoked")</code>.</p>
<p dir="auto">I plan to open an amendment to the where clause RFC describing this particular case.</p>