<p dir="auto">Not sure on best way to describe this bug, but get llvm::StoreInst::AssertOK() exception compiling.  Too new to rust to describe expected behavior other than not llvm exception.</p>
<p dir="auto">Code example at <a href="http://is.gd/dOuQoI" rel="nofollow">http://is.gd/dOuQoI</a></p>
<p dir="auto">Produces result:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="rustc: /build/rust-git/src/rust/src/llvm/lib/IR/Instructions.cpp:1086: void llvm::StoreInst::AssertOK(): Assertion `getOperand(0)-&gt;getType() == cast&lt;PointerType&gt;(getOperand(1)-&gt;getType())-&gt;getElementType() &amp;&amp; &quot;Ptr must be a pointer to Val type!&quot;' failed.
Aborted"><pre class="notranslate"><code class="notranslate">rustc: /build/rust-git/src/rust/src/llvm/lib/IR/Instructions.cpp:1086: void llvm::StoreInst::AssertOK(): Assertion `getOperand(0)-&gt;getType() == cast&lt;PointerType&gt;(getOperand(1)-&gt;getType())-&gt;getElementType() &amp;&amp; "Ptr must be a pointer to Val type!"' failed.
Aborted
</code></pre></div>
<p dir="auto">Code duplicated below</p>
<div class="highlight highlight-source-rust notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="pub trait Color {
    fn desc(&amp;self) -&gt; &amp;str;
}

pub struct ColorImpl {
    desc: &amp;'static str,
}

impl Color for ColorImpl {
    fn desc(&amp;self) -&gt; &amp;str {
        return self.desc
    }
}

pub static RED: ColorImpl = ColorImpl{desc:&quot;red&quot;};

pub trait Suit {
    fn color(&amp;self) -&gt; &amp;Color;
    fn desc(&amp;self) -&gt; &amp;str;
}

pub struct SuitImpl {
    desc: &amp;'static str,
    c: &amp;'static ColorImpl,
}

impl Suit for SuitImpl {
    fn desc(&amp;self) -&gt; &amp;str {
        return self.desc
    }
    fn color(&amp;self) -&gt; &amp;Color {
        return self.c
    }
}

static HEART: SuitImpl = SuitImpl{desc:&quot;heart&quot;, c: &amp;RED};

fn main() {
    assert_eq!(&quot;heart&quot;, HEART.desc());
}"><pre class="notranslate"><span class="pl-k">pub</span> <span class="pl-k">trait</span> <span class="pl-smi">Color</span> <span class="pl-kos">{</span>
    <span class="pl-k">fn</span> <span class="pl-en">desc</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">str</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>

<span class="pl-k">pub</span> <span class="pl-k">struct</span> <span class="pl-smi">ColorImpl</span> <span class="pl-kos">{</span>
    <span class="pl-c1">desc</span><span class="pl-kos">:</span> <span class="pl-c1">&amp;</span><span class="pl-c1">'</span><span class="pl-ent">static</span> <span class="pl-smi">str</span><span class="pl-kos">,</span>
<span class="pl-kos">}</span>

<span class="pl-k">impl</span> <span class="pl-smi">Color</span> <span class="pl-k">for</span> <span class="pl-smi">ColorImpl</span> <span class="pl-kos">{</span>
    <span class="pl-k">fn</span> <span class="pl-en">desc</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">str</span> <span class="pl-kos">{</span>
        <span class="pl-k">return</span> <span class="pl-smi">self</span><span class="pl-kos">.</span><span class="pl-c1">desc</span>
    <span class="pl-kos">}</span>
<span class="pl-kos">}</span>

<span class="pl-k">pub</span> <span class="pl-k">static</span> <span class="pl-v">RED</span><span class="pl-kos">:</span> <span class="pl-smi">ColorImpl</span> = <span class="pl-smi">ColorImpl</span><span class="pl-kos">{</span><span class="pl-c1">desc</span><span class="pl-kos">:</span><span class="pl-s">"red"</span><span class="pl-kos">}</span><span class="pl-kos">;</span>

<span class="pl-k">pub</span> <span class="pl-k">trait</span> <span class="pl-smi">Suit</span> <span class="pl-kos">{</span>
    <span class="pl-k">fn</span> <span class="pl-en">color</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">Color</span><span class="pl-kos">;</span>
    <span class="pl-k">fn</span> <span class="pl-en">desc</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">str</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>

<span class="pl-k">pub</span> <span class="pl-k">struct</span> <span class="pl-smi">SuitImpl</span> <span class="pl-kos">{</span>
    <span class="pl-c1">desc</span><span class="pl-kos">:</span> <span class="pl-c1">&amp;</span><span class="pl-c1">'</span><span class="pl-ent">static</span> <span class="pl-smi">str</span><span class="pl-kos">,</span>
    <span class="pl-c1">c</span><span class="pl-kos">:</span> <span class="pl-c1">&amp;</span><span class="pl-c1">'</span><span class="pl-ent">static</span> <span class="pl-smi">ColorImpl</span><span class="pl-kos">,</span>
<span class="pl-kos">}</span>

<span class="pl-k">impl</span> <span class="pl-smi">Suit</span> <span class="pl-k">for</span> <span class="pl-smi">SuitImpl</span> <span class="pl-kos">{</span>
    <span class="pl-k">fn</span> <span class="pl-en">desc</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">str</span> <span class="pl-kos">{</span>
        <span class="pl-k">return</span> <span class="pl-smi">self</span><span class="pl-kos">.</span><span class="pl-c1">desc</span>
    <span class="pl-kos">}</span>
    <span class="pl-k">fn</span> <span class="pl-en">color</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">Color</span> <span class="pl-kos">{</span>
        <span class="pl-k">return</span> <span class="pl-smi">self</span><span class="pl-kos">.</span><span class="pl-c1">c</span>
    <span class="pl-kos">}</span>
<span class="pl-kos">}</span>

<span class="pl-k">static</span> <span class="pl-v">HEART</span><span class="pl-kos">:</span> <span class="pl-smi">SuitImpl</span> = <span class="pl-smi">SuitImpl</span><span class="pl-kos">{</span><span class="pl-c1">desc</span><span class="pl-kos">:</span><span class="pl-s">"heart"</span><span class="pl-kos">,</span> <span class="pl-c1">c</span><span class="pl-kos">:</span> <span class="pl-c1">&amp;</span><span class="pl-v">RED</span><span class="pl-kos">}</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-en">assert_eq</span><span class="pl-en">!</span><span class="pl-kos">(</span><span class="pl-s">"heart"</span>, <span class="pl-v">HEART</span>.desc<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">EDIT: this issue has been stalled on disagreements about how to handle a nasty problem found during implementation. <a href="https://internals.rust-lang.org/t/interaction-of-user-defined-and-integral-fallbacks-with-inference/2496" rel="nofollow">See the internals thread where this was detailed and discussed</a>.</p>
<hr>
<p dir="auto">This is a tracking issue for <a href="https://github.com/rust-lang/rfcs/blob/master/text/0213-defaulted-type-params.md">RFC 213</a>.</p>
<p dir="auto">The initial implementation of this feature has <a href="https://github.com/rust-lang/rust/pull/26870" data-hovercard-type="pull_request" data-hovercard-url="/rust-lang/rust/pull/26870/hovercard">landed</a>.</p>
<p dir="auto">cc <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/nikomatsakis/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/nikomatsakis">@nikomatsakis</a></p>