<p dir="auto">Alexander was having trouble on the mailing list doing this:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="pub trait TupleVal&lt;T&gt; {
    pub pure fn _1(&amp;self) -&gt; &amp;self/T;
}

impl &lt;T&gt;(T, T): TupleVal&lt;T&gt; {
    pure fn _1(&amp;self) -&gt; &amp;self/T {
        //match *self { (ref a, _) =&gt; a }
        let &amp;(ref a, _) = self;
        a
    }
}

fn main() {
    let pair = (1, 2);
    let left = *pair._1();
    io::println(fmt!(&quot;pair left: %u&quot;, left));
}"><pre class="notranslate"><code class="notranslate">pub trait TupleVal&lt;T&gt; {
    pub pure fn _1(&amp;self) -&gt; &amp;self/T;
}

impl &lt;T&gt;(T, T): TupleVal&lt;T&gt; {
    pure fn _1(&amp;self) -&gt; &amp;self/T {
        //match *self { (ref a, _) =&gt; a }
        let &amp;(ref a, _) = self;
        a
    }
}

fn main() {
    let pair = (1, 2);
    let left = *pair._1();
    io::println(fmt!("pair left: %u", left));
}
</code></pre></div>
<p dir="auto">This results in the following llvm error:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Assertion failed: (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;), function AssertOK, file /Users/erickt/Projects/rust/rust/src/llvm/lib/VMCore/Instructions.cpp, line 1062"><pre class="notranslate"><code class="notranslate">Assertion failed: (getOperand(0)-&gt;getType() == cast&lt;PointerType&gt;(getOperand(1)-&gt;getType())-&gt;getElementType() &amp;&amp; "Ptr must be a pointer to Val type!"), function AssertOK, file /Users/erickt/Projects/rust/rust/src/llvm/lib/VMCore/Instructions.cpp, line 1062
</code></pre></div>
<p dir="auto">If instead we use the commented out llvm form, it compiles and runs perfectly fine, so the <code class="notranslate">let</code> destructuring mechanism is probably to blame. <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/catamorphism/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/catamorphism">@catamorphism</a>: You wrote that code, right? Can you take a look at this?</p>
<p dir="auto">Also, I ran into a similar llvm assertion in <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="10567528" data-permission-text="Title is private" data-url="https://github.com/rust-lang/rust/issues/4759" data-hovercard-type="issue" data-hovercard-url="/rust-lang/rust/issues/4759/hovercard" href="https://github.com/rust-lang/rust/issues/4759">#4759</a>, so maybe it's the same bug.</p>
<p dir="auto">This program:</p>
<div class="highlight highlight-source-rust notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="fn main() {
  let &amp;(ref x, _) = &amp;(1, 1);
}"><pre class="notranslate"><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-k">let</span> <span class="pl-c1">&amp;</span><span class="pl-kos">(</span><span class="pl-k">ref</span> x<span class="pl-kos">,</span> _<span class="pl-kos">)</span> = <span class="pl-c1">&amp;</span><span class="pl-kos">(</span><span class="pl-c1">1</span><span class="pl-kos">,</span> <span class="pl-c1">1</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto">Produces the output:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ rustc --test bug3.rs
bug3.rs:2:8: 2:14 warning: unused variable: `x`
bug3.rs:2   let &amp;(ref x, _) = &amp;(1, 1);
                  ^~~~~~
Assertion failed: (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;), function AssertOK, file /Users/alex/code/rust2/src/llvm/lib/VMCore/Instructions.cpp, line 1062.
"><pre class="notranslate"><code class="notranslate">$ rustc --test bug3.rs
bug3.rs:2:8: 2:14 warning: unused variable: `x`
bug3.rs:2   let &amp;(ref x, _) = &amp;(1, 1);
                  ^~~~~~
Assertion failed: (getOperand(0)-&gt;getType() == cast&lt;PointerType&gt;(getOperand(1)-&gt;getType())-&gt;getElementType() &amp;&amp; "Ptr must be a pointer
 to Val type!"), function AssertOK, file /Users/alex/code/rust2/src/llvm/lib/VMCore/Instructions.cpp, line 1062.

</code></pre></div>