<p dir="auto">I was testing out some code I found on the mailing list, and appended some of my own:</p>
<div class="highlight highlight-source-rust notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="enum Foobar {
  Foo(~str),
  Bar(~str)
}

fn f&lt;'a&gt;(fb: &amp;'a Foobar) -&gt; &amp;'a str {
  let rs = match *fb {
    Foo(ref rs) =&gt; rs,
    Bar(ref rs) =&gt; rs
  };
  let s: &amp;'a str = *rs;
  s
}

struct Foo(int);

fn main() {
}"><pre class="notranslate"><span class="pl-k">enum</span> <span class="pl-smi">Foobar</span> <span class="pl-kos">{</span>
  <span class="pl-v">Foo</span><span class="pl-kos">(</span>~<span class="pl-smi">str</span><span class="pl-kos">)</span><span class="pl-kos">,</span>
  <span class="pl-v">Bar</span><span class="pl-kos">(</span>~<span class="pl-smi">str</span><span class="pl-kos">)</span>
<span class="pl-kos">}</span>

<span class="pl-k">fn</span> <span class="pl-en">f</span><span class="pl-kos">&lt;</span><span class="pl-c1">'</span><span class="pl-ent">a</span><span class="pl-kos">&gt;</span><span class="pl-kos">(</span><span class="pl-s1">fb</span><span class="pl-kos">:</span> <span class="pl-c1">&amp;</span><span class="pl-c1">'</span><span class="pl-ent">a</span> <span class="pl-smi">Foobar</span><span class="pl-kos">)</span> -&gt; <span class="pl-c1">&amp;</span><span class="pl-c1">'</span><span class="pl-ent">a</span> <span class="pl-smi">str</span> <span class="pl-kos">{</span>
  <span class="pl-k">let</span> rs = <span class="pl-k">match</span> <span class="pl-c1">*</span>fb <span class="pl-kos">{</span>
    <span class="pl-v">Foo</span><span class="pl-kos">(</span><span class="pl-k">ref</span> rs<span class="pl-kos">)</span> =&gt; rs<span class="pl-kos">,</span>
    <span class="pl-v">Bar</span><span class="pl-kos">(</span><span class="pl-k">ref</span> rs<span class="pl-kos">)</span> =&gt; rs
  <span class="pl-kos">}</span><span class="pl-kos">;</span>
  <span class="pl-k">let</span> s<span class="pl-kos">:</span> <span class="pl-c1">&amp;</span><span class="pl-c1">'</span><span class="pl-ent">a</span> <span class="pl-smi">str</span> = <span class="pl-c1">*</span>rs<span class="pl-kos">;</span>
  s
<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-smi">int</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">Compiling the above program (after adding <code class="notranslate">struct Foo(int);</code>) results in a compiler error. Setting the <code class="notranslate">RUST_LOG</code> flag to <code class="notranslate">rustc=1,::rt::backtrace</code> produces the following log dump:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="rust: task failed at 'non-variant in variant_def_ids', /home/zhatahet/code/rust-0.6/src/libsyntax/ast_util.rs:55
/home/zhatahet/rust/bin/../lib/librustrt.so(_ZN9rust_task13begin_failureEPKcS1_m+0x4f)[0x7f6edda7701f]
/home/zhatahet/rust/bin/../lib/librustrt.so(+0x2d921)[0x7f6edda88921]
/home/zhatahet/rust/bin/../lib/librustrt.so(upcall_fail+0x1ce)[0x7f6edda79a3e]
/home/zhatahet/rust/bin/../lib/libcore-c3ca5d77d81b46c1-0.6.so(+0x10aa2b)[0x7f6edf5c3a2b]
/home/zhatahet/rust/bin/../lib/libcore-c3ca5d77d81b46c1-0.6.so(+0x10a9d2)[0x7f6edf5c39d2]
/home/zhatahet/rust/bin/../lib/libcore-c3ca5d77d81b46c1-0.6.so(_ZN3sys12begin_unwind17_61fe198059b9e3fc3_06E+0x71)[0x7f6edf50b4a1]
/home/zhatahet/rust/bin/../lib/libsyntax-84efebcb12c867a2-0.6.so(_ZN8ast_util15variant_def_ids17_adb77598a27029ff3_06E+0x136)[0x7f6edeaa2926]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(_ZN6middle6typeck5check6_match17check_pat_variant17_4fbfcbee3eb1c2da3_06E+0x21b)[0x7f6ede0fe54b]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(_ZN6middle6typeck5check6_match9check_pat17_548e5ffb944ea5373_06E+0x3557)[0x7f6ede0f6457]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(+0x8c1ae4)[0x7f6ede57bae4]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(+0x438ee7)[0x7f6ede0f2ee7]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(_ZN6middle6typeck5check6_match11check_match17_536eb3b0eafde7b13_06E+0x22f)[0x7f6ede0ee94f]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(_ZN6middle6typeck5check23check_expr_with_unifier17_841417e8b97d6e713_06E+0x3ef1)[0x7f6ede1a8151]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(_ZN6middle6typeck5check28check_expr_coercable_to_type17_5acee3342c4cd5a23_06E+0x91)[0x7f6ede1bbfc1]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(_ZN6middle6typeck5check22check_decl_initializer17_1547d91555c977933_06E+0xb2)[0x7f6ede1cf042]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(_ZN6middle6typeck5check16check_decl_local16_ac37e3abcfdd7ff3_06E+0x5ea)[0x7f6ede1cf72a]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(+0x8c1ae4)[0x7f6ede57bae4]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(+0x5175ba)[0x7f6ede1d15ba]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(_ZN6middle6typeck5check10check_stmt17_e63c562496e2808c3_06E+0x26e)[0x7f6ede1d102e]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(+0x517791)[0x7f6ede1d1791]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(_ZN6middle6typeck5check25check_block_with_expected17_b352eb1d2e7639c03_06E+0x21e)[0x7f6ede16caae]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(_ZN6middle6typeck5check8check_fn17_20cad4a150c275a73_06E+0x1089)[0x7f6ede16b2f9]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(_ZN6middle6typeck5check13check_bare_fn14_4fc3abe889a533_06E+0x17e)[0x7f6ede169fae]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(_ZN6middle6typeck5check10check_item16_f8c9b58265752963_06E+0x43d)[0x7f6ede168ded]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(+0x4ae801)[0x7f6ede168801]
/home/zhatahet/rust/bin/../lib/libsyntax-84efebcb12c867a2-0.6.so(+0xe5154)[0x7f6edeaec154]
/home/zhatahet/rust/bin/../lib/libsyntax-84efebcb12c867a2-0.6.so(+0xe4cfa)[0x7f6edeaebcfa]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(_ZN6middle6typeck5check16check_item_types17_b41350aeb9ad50f23_06E+0x430)[0x7f6ede1685d0]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(+0x5e52a5)[0x7f6ede29f2a5]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(_ZN6middle6typeck11check_crate17_63c941d6da5d83433_06E+0x2d0)[0x7f6ede29dec0]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(_ZN6driver6driver12compile_rest17_b2b258b84b35f3533_06E+0x1218)[0x7f6ede5380d8]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(+0x8c1ae4)[0x7f6ede57bae4]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(_ZN6driver6driver12compile_upto17_12335154b455986e3_06E+0x108)[0x7f6ede53d3e8]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(+0x8c1ae4)[0x7f6ede57bae4]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(_ZN6driver6driver13compile_input15_bb29edf7a232863_06E+0xca)[0x7f6ede53d82a]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(_ZN12run_compiler17_64d52739a36d169c3_06E+0x20aa)[0x7f6ede56cf7a]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(+0x8bf5b1)[0x7f6ede5795b1]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(+0x8bbddc)[0x7f6ede575ddc]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(+0x8c1ae4)[0x7f6ede57bae4]
/home/zhatahet/rust/bin/../lib/libcore-c3ca5d77d81b46c1-0.6.so(+0xd340e)[0x7f6edf58c40e]
/home/zhatahet/rust/bin/../lib/libcore-c3ca5d77d81b46c1-0.6.so(+0x153294)[0x7f6edf60c294]
/home/zhatahet/rust/bin/../lib/librustrt.so(_Z18task_start_wrapperP10spawn_args+0x24)[0x7f6edda782b4]
error: internal compiler error: unexpected failure
note: the compiler hit an unexpected failure path. this is a bug
note: try running with RUST_LOG=rustc=1,::rt::backtrace to get further details and report the results to github.com/mozilla/rust/issues
rust: task failed at 'explicit failure', /home/zhatahet/code/rust-0.6/src/librustc/rustc.rc:357
/home/zhatahet/rust/bin/../lib/librustrt.so(_ZN9rust_task13begin_failureEPKcS1_m+0x4f)[0x7f6edda7701f]
/home/zhatahet/rust/bin/../lib/librustrt.so(+0x2d921)[0x7f6edda88921]
/home/zhatahet/rust/bin/../lib/librustrt.so(upcall_fail+0x1ce)[0x7f6edda79a3e]
/home/zhatahet/rust/bin/../lib/libcore-c3ca5d77d81b46c1-0.6.so(+0x10aa2b)[0x7f6edf5c3a2b]
/home/zhatahet/rust/bin/../lib/libcore-c3ca5d77d81b46c1-0.6.so(+0x10a9d2)[0x7f6edf5c39d2]
/home/zhatahet/rust/bin/../lib/libcore-c3ca5d77d81b46c1-0.6.so(_ZN3sys12begin_unwind17_61fe198059b9e3fc3_06E+0x71)[0x7f6edf50b4a1]
/home/zhatahet/rust/bin/../lib/libcore-c3ca5d77d81b46c1-0.6.so(+0x153294)[0x7f6edf60c294]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(_ZN7monitor17_78935df9ff9e1afa3_06E+0x1577)[0x7f6ede56f5a7]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(+0x8c1ae4)[0x7f6ede57bae4]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(_ZN4main15_c4de63b748e03d3_06E+0x7e)[0x7f6ede57b6fe]
/home/zhatahet/rust/bin/../lib/librustrt.so(_Z18task_start_wrapperP10spawn_args+0x24)[0x7f6edda782b4]
rust: domain main @0x177b3c0 root task failed"><pre class="notranslate"><code class="notranslate">rust: task failed at 'non-variant in variant_def_ids', /home/zhatahet/code/rust-0.6/src/libsyntax/ast_util.rs:55
/home/zhatahet/rust/bin/../lib/librustrt.so(_ZN9rust_task13begin_failureEPKcS1_m+0x4f)[0x7f6edda7701f]
/home/zhatahet/rust/bin/../lib/librustrt.so(+0x2d921)[0x7f6edda88921]
/home/zhatahet/rust/bin/../lib/librustrt.so(upcall_fail+0x1ce)[0x7f6edda79a3e]
/home/zhatahet/rust/bin/../lib/libcore-c3ca5d77d81b46c1-0.6.so(+0x10aa2b)[0x7f6edf5c3a2b]
/home/zhatahet/rust/bin/../lib/libcore-c3ca5d77d81b46c1-0.6.so(+0x10a9d2)[0x7f6edf5c39d2]
/home/zhatahet/rust/bin/../lib/libcore-c3ca5d77d81b46c1-0.6.so(_ZN3sys12begin_unwind17_61fe198059b9e3fc3_06E+0x71)[0x7f6edf50b4a1]
/home/zhatahet/rust/bin/../lib/libsyntax-84efebcb12c867a2-0.6.so(_ZN8ast_util15variant_def_ids17_adb77598a27029ff3_06E+0x136)[0x7f6edeaa2926]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(_ZN6middle6typeck5check6_match17check_pat_variant17_4fbfcbee3eb1c2da3_06E+0x21b)[0x7f6ede0fe54b]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(_ZN6middle6typeck5check6_match9check_pat17_548e5ffb944ea5373_06E+0x3557)[0x7f6ede0f6457]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(+0x8c1ae4)[0x7f6ede57bae4]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(+0x438ee7)[0x7f6ede0f2ee7]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(_ZN6middle6typeck5check6_match11check_match17_536eb3b0eafde7b13_06E+0x22f)[0x7f6ede0ee94f]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(_ZN6middle6typeck5check23check_expr_with_unifier17_841417e8b97d6e713_06E+0x3ef1)[0x7f6ede1a8151]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(_ZN6middle6typeck5check28check_expr_coercable_to_type17_5acee3342c4cd5a23_06E+0x91)[0x7f6ede1bbfc1]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(_ZN6middle6typeck5check22check_decl_initializer17_1547d91555c977933_06E+0xb2)[0x7f6ede1cf042]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(_ZN6middle6typeck5check16check_decl_local16_ac37e3abcfdd7ff3_06E+0x5ea)[0x7f6ede1cf72a]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(+0x8c1ae4)[0x7f6ede57bae4]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(+0x5175ba)[0x7f6ede1d15ba]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(_ZN6middle6typeck5check10check_stmt17_e63c562496e2808c3_06E+0x26e)[0x7f6ede1d102e]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(+0x517791)[0x7f6ede1d1791]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(_ZN6middle6typeck5check25check_block_with_expected17_b352eb1d2e7639c03_06E+0x21e)[0x7f6ede16caae]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(_ZN6middle6typeck5check8check_fn17_20cad4a150c275a73_06E+0x1089)[0x7f6ede16b2f9]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(_ZN6middle6typeck5check13check_bare_fn14_4fc3abe889a533_06E+0x17e)[0x7f6ede169fae]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(_ZN6middle6typeck5check10check_item16_f8c9b58265752963_06E+0x43d)[0x7f6ede168ded]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(+0x4ae801)[0x7f6ede168801]
/home/zhatahet/rust/bin/../lib/libsyntax-84efebcb12c867a2-0.6.so(+0xe5154)[0x7f6edeaec154]
/home/zhatahet/rust/bin/../lib/libsyntax-84efebcb12c867a2-0.6.so(+0xe4cfa)[0x7f6edeaebcfa]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(_ZN6middle6typeck5check16check_item_types17_b41350aeb9ad50f23_06E+0x430)[0x7f6ede1685d0]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(+0x5e52a5)[0x7f6ede29f2a5]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(_ZN6middle6typeck11check_crate17_63c941d6da5d83433_06E+0x2d0)[0x7f6ede29dec0]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(_ZN6driver6driver12compile_rest17_b2b258b84b35f3533_06E+0x1218)[0x7f6ede5380d8]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(+0x8c1ae4)[0x7f6ede57bae4]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(_ZN6driver6driver12compile_upto17_12335154b455986e3_06E+0x108)[0x7f6ede53d3e8]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(+0x8c1ae4)[0x7f6ede57bae4]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(_ZN6driver6driver13compile_input15_bb29edf7a232863_06E+0xca)[0x7f6ede53d82a]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(_ZN12run_compiler17_64d52739a36d169c3_06E+0x20aa)[0x7f6ede56cf7a]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(+0x8bf5b1)[0x7f6ede5795b1]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(+0x8bbddc)[0x7f6ede575ddc]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(+0x8c1ae4)[0x7f6ede57bae4]
/home/zhatahet/rust/bin/../lib/libcore-c3ca5d77d81b46c1-0.6.so(+0xd340e)[0x7f6edf58c40e]
/home/zhatahet/rust/bin/../lib/libcore-c3ca5d77d81b46c1-0.6.so(+0x153294)[0x7f6edf60c294]
/home/zhatahet/rust/bin/../lib/librustrt.so(_Z18task_start_wrapperP10spawn_args+0x24)[0x7f6edda782b4]
error: internal compiler error: unexpected failure
note: the compiler hit an unexpected failure path. this is a bug
note: try running with RUST_LOG=rustc=1,::rt::backtrace to get further details and report the results to github.com/mozilla/rust/issues
rust: task failed at 'explicit failure', /home/zhatahet/code/rust-0.6/src/librustc/rustc.rc:357
/home/zhatahet/rust/bin/../lib/librustrt.so(_ZN9rust_task13begin_failureEPKcS1_m+0x4f)[0x7f6edda7701f]
/home/zhatahet/rust/bin/../lib/librustrt.so(+0x2d921)[0x7f6edda88921]
/home/zhatahet/rust/bin/../lib/librustrt.so(upcall_fail+0x1ce)[0x7f6edda79a3e]
/home/zhatahet/rust/bin/../lib/libcore-c3ca5d77d81b46c1-0.6.so(+0x10aa2b)[0x7f6edf5c3a2b]
/home/zhatahet/rust/bin/../lib/libcore-c3ca5d77d81b46c1-0.6.so(+0x10a9d2)[0x7f6edf5c39d2]
/home/zhatahet/rust/bin/../lib/libcore-c3ca5d77d81b46c1-0.6.so(_ZN3sys12begin_unwind17_61fe198059b9e3fc3_06E+0x71)[0x7f6edf50b4a1]
/home/zhatahet/rust/bin/../lib/libcore-c3ca5d77d81b46c1-0.6.so(+0x153294)[0x7f6edf60c294]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(_ZN7monitor17_78935df9ff9e1afa3_06E+0x1577)[0x7f6ede56f5a7]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(+0x8c1ae4)[0x7f6ede57bae4]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(_ZN4main15_c4de63b748e03d3_06E+0x7e)[0x7f6ede57b6fe]
/home/zhatahet/rust/bin/../lib/librustrt.so(_Z18task_start_wrapperP10spawn_args+0x24)[0x7f6edda782b4]
rust: domain main @0x177b3c0 root task failed
</code></pre></div>
<p dir="auto">It would be nice if there would be some way to <code class="notranslate">std::mem::transmute</code> in functions, even with type parameters.</p>
<p dir="auto">Maybe the prototype of the <code class="notranslate">transmute</code> function could be changed to</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="fn transmute&lt;T,U:Transmutable&lt;T&gt;&gt;(x: T) -&gt; U;"><pre class="notranslate"><code class="notranslate">fn transmute&lt;T,U:Transmutable&lt;T&gt;&gt;(x: T) -&gt; U;
</code></pre></div>
<p dir="auto">where <code class="notranslate">Transmutable</code> is a compiler-implemented type, like <code class="notranslate">Send</code>, <code class="notranslate">Copy</code> or <code class="notranslate">Share</code>.</p>