<p dir="auto">rustc panics with the following backtrace when building <a href="https://github.com/alexchandel/rlibc">this fork of rlibc</a>. I can't even tell which line of my code is causing it, but it occurs after most of the warnings are printed:</p>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="...
src/posix/fcntl.rs:6:62: 6:66 warning: unused variable: `mode`, #[warn(unused_variables)] on by default
src/posix/fcntl.rs:6 pub unsafe extern fn open(path: *const char_t, flags: int_t, mode: mode_t) -&gt; int_t {
                                                                                  ^~~~
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 'Trying to convert unsized value to lval', /Users/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-mac/build/src/librustc_trans/trans/datum.rs:495

stack backtrace:
   1:        0x112612be3 - sys::backtrace::write::h918207864656307b0nC
   2:        0x112640be5 - panicking::on_panic::h2c4b1456225ae37fnPL
   3:        0x11256a418 - rt::unwind::begin_unwind_inner::h6c7f1344c68dd4a7AwL
   4:        0x10ea6dc45 - rt::unwind::begin_unwind::h4082345751407454387
   5:        0x10eaec56f - trans::datum::Datum&lt;'tcx, Expr&gt;::to_lvalue_datum::h4809841e9861f286hYf
   6:        0x10eb20dd5 - trans::expr::trans_index::h56dd6242817519cf6Ei
   7:        0x10eb0d9c9 - trans::expr::trans_unadjusted::h8c78f89bb783464csqi
   8:        0x10eac21d0 - trans::expr::trans::h25c26cd42d9241e1HMh
   9:        0x10eb237e3 - trans::expr::trans_addr_of::h5be1b2f119f51174rNj
  10:        0x10eb0dbd7 - trans::expr::trans_unadjusted::h8c78f89bb783464csqi
  11:        0x10eac21d0 - trans::expr::trans::h25c26cd42d9241e1HMh
  12:        0x10eafdba5 - trans::callee::trans_args::hc52bfad7cdf49353xjh
  13:        0x10eb048fc - trans::callee::trans_call_inner::h5306915459861161960
  14:        0x10eb0fdaa - trans::expr::trans_rvalue_dps_unadjusted::hb1406d54d45518409Wi
  15:        0x10eb0d642 - trans::expr::trans_unadjusted::h8c78f89bb783464csqi
  16:        0x10eac21d0 - trans::expr::trans::h25c26cd42d9241e1HMh
  17:        0x10eb22c0c - trans::expr::trans_unary::h509c840b305ef674LFj
  18:        0x10eb0dbc0 - trans::expr::trans_unadjusted::h8c78f89bb783464csqi
  19:        0x10eac0a0b - trans::expr::trans_into::h0f31dfb1ff207cd8pGh
  20:        0x10ebb5fd7 - trans::_match::trans_match_inner::h56e2641ee60bee0daMx
  21:        0x10eb0f1b3 - trans::expr::trans_rvalue_dps_unadjusted::hb1406d54d45518409Wi
  22:        0x10eac09eb - trans::expr::trans_into::h0f31dfb1ff207cd8pGh
  23:        0x10eac17fa - trans::controlflow::trans_block::hb675814db44e1ef35ee
  24:        0x10eb982bf - trans::base::trans_closure::h1fc9dae5b42c150ephu
  25:        0x10eaac086 - trans::base::trans_fn::h1baa1a79c6642379Gsu
  26:        0x10eaa6fc9 - trans::base::trans_item::h99ee5fcee3ea0222zRu
  27:        0x10eb99a89 - trans::base::trans_mod::h0f4f7f5d04ce3f65yXu
  28:        0x10eaa70dd - trans::base::trans_item::h99ee5fcee3ea0222zRu
  29:        0x10eb9ee0c - trans::base::trans_crate::h89e3520c5dfd05b21Ov
  30:        0x10e92d058 - driver::phase_4_translate_to_llvm::h5a7c1f8c7ec04632qPa
  31:        0x10e907f72 - driver::compile_input::h32723f720e0c3c95Gba
  32:        0x10e9e08a7 - run_compiler::hfdf8469da778a8d4Zbc
  33:        0x10e9ddd21 - thunk::F.Invoke&lt;A, R&gt;::invoke::h56535309890628509
  34:        0x10e9dc980 - rt::unwind::try::try_fn::h6830563953582217021
  35:        0x1126ba7e9 - rust_try_inner
  36:        0x1126ba7d6 - rust_try
  37:        0x10e9dd0e5 - thunk::F.Invoke&lt;A, R&gt;::invoke::h12775416177659868106
  38:        0x112629ac3 - sys::thread::thread_start::hccc0587963a6c50bU4G
  39:     0x7fff8cc79268 - _pthread_body
  40:     0x7fff8cc791e5 - _pthread_body

make: *** [target/x86_64-apple-darwin/c.o] Error 101"><pre class="notranslate">...
src/posix/fcntl.rs:6:62: 6:66 warning: unused variable: <span class="pl-s"><span class="pl-pds">`</span>mode<span class="pl-pds">`</span></span>, <span class="pl-c"><span class="pl-c">#</span>[warn(unused_variables)] on by default</span>
src/posix/fcntl.rs:6 pub unsafe extern fn open(path: <span class="pl-k">*</span>const char_t, flags: int_t, mode: mode_t) -<span class="pl-k">&gt;</span> int_t {
                                                                                  ^~~~
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 <span class="pl-s"><span class="pl-pds">`</span>RUST_BACKTRACE=1<span class="pl-pds">`</span></span> <span class="pl-k">for</span> a backtrace
thread <span class="pl-s"><span class="pl-pds">'</span>rustc<span class="pl-pds">'</span></span> panicked at <span class="pl-s"><span class="pl-pds">'</span>Trying to convert unsized value to lval<span class="pl-pds">'</span></span>, /Users/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-mac/build/src/librustc_trans/trans/datum.rs:495

stack backtrace:
   1:        0x112612be3 - sys::backtrace::write::h918207864656307b0nC
   2:        0x112640be5 - panicking::on_panic::h2c4b1456225ae37fnPL
   3:        0x11256a418 - rt::unwind::begin_unwind_inner::h6c7f1344c68dd4a7AwL
   4:        0x10ea6dc45 - rt::unwind::begin_unwind::h4082345751407454387
   5:        0x10eaec56f - trans::datum::Datum<span class="pl-k">&lt;</span><span class="pl-s"><span class="pl-pds">'</span>tcx, Expr&gt;::to_lvalue_datum::h4809841e9861f286hYf</span>
<span class="pl-s">   6:        0x10eb20dd5 - trans::expr::trans_index::h56dd6242817519cf6Ei</span>
<span class="pl-s">   7:        0x10eb0d9c9 - trans::expr::trans_unadjusted::h8c78f89bb783464csqi</span>
<span class="pl-s">   8:        0x10eac21d0 - trans::expr::trans::h25c26cd42d9241e1HMh</span>
<span class="pl-s">   9:        0x10eb237e3 - trans::expr::trans_addr_of::h5be1b2f119f51174rNj</span>
<span class="pl-s">  10:        0x10eb0dbd7 - trans::expr::trans_unadjusted::h8c78f89bb783464csqi</span>
<span class="pl-s">  11:        0x10eac21d0 - trans::expr::trans::h25c26cd42d9241e1HMh</span>
<span class="pl-s">  12:        0x10eafdba5 - trans::callee::trans_args::hc52bfad7cdf49353xjh</span>
<span class="pl-s">  13:        0x10eb048fc - trans::callee::trans_call_inner::h5306915459861161960</span>
<span class="pl-s">  14:        0x10eb0fdaa - trans::expr::trans_rvalue_dps_unadjusted::hb1406d54d45518409Wi</span>
<span class="pl-s">  15:        0x10eb0d642 - trans::expr::trans_unadjusted::h8c78f89bb783464csqi</span>
<span class="pl-s">  16:        0x10eac21d0 - trans::expr::trans::h25c26cd42d9241e1HMh</span>
<span class="pl-s">  17:        0x10eb22c0c - trans::expr::trans_unary::h509c840b305ef674LFj</span>
<span class="pl-s">  18:        0x10eb0dbc0 - trans::expr::trans_unadjusted::h8c78f89bb783464csqi</span>
<span class="pl-s">  19:        0x10eac0a0b - trans::expr::trans_into::h0f31dfb1ff207cd8pGh</span>
<span class="pl-s">  20:        0x10ebb5fd7 - trans::_match::trans_match_inner::h56e2641ee60bee0daMx</span>
<span class="pl-s">  21:        0x10eb0f1b3 - trans::expr::trans_rvalue_dps_unadjusted::hb1406d54d45518409Wi</span>
<span class="pl-s">  22:        0x10eac09eb - trans::expr::trans_into::h0f31dfb1ff207cd8pGh</span>
<span class="pl-s">  23:        0x10eac17fa - trans::controlflow::trans_block::hb675814db44e1ef35ee</span>
<span class="pl-s">  24:        0x10eb982bf - trans::base::trans_closure::h1fc9dae5b42c150ephu</span>
<span class="pl-s">  25:        0x10eaac086 - trans::base::trans_fn::h1baa1a79c6642379Gsu</span>
<span class="pl-s">  26:        0x10eaa6fc9 - trans::base::trans_item::h99ee5fcee3ea0222zRu</span>
<span class="pl-s">  27:        0x10eb99a89 - trans::base::trans_mod::h0f4f7f5d04ce3f65yXu</span>
<span class="pl-s">  28:        0x10eaa70dd - trans::base::trans_item::h99ee5fcee3ea0222zRu</span>
<span class="pl-s">  29:        0x10eb9ee0c - trans::base::trans_crate::h89e3520c5dfd05b21Ov</span>
<span class="pl-s">  30:        0x10e92d058 - driver::phase_4_translate_to_llvm::h5a7c1f8c7ec04632qPa</span>
<span class="pl-s">  31:        0x10e907f72 - driver::compile_input::h32723f720e0c3c95Gba</span>
<span class="pl-s">  32:        0x10e9e08a7 - run_compiler::hfdf8469da778a8d4Zbc</span>
<span class="pl-s">  33:        0x10e9ddd21 - thunk::F.Invoke&lt;A, R&gt;::invoke::h56535309890628509</span>
<span class="pl-s">  34:        0x10e9dc980 - rt::unwind::try::try_fn::h6830563953582217021</span>
<span class="pl-s">  35:        0x1126ba7e9 - rust_try_inner</span>
<span class="pl-s">  36:        0x1126ba7d6 - rust_try</span>
<span class="pl-s">  37:        0x10e9dd0e5 - thunk::F.Invoke&lt;A, R&gt;::invoke::h12775416177659868106</span>
<span class="pl-s">  38:        0x112629ac3 - sys::thread::thread_start::hccc0587963a6c50bU4G</span>
<span class="pl-s">  39:     0x7fff8cc79268 - _pthread_body</span>
<span class="pl-s">  40:     0x7fff8cc791e5 - _pthread_body</span>
<span class="pl-s"></span>
<span class="pl-s">make: *** [target/x86_64-apple-darwin/c.o] Error 101</span></pre></div>
<p dir="auto">I got this compiling a fairly large app:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="error: internal compiler error: unexpected panic
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: http://doc.rust-lang.org/complement-bugreport.html
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'Trying to convert unsized value to lval', /Users/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-mac/build/src/librustc_trans/trans/datum.rs:402

stack backtrace:
   1:        0x10c85ecd7 - sys::backtrace::write::h4ee5c5ad264b65f5mbu
   2:        0x10c884e9c - failure::on_fail::h55e5ff39107f11fcHbB
   3:        0x10c7e6618 - rt::unwind::begin_unwind_inner::habba3c5d37f59591DTA
   4:        0x10904eca5 - rt::unwind::begin_unwind::h5615917778268573803
   5:        0x1090d753e - trans::datum::Datum&lt;'tcx, Expr&gt;::to_lvalue_datum::h9595aad7c2992d4cZSf
   6:        0x1090feaac - trans::expr::trans_index::h33588fb9dd7ce121yzi
   7:        0x1090e75a3 - trans::expr::trans_unadjusted::h4bfe4622405612c0Vki
   8:        0x10909f7d4 - trans::expr::trans::h87900629b98dec94YCh
   9:        0x109101448 - trans::expr::trans_addr_of::he4d93cb9897bf566uHj
  10:        0x1090e779e - trans::expr::trans_unadjusted::h4bfe4622405612c0Vki
  11:        0x10909f7d4 - trans::expr::trans::h87900629b98dec94YCh
  12:        0x10909e521 - trans::expr::trans_into::h8d099f5179d39277uzh
  13:        0x10911d773 - trans::expr::trans_adt::h04652ea6bac31317Drj
  14:        0x1090b0cdf - trans::base::trans_named_tuple_constructor::h27bf054814ac4386Dcu
  15:        0x1090e25a6 - trans::callee::trans_call_inner::h12337891083913942824
  16:        0x1090e9b77 - trans::expr::trans_rvalue_dps_unadjusted::h76d104b0c393ded0ITi
  17:        0x10909e762 - trans::expr::trans_into::h8d099f5179d39277uzh
  18:        0x10909f339 - trans::controlflow::trans_block::ha4c3bc4d960bd55aT3d
  19:        0x1090e8c91 - trans::expr::trans_rvalue_dps_unadjusted::h76d104b0c393ded0ITi
  20:        0x10909e762 - trans::expr::trans_into::h8d099f5179d39277uzh
  21:        0x10909f339 - trans::controlflow::trans_block::ha4c3bc4d960bd55aT3d
  22:        0x10916c644 - trans::base::trans_closure::hc2f7f2fc0f6c7df0WXt
  23:        0x10908b1c9 - trans::base::trans_fn::he8bb083f0eb63cd3Q8t
  24:        0x109086f0b - trans::base::trans_item::h6e886ccbd5f66d227vu
  25:        0x10916de29 - trans::base::trans_mod::hacffe7d798632c0cIBu
  26:        0x10908664e - trans::base::trans_item::h6e886ccbd5f66d227vu
  27:        0x109172a8c - trans::base::trans_crate::h03f93f510f95d199hrv
  28:        0x108f29f6e - driver::phase_4_translate_to_llvm::hf01e1f3e6069eac9mOa
  29:        0x108f05f3c - driver::compile_input::h8e0204b8bb9ea44bBba
  30:        0x108fced3e - run_compiler::h322f9334a9a1d7e6l9b
  31:        0x108fcbd7f - thunk::F.Invoke&lt;A, R&gt;::invoke::h14356237310415989951
  32:        0x108fcaa10 - rt::unwind::try::try_fn::h798029436104877783
  33:        0x10c8fb329 - rust_try_inner
  34:        0x10c8fb316 - rust_try
  35:        0x108fcb0d4 - thunk::F.Invoke&lt;A, R&gt;::invoke::h15628186897385384602
  36:        0x10c86f553 - sys::thread::thread_start::h3f48e8c893476626A3w
  37:     0x7fff854c5899 - _pthread_body
  38:     0x7fff854c572a - _pthread_struct_init"><pre class="notranslate"><code class="notranslate">error: internal compiler error: unexpected panic
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: http://doc.rust-lang.org/complement-bugreport.html
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'Trying to convert unsized value to lval', /Users/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-mac/build/src/librustc_trans/trans/datum.rs:402

stack backtrace:
   1:        0x10c85ecd7 - sys::backtrace::write::h4ee5c5ad264b65f5mbu
   2:        0x10c884e9c - failure::on_fail::h55e5ff39107f11fcHbB
   3:        0x10c7e6618 - rt::unwind::begin_unwind_inner::habba3c5d37f59591DTA
   4:        0x10904eca5 - rt::unwind::begin_unwind::h5615917778268573803
   5:        0x1090d753e - trans::datum::Datum&lt;'tcx, Expr&gt;::to_lvalue_datum::h9595aad7c2992d4cZSf
   6:        0x1090feaac - trans::expr::trans_index::h33588fb9dd7ce121yzi
   7:        0x1090e75a3 - trans::expr::trans_unadjusted::h4bfe4622405612c0Vki
   8:        0x10909f7d4 - trans::expr::trans::h87900629b98dec94YCh
   9:        0x109101448 - trans::expr::trans_addr_of::he4d93cb9897bf566uHj
  10:        0x1090e779e - trans::expr::trans_unadjusted::h4bfe4622405612c0Vki
  11:        0x10909f7d4 - trans::expr::trans::h87900629b98dec94YCh
  12:        0x10909e521 - trans::expr::trans_into::h8d099f5179d39277uzh
  13:        0x10911d773 - trans::expr::trans_adt::h04652ea6bac31317Drj
  14:        0x1090b0cdf - trans::base::trans_named_tuple_constructor::h27bf054814ac4386Dcu
  15:        0x1090e25a6 - trans::callee::trans_call_inner::h12337891083913942824
  16:        0x1090e9b77 - trans::expr::trans_rvalue_dps_unadjusted::h76d104b0c393ded0ITi
  17:        0x10909e762 - trans::expr::trans_into::h8d099f5179d39277uzh
  18:        0x10909f339 - trans::controlflow::trans_block::ha4c3bc4d960bd55aT3d
  19:        0x1090e8c91 - trans::expr::trans_rvalue_dps_unadjusted::h76d104b0c393ded0ITi
  20:        0x10909e762 - trans::expr::trans_into::h8d099f5179d39277uzh
  21:        0x10909f339 - trans::controlflow::trans_block::ha4c3bc4d960bd55aT3d
  22:        0x10916c644 - trans::base::trans_closure::hc2f7f2fc0f6c7df0WXt
  23:        0x10908b1c9 - trans::base::trans_fn::he8bb083f0eb63cd3Q8t
  24:        0x109086f0b - trans::base::trans_item::h6e886ccbd5f66d227vu
  25:        0x10916de29 - trans::base::trans_mod::hacffe7d798632c0cIBu
  26:        0x10908664e - trans::base::trans_item::h6e886ccbd5f66d227vu
  27:        0x109172a8c - trans::base::trans_crate::h03f93f510f95d199hrv
  28:        0x108f29f6e - driver::phase_4_translate_to_llvm::hf01e1f3e6069eac9mOa
  29:        0x108f05f3c - driver::compile_input::h8e0204b8bb9ea44bBba
  30:        0x108fced3e - run_compiler::h322f9334a9a1d7e6l9b
  31:        0x108fcbd7f - thunk::F.Invoke&lt;A, R&gt;::invoke::h14356237310415989951
  32:        0x108fcaa10 - rt::unwind::try::try_fn::h798029436104877783
  33:        0x10c8fb329 - rust_try_inner
  34:        0x10c8fb316 - rust_try
  35:        0x108fcb0d4 - thunk::F.Invoke&lt;A, R&gt;::invoke::h15628186897385384602
  36:        0x10c86f553 - sys::thread::thread_start::h3f48e8c893476626A3w
  37:     0x7fff854c5899 - _pthread_body
  38:     0x7fff854c572a - _pthread_struct_init
</code></pre></div>
<p dir="auto">The problem appears to be in this function:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="pub fn chunk_containing(&amp;self, abs_x: u32, abs_y: u32) -&gt; Option&lt;&amp;Chunk&gt; {
    // x_idx and y_idx are indices int the chunks array.
    let x_idx: usize = abs_x.div_floor(&amp;self.chunk_x_size) as usize;
    let y_idx: usize = abs_y.div_floor(&amp;self.chunk_y_size) as usize;

    if ((x_idx as u32) &lt; self.x_chunks &amp;&amp; (y_idx as u32) &lt; self.y_chunks) {
        Some(&amp;self.chunks[y_idx][x_idx])
    } else {
        None
    }
}"><pre class="notranslate"><code class="notranslate">pub fn chunk_containing(&amp;self, abs_x: u32, abs_y: u32) -&gt; Option&lt;&amp;Chunk&gt; {
    // x_idx and y_idx are indices int the chunks array.
    let x_idx: usize = abs_x.div_floor(&amp;self.chunk_x_size) as usize;
    let y_idx: usize = abs_y.div_floor(&amp;self.chunk_y_size) as usize;

    if ((x_idx as u32) &lt; self.x_chunks &amp;&amp; (y_idx as u32) &lt; self.y_chunks) {
        Some(&amp;self.chunks[y_idx][x_idx])
    } else {
        None
    }
}
</code></pre></div>
<p dir="auto">And specifically, the problem appears to be this line:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Some(&amp;self.chunks[y_idx][x_idx])"><pre class="notranslate"><code class="notranslate">Some(&amp;self.chunks[y_idx][x_idx])
</code></pre></div>
<p dir="auto">I reached that conclusion because replacing the above line with <code class="notranslate">None</code> clears the error. The type of <code class="notranslate">self.chunks</code> is <code class="notranslate">[[Chunk]]</code>. Changing its type to <code class="notranslate">Vec&lt;Vec&lt;Chunk&gt;&gt;</code> also clears the error.</p>
<p dir="auto">OSX 10.9.5<br>
rustc 1.0.0-nightly (<a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/rust-lang/rust/commit/1d00c545ede609b9d43fdf9f252c15da5a66dac7/hovercard" href="https://github.com/rust-lang/rust/commit/1d00c545ede609b9d43fdf9f252c15da5a66dac7"><tt>1d00c54</tt></a> 2015-01-30 19:56:34 +0000)<br>
binary: rustc<br>
commit-hash: <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/rust-lang/rust/commit/1d00c545ede609b9d43fdf9f252c15da5a66dac7/hovercard" href="https://github.com/rust-lang/rust/commit/1d00c545ede609b9d43fdf9f252c15da5a66dac7"><tt>1d00c54</tt></a><br>
commit-date: 2015-01-30 19:56:34 +0000<br>
host: x86_64-apple-darwin<br>
release: 1.0.0-nightly</p>