<p dir="auto">The following code</p>
<div class="highlight highlight-source-rust notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="struct Struct([u8]);


fn as_slice(s: &amp;Struct) -&gt; &amp;[u8] {
    let &amp;Struct(ref this) = s;
    this
} 

fn main() { }"><pre class="notranslate"><span class="pl-k">struct</span> <span class="pl-smi">Struct</span><span class="pl-kos">(</span><span class="pl-kos">[</span><span class="pl-smi">u8</span><span class="pl-kos">]</span><span class="pl-kos">)</span><span class="pl-kos">;</span>


<span class="pl-k">fn</span> <span class="pl-en">as_slice</span><span class="pl-kos">(</span><span class="pl-s1">s</span><span class="pl-kos">:</span> <span class="pl-c1">&amp;</span><span class="pl-smi">Struct</span><span class="pl-kos">)</span> -&gt; <span class="pl-c1">&amp;</span><span class="pl-kos">[</span><span class="pl-smi">u8</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-v">Struct</span><span class="pl-kos">(</span><span class="pl-k">ref</span> this<span class="pl-kos">)</span> = s<span class="pl-kos">;</span>
    this
<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>
<p dir="auto">fails to compile, the error message is:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Assertion failed: (Ty &amp;&amp; &quot;Invalid GetElementPtrInst indices for type!&quot;), function checkGEPType, file /Users/rustbuild/src/rust-buildbot/slave/nightly-mac/build/src/llvm/include/llvm/IR/Instructions.h, line 782.
Abort trap: 6"><pre class="notranslate"><code class="notranslate">Assertion failed: (Ty &amp;&amp; "Invalid GetElementPtrInst indices for type!"), function checkGEPType, file /Users/rustbuild/src/rust-buildbot/slave/nightly-mac/build/src/llvm/include/llvm/IR/Instructions.h, line 782.
Abort trap: 6
</code></pre></div>
<p dir="auto">Trying to build this:</p>
<div class="highlight highlight-source-rust notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="struct Foo(pub str);

impl Foo {
  fn print(&amp;self) {
    match self {
      &amp;Foo(ref s)  =&gt; println!(&quot;f\&quot;{}\&quot;&quot;, s),
    }
  }
}

fn main() {}"><pre class="notranslate"><span class="pl-k">struct</span> <span class="pl-smi">Foo</span><span class="pl-kos">(</span><span class="pl-k">pub</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">Foo</span> <span class="pl-kos">{</span>
  <span class="pl-k">fn</span> <span class="pl-en">print</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">match</span> <span class="pl-smi">self</span> <span class="pl-kos">{</span>
      <span class="pl-c1">&amp;</span><span class="pl-v">Foo</span><span class="pl-kos">(</span><span class="pl-k">ref</span> s<span class="pl-kos">)</span>  =&gt; <span class="pl-en">println</span><span class="pl-en">!</span><span class="pl-kos">(</span><span class="pl-s">"f<span class="pl-cce">\"</span>{}<span class="pl-cce">\"</span>"</span>, s<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>

<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>
<p dir="auto">and I get this:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="rustc: /home/shum/src/rust/rust/src/llvm/include/llvm/Support/Casting.h:237: typename llvm::cast_retty&lt;X, Y*&gt;::ret_type llvm::cast(Y*) [with X = llvm::PointerType; Y = const llvm::Type; typename llvm::cast_retty&lt;X, Y*&gt;::ret_type = const llvm::PointerType*]: Assertion `isa&lt;X&gt;(Val) &amp;&amp; &quot;cast&lt;Ty&gt;() argument of incompatible type!&quot;' failed."><pre class="notranslate"><code class="notranslate">rustc: /home/shum/src/rust/rust/src/llvm/include/llvm/Support/Casting.h:237: typename llvm::cast_retty&lt;X, Y*&gt;::ret_type llvm::cast(Y*) [with X = llvm::PointerType; Y = const llvm::Type; typename llvm::cast_retty&lt;X, Y*&gt;::ret_type = const llvm::PointerType*]: Assertion `isa&lt;X&gt;(Val) &amp;&amp; "cast&lt;Ty&gt;() argument of incompatible type!"' failed.
</code></pre></div>