<p dir="auto">Currently this code compiles, but it shouldn't:</p>
<div class="highlight highlight-source-rust notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="trait MyMul&lt;RHS, Res&gt;
{
    fn mul(&amp;self, rhs: &amp;RHS) -&gt; Res;
}

fn foo&lt;T: MyMul&lt;f64, f64&gt;&gt;(a: &amp;T, b: f64) -&gt; f64
{
    a * b
}

fn main()
{

}"><pre class="notranslate"><span class="pl-k">trait</span> <span class="pl-smi">MyMul</span><span class="pl-kos">&lt;</span><span class="pl-smi">RHS</span><span class="pl-kos">,</span> <span class="pl-smi">Res</span><span class="pl-kos">&gt;</span>
<span class="pl-kos">{</span>
    <span class="pl-k">fn</span> <span class="pl-en">mul</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">rhs</span><span class="pl-kos">:</span> <span class="pl-c1">&amp;</span><span class="pl-smi">RHS</span><span class="pl-kos">)</span> -&gt; <span class="pl-smi">Res</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>

<span class="pl-k">fn</span> <span class="pl-en">foo</span><span class="pl-kos">&lt;</span><span class="pl-smi">T</span><span class="pl-kos">:</span> <span class="pl-smi">MyMul</span><span class="pl-kos">&lt;</span><span class="pl-smi">f64</span><span class="pl-kos">,</span> <span class="pl-smi">f64</span><span class="pl-kos">&gt;</span><span class="pl-kos">&gt;</span><span class="pl-kos">(</span><span class="pl-s1">a</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-s1">b</span><span class="pl-kos">:</span> <span class="pl-smi">f64</span><span class="pl-kos">)</span> -&gt; <span class="pl-smi">f64</span>
<span class="pl-kos">{</span>
    a <span class="pl-c1">*</span> b
<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-kos">}</span></pre></div>
<div class="highlight highlight-source-rust notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="use t::T;
mod t {
    pub trait T {}
}

struct S;

impl T for S {}

impl T {} // oops

fn main() {}"><pre class="notranslate"><span class="pl-k">use</span> t<span class="pl-kos">::</span><span class="pl-v">T</span><span class="pl-kos">;</span>
<span class="pl-k">mod</span> t <span class="pl-kos">{</span>
    <span class="pl-k">pub</span> <span class="pl-k">trait</span> <span class="pl-smi">T</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">S</span><span class="pl-kos">;</span>

<span class="pl-k">impl</span> <span class="pl-smi">T</span> <span class="pl-k">for</span> <span class="pl-smi">S</span> <span class="pl-kos">{</span><span class="pl-kos">}</span>

<span class="pl-k">impl</span> <span class="pl-smi">T</span> <span class="pl-kos">{</span><span class="pl-kos">}</span> <span class="pl-c">// oops</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-kos">}</span></pre></div>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="a.rs:8:5: 8:6 error: T is not a trait
a.rs:8 impl T for S {}
            ^"><pre class="notranslate"><code class="notranslate">a.rs:8:5: 8:6 error: T is not a trait
a.rs:8 impl T for S {}
            ^
</code></pre></div>
<p dir="auto">This should show better error message. If <code class="notranslate">trait T</code> is not in mod, rustc prints "duplicate definition of module <code class="notranslate">T</code>".</p>