<p dir="auto">I just got an ICE while working on a testcase for another issue.</p>
<div class="highlight highlight-source-rust notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="enum SomeEnum {
    Something(i8),
    SomethingElse([u8])
}

fn some_function(arg: &amp;SomeEnum) -&gt; () {
    ()
}

fn main() {
    some_function(&amp;SomeEnum::Something(1));
}"><pre class="notranslate"><span class="pl-k">enum</span> <span class="pl-smi">SomeEnum</span> <span class="pl-kos">{</span>
    <span class="pl-v">Something</span><span class="pl-kos">(</span><span class="pl-smi">i8</span><span class="pl-kos">)</span><span class="pl-kos">,</span>
    <span class="pl-v">SomethingElse</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">some_function</span><span class="pl-kos">(</span><span class="pl-s1">arg</span><span class="pl-kos">:</span> <span class="pl-c1">&amp;</span><span class="pl-smi">SomeEnum</span><span class="pl-kos">)</span> -&gt; <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-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">some_function</span><span class="pl-kos">(</span><span class="pl-c1">&amp;</span><span class="pl-smi">SomeEnum</span><span class="pl-kos">::</span><span class="pl-v">Something</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>
<span class="pl-kos">}</span></pre></div>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&lt;anon&gt;:3:5: 3:24 warning: variant is never used: `SomethingElse`, #[warn(dead_code)] on by default
&lt;anon&gt;:3     SomethingElse([u8])
             ^~~~~~~~~~~~~~~~~~~
&lt;anon&gt;:6:18: 6:21 warning: unused variable: `arg`, #[warn(unused_variables)] on by default
&lt;anon&gt;:6 fn some_function(arg: &amp;SomeEnum) -&gt; () {
                          ^~~
error: internal compiler error: unexpected panic
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'unsized_part_of_type failed even though ty is unsized', /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/librustc_trans/trans/common.rs:168


playpen: application terminated with error code 101"><pre class="notranslate"><code class="notranslate">&lt;anon&gt;:3:5: 3:24 warning: variant is never used: `SomethingElse`, #[warn(dead_code)] on by default
&lt;anon&gt;:3     SomethingElse([u8])
             ^~~~~~~~~~~~~~~~~~~
&lt;anon&gt;:6:18: 6:21 warning: unused variable: `arg`, #[warn(unused_variables)] on by default
&lt;anon&gt;:6 fn some_function(arg: &amp;SomeEnum) -&gt; () {
                          ^~~
error: internal compiler error: unexpected panic
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'unsized_part_of_type failed even though ty is unsized', /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/librustc_trans/trans/common.rs:168


playpen: application terminated with error code 101
</code></pre></div>
<p dir="auto"><a href="http://is.gd/qkbk29" rel="nofollow">http://is.gd/qkbk29</a></p>
<div class="highlight highlight-source-rust notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="enum Foo {
    Bar(int, [int]),
}

fn main() {
    // Either of these lines can cause the ICE
    let _x: &amp;(int, [int]);
    let _y: &amp;Foo;
}"><pre class="notranslate"><span class="pl-k">enum</span> <span class="pl-smi">Foo</span> <span class="pl-kos">{</span>
    <span class="pl-v">Bar</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-smi">int</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-c">// Either of these lines can cause the ICE</span>
    <span class="pl-k">let</span> _x<span class="pl-kos">:</span> <span class="pl-c1">&amp;</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-smi">int</span><span class="pl-kos">]</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-k">let</span> _y<span class="pl-kos">:</span> <span class="pl-c1">&amp;</span><span class="pl-smi">Foo</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto">Backtrace:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="   1:     0x7f2a127e8580 - rt::backtrace::imp::write::h0180e7ded76a3ff2c0q
   2:     0x7f2a127eb770 - failure::on_fail::h3f169393c89b5f90Tlr
   3:     0x7f2a12fd24f0 - unwind::begin_unwind_inner::haeb9517b5061bc86Zie
   4:     0x7f2a133ad670 - unwind::begin_unwind::h17017358962417336117
   5:     0x7f2a13803a20 - middle::ty::unsized_part_of_type::h8eae6d239e9b7af3tnG
   6:     0x7f2a138037c0 - middle::trans::type_of::type_of::type_of_unsize_info::h67819f63aa2acfb5Xh9
   7:     0x7f2a1377b050 - middle::trans::type_of::type_of::h3c89a1738d384c45Ih9
   8:     0x7f2a1377b050 - middle::trans::type_of::type_of::h3c89a1738d384c45Ih9
   9:     0x7f2a137b0860 - middle::trans::base::alloc_ty::h5485998eeb61d023mTd
  10:     0x7f2a13859870 - middle::trans::_match::mk_binding_alloca::h11628361498234501597
  11:     0x7f2a1385bdf0 - middle::trans::_match::store_local::create_dummy_locals::closure.119283
  12:     0x7f2a13681560 - middle::pat_util::pat_bindings::closure.112016
  13:     0x7f2a0ea1ccb0 - ast_util::walk_pat::hc858153057fb5965oRB
  14:     0x7f2a138205f0 - middle::trans::_match::store_local::h9195017fe21b4124A2h
  15:     0x7f2a13772d10 - middle::trans::base::init_local::h5e8a493dc2ae05b1WFd
  16:     0x7f2a13772220 - middle::trans::controlflow::trans_stmt::hf26d5cee55a6056blhY
  17:     0x7f2a13773c40 - middle::trans::controlflow::trans_block::h004dea36138a75c8wmY
  18:     0x7f2a13829560 - middle::trans::base::trans_closure::h655acfc433ac13fevye
  19:     0x7f2a13764670 - middle::trans::base::trans_fn::hf0a444fa9ff43aebiKe
  20:     0x7f2a1375f9b0 - middle::trans::base::trans_item::hda4d4160cb2b58dfi2e
  21:     0x7f2a138341f0 - middle::trans::base::trans_crate::hff0f87c98e6356c8JWf
  22:     0x7f2a13c058d0 - driver::driver::phase_4_translate_to_llvm::h8223ee9d7ab4951cpzy
  23:     0x7f2a13bfd280 - driver::driver::compile_input::hfa4fd95c9e6a2ceeQby
  24:     0x7f2a13c8f0a0 - driver::run_compiler::h32bdccca6ed9465cJIB
  25:     0x7f2a13c8efb0 - driver::main_args::closure.138206
  26:     0x7f2a13ca1240 - task::TaskBuilder&lt;S&gt;::try_future::closure.139324
  27:     0x7f2a13ca1040 - task::TaskBuilder&lt;S&gt;::spawn_internal::closure.139301
  28:     0x7f2a146dcf10 - task::spawn_opts::closure.8369
  29:     0x7f2a1302af90 - rust_try_inner
  30:     0x7f2a1302af80 - rust_try
  31:     0x7f2a12fcfb20 - unwind::try::h03d8d1d4cb0de0c1f7d
  32:     0x7f2a12fcf8e0 - task::Task::run::hafab6bcab45e61e5zdd
  33:     0x7f2a146dcc70 - task::spawn_opts::closure.8315
  34:     0x7f2a12fd16e0 - thread::thread_start::hba588af1f803bb5blCd
  35:     0x7f2a1227f0c0 - start_thread
  36:     0x7f2a12c99359 - __clone
  37:                0x0 - &lt;unknown&gt;"><pre class="notranslate"><code class="notranslate">   1:     0x7f2a127e8580 - rt::backtrace::imp::write::h0180e7ded76a3ff2c0q
   2:     0x7f2a127eb770 - failure::on_fail::h3f169393c89b5f90Tlr
   3:     0x7f2a12fd24f0 - unwind::begin_unwind_inner::haeb9517b5061bc86Zie
   4:     0x7f2a133ad670 - unwind::begin_unwind::h17017358962417336117
   5:     0x7f2a13803a20 - middle::ty::unsized_part_of_type::h8eae6d239e9b7af3tnG
   6:     0x7f2a138037c0 - middle::trans::type_of::type_of::type_of_unsize_info::h67819f63aa2acfb5Xh9
   7:     0x7f2a1377b050 - middle::trans::type_of::type_of::h3c89a1738d384c45Ih9
   8:     0x7f2a1377b050 - middle::trans::type_of::type_of::h3c89a1738d384c45Ih9
   9:     0x7f2a137b0860 - middle::trans::base::alloc_ty::h5485998eeb61d023mTd
  10:     0x7f2a13859870 - middle::trans::_match::mk_binding_alloca::h11628361498234501597
  11:     0x7f2a1385bdf0 - middle::trans::_match::store_local::create_dummy_locals::closure.119283
  12:     0x7f2a13681560 - middle::pat_util::pat_bindings::closure.112016
  13:     0x7f2a0ea1ccb0 - ast_util::walk_pat::hc858153057fb5965oRB
  14:     0x7f2a138205f0 - middle::trans::_match::store_local::h9195017fe21b4124A2h
  15:     0x7f2a13772d10 - middle::trans::base::init_local::h5e8a493dc2ae05b1WFd
  16:     0x7f2a13772220 - middle::trans::controlflow::trans_stmt::hf26d5cee55a6056blhY
  17:     0x7f2a13773c40 - middle::trans::controlflow::trans_block::h004dea36138a75c8wmY
  18:     0x7f2a13829560 - middle::trans::base::trans_closure::h655acfc433ac13fevye
  19:     0x7f2a13764670 - middle::trans::base::trans_fn::hf0a444fa9ff43aebiKe
  20:     0x7f2a1375f9b0 - middle::trans::base::trans_item::hda4d4160cb2b58dfi2e
  21:     0x7f2a138341f0 - middle::trans::base::trans_crate::hff0f87c98e6356c8JWf
  22:     0x7f2a13c058d0 - driver::driver::phase_4_translate_to_llvm::h8223ee9d7ab4951cpzy
  23:     0x7f2a13bfd280 - driver::driver::compile_input::hfa4fd95c9e6a2ceeQby
  24:     0x7f2a13c8f0a0 - driver::run_compiler::h32bdccca6ed9465cJIB
  25:     0x7f2a13c8efb0 - driver::main_args::closure.138206
  26:     0x7f2a13ca1240 - task::TaskBuilder&lt;S&gt;::try_future::closure.139324
  27:     0x7f2a13ca1040 - task::TaskBuilder&lt;S&gt;::spawn_internal::closure.139301
  28:     0x7f2a146dcf10 - task::spawn_opts::closure.8369
  29:     0x7f2a1302af90 - rust_try_inner
  30:     0x7f2a1302af80 - rust_try
  31:     0x7f2a12fcfb20 - unwind::try::h03d8d1d4cb0de0c1f7d
  32:     0x7f2a12fcf8e0 - task::Task::run::hafab6bcab45e61e5zdd
  33:     0x7f2a146dcc70 - task::spawn_opts::closure.8315
  34:     0x7f2a12fd16e0 - thread::thread_start::hba588af1f803bb5blCd
  35:     0x7f2a1227f0c0 - start_thread
  36:     0x7f2a12c99359 - __clone
  37:                0x0 - &lt;unknown&gt;
</code></pre></div>
<p dir="auto">This seems to occur when using a non-struct type that contains an unsized type. This is probably because <a href="https://github.com/rust-lang/rust/blob/7932b719ec2b65acfa8c3e74aad29346d47ee992/src/librustc/middle/ty.rs#L2938-L2956"><code class="notranslate">unsized_part_of_type</code></a> only handles <code class="notranslate">ty_struct</code> and the base unsized types. This should be extended to handle enums and tuples as well.</p>