<p dir="auto">Getting this ICE:<br>
error: internal compiler error: trying to take the sizing type of A, an unsized type</p>
<p dir="auto">when compiling this:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="enum A {
    B(char),
    C([Box&lt;A&gt;]),
}

fn c(c:char) -&gt; A {
    return B(c)
}

pub fn main() {
}"><pre class="notranslate"><code class="notranslate">enum A {
    B(char),
    C([Box&lt;A&gt;]),
}

fn c(c:char) -&gt; A {
    return B(c)
}

pub fn main() {
}
</code></pre></div>
<p dir="auto">Heard on IRC that pinging <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/nick29581/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/nick29581">@nick29581</a> may be good on this issue</p>
<p dir="auto">Hello,</p>
<p dir="auto">I don't know if this is related to <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="41406143" data-permission-text="Title is private" data-url="https://github.com/rust-lang/rust/issues/16822" data-hovercard-type="issue" data-hovercard-url="/rust-lang/rust/issues/16822/hovercard" href="https://github.com/rust-lang/rust/issues/16822">#16822</a> or not. I was following the example here <a href="http://doc.rust-lang.org/getopts/" rel="nofollow">http://doc.rust-lang.org/getopts/</a> and wanted to tweak it so the <code class="notranslate">program</code> is only the filename, not the whole path to it. So I started hacking around and extracted it into a function, which resulted into this error.</p>
<p dir="auto">I'm new to Rust, so… I'm doing silly things probably. :) Feel free to tell me.<br>
Anyway this is not the "getopts" code, I wanted to isolate the problem. I also made the types explicit for illustration.</p>
<div class="highlight highlight-source-rust notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="fn main() {
    let filename: &amp;str = &amp;filename_of_foo();
    // `filename` should be &amp;&quot;foo&quot;
    println!(&quot;The filename is {}&quot;, filename);
}

fn filename_of_foo() -&gt; str {
    let path: Path     = Path::new(&quot;./bar/foo&quot;);
    let filename: &amp;str = path.filename_str().unwrap();
    *filename
}"><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> filename<span class="pl-kos">:</span> <span class="pl-c1">&amp;</span><span class="pl-smi">str</span> = <span class="pl-c1">&amp;</span><span class="pl-en">filename_of_foo</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-c">// `filename` should be &amp;"foo"</span>
    <span class="pl-en">println</span><span class="pl-en">!</span><span class="pl-kos">(</span><span class="pl-s">"The filename is {}"</span>, filename<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">filename_of_foo</span><span class="pl-kos">(</span><span class="pl-kos">)</span> -&gt; <span class="pl-smi">str</span> <span class="pl-kos">{</span>
    <span class="pl-k">let</span> path<span class="pl-kos">:</span> <span class="pl-smi">Path</span>     = <span class="pl-smi">Path</span><span class="pl-kos">::</span><span class="pl-en">new</span><span class="pl-kos">(</span><span class="pl-s">"./bar/foo"</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-k">let</span> filename<span class="pl-kos">:</span> <span class="pl-c1">&amp;</span><span class="pl-smi">str</span> = path<span class="pl-kos">.</span><span class="pl-en">filename_str</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">unwrap</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-c1">*</span>filename
<span class="pl-kos">}</span></pre></div>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ RUST_BACKTRACE=1 rustc main.rs
error: internal compiler error: trying to take the sizing type of str, an unsized type
note: the compiler hit an unexpected failure path. 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
task 'rustc' failed at 'Box&lt;Any&gt;', /Users/olda/Code/rust/rust-lang/src/libsyntax/ast_util.rs:776

stack backtrace:
   1:        0x10e7ea9b5 - rt::backtrace::imp::write::hbe93ad1ca3375f7ai9q
   2:        0x10e7edd33 - failure::on_fail::ha008d924473a588cbqr
   3:        0x10eab3d23 - unwind::begin_unwind_inner::h53af0f566031f9f14fe
   4:        0x10c7b643a - unwind::begin_unwind::h3612296561932415380
   5:        0x10c7b6e40 - diagnostic::Handler::bug::h6cd4a0f0829e2050shF
   6:        0x10b3a5c58 - driver::session::Session::bug::hba3620fae1af216dkXz
   7:        0x10b75c121 - middle::trans::type_of::sizing_type_of::h7963730f82cd4b33Ma9
   8:        0x10b78aeac - middle::trans::expr::trans_unadjusted::he74a35bd5ea421c1Fh3
   9:        0x10b748380 - middle::trans::expr::trans::hd79efa6056358d2dEw2
  10:        0x10b798ca1 - middle::trans::expr::trans_addr_of::hff42e1cdb8b6828bfI4
  11:        0x10b78b4f8 - middle::trans::expr::trans_unadjusted::he74a35bd5ea421c1Fh3
  12:        0x10b748380 - middle::trans::expr::trans::hd79efa6056358d2dEw2
  13:        0x10b746b48 - middle::trans::expr::trans_into::h4adfb7ed4c8e4c8eIs2
  14:        0x10b82a54f - middle::trans::_match::store_local::closure.119296
  15:        0x10b82a321 - middle::trans::_match::mk_binding_alloca::h11723812663586266914
  16:        0x10b7f2233 - middle::trans::_match::store_local::h15ef2e60d6b94e5cA2h
  17:        0x10b7463b2 - middle::trans::base::init_local::hf1089f76e4fd41bdWFd
  18:        0x10b7458ea - middle::trans::controlflow::trans_stmt::h2ab88f6dc40905eblhY
  19:        0x10b74701c - middle::trans::controlflow::trans_block::hee6f69106b0dfacewmY
  20:        0x10b7fd0e2 - middle::trans::base::trans_closure::h9bdf3049defa1b73vye
  21:        0x10b7382a0 - middle::trans::base::trans_fn::hf0c57f353c923cd3iKe
  22:        0x10b73361f - middle::trans::base::trans_item::hbe3f225a458737f5i2e
  23:        0x10b8060bc - middle::trans::base::trans_crate::h430604ba8b62ae67JWf
  24:        0x10bbc0811 - driver::driver::phase_4_translate_to_llvm::h3758d3df9e2a7401pzy
  25:        0x10bbb9d3d - driver::driver::compile_input::hf84c86c09fa7f085Qby
  26:        0x10bc43dc7 - driver::run_compiler::hd0616be9c11c6733JIB
  27:        0x10bc42506 - driver::main_args::closure.138223
  28:        0x10bc53dbb - task::TaskBuilder&lt;S&gt;::try_future::closure.139341
  29:        0x10bc53cc3 - task::TaskBuilder&lt;S&gt;::spawn_internal::closure.139318
  30:        0x10e71e2ec - task::spawn_opts::closure.8459
  31:        0x10eb18b0c - rust_try_inner
  32:        0x10eb18af6 - rust_try
  33:        0x10eab1177 - unwind::try::h5bbc3fdef4df0c47k4d
  34:        0x10eab0f3b - task::Task::run::h3fd23eb8e2343898bbd
  35:        0x10e71e132 - task::spawn_opts::closure.8404
  36:        0x10eab2cb6 - thread::thread_start::hb6d4d41faea4249bXzd
  37:     0x7fff8ce03899 - _pthread_body
  38:     0x7fff8ce0372a - _pthread_struct_init"><pre class="notranslate"><code class="notranslate">$ RUST_BACKTRACE=1 rustc main.rs
error: internal compiler error: trying to take the sizing type of str, an unsized type
note: the compiler hit an unexpected failure path. 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
task 'rustc' failed at 'Box&lt;Any&gt;', /Users/olda/Code/rust/rust-lang/src/libsyntax/ast_util.rs:776

stack backtrace:
   1:        0x10e7ea9b5 - rt::backtrace::imp::write::hbe93ad1ca3375f7ai9q
   2:        0x10e7edd33 - failure::on_fail::ha008d924473a588cbqr
   3:        0x10eab3d23 - unwind::begin_unwind_inner::h53af0f566031f9f14fe
   4:        0x10c7b643a - unwind::begin_unwind::h3612296561932415380
   5:        0x10c7b6e40 - diagnostic::Handler::bug::h6cd4a0f0829e2050shF
   6:        0x10b3a5c58 - driver::session::Session::bug::hba3620fae1af216dkXz
   7:        0x10b75c121 - middle::trans::type_of::sizing_type_of::h7963730f82cd4b33Ma9
   8:        0x10b78aeac - middle::trans::expr::trans_unadjusted::he74a35bd5ea421c1Fh3
   9:        0x10b748380 - middle::trans::expr::trans::hd79efa6056358d2dEw2
  10:        0x10b798ca1 - middle::trans::expr::trans_addr_of::hff42e1cdb8b6828bfI4
  11:        0x10b78b4f8 - middle::trans::expr::trans_unadjusted::he74a35bd5ea421c1Fh3
  12:        0x10b748380 - middle::trans::expr::trans::hd79efa6056358d2dEw2
  13:        0x10b746b48 - middle::trans::expr::trans_into::h4adfb7ed4c8e4c8eIs2
  14:        0x10b82a54f - middle::trans::_match::store_local::closure.119296
  15:        0x10b82a321 - middle::trans::_match::mk_binding_alloca::h11723812663586266914
  16:        0x10b7f2233 - middle::trans::_match::store_local::h15ef2e60d6b94e5cA2h
  17:        0x10b7463b2 - middle::trans::base::init_local::hf1089f76e4fd41bdWFd
  18:        0x10b7458ea - middle::trans::controlflow::trans_stmt::h2ab88f6dc40905eblhY
  19:        0x10b74701c - middle::trans::controlflow::trans_block::hee6f69106b0dfacewmY
  20:        0x10b7fd0e2 - middle::trans::base::trans_closure::h9bdf3049defa1b73vye
  21:        0x10b7382a0 - middle::trans::base::trans_fn::hf0c57f353c923cd3iKe
  22:        0x10b73361f - middle::trans::base::trans_item::hbe3f225a458737f5i2e
  23:        0x10b8060bc - middle::trans::base::trans_crate::h430604ba8b62ae67JWf
  24:        0x10bbc0811 - driver::driver::phase_4_translate_to_llvm::h3758d3df9e2a7401pzy
  25:        0x10bbb9d3d - driver::driver::compile_input::hf84c86c09fa7f085Qby
  26:        0x10bc43dc7 - driver::run_compiler::hd0616be9c11c6733JIB
  27:        0x10bc42506 - driver::main_args::closure.138223
  28:        0x10bc53dbb - task::TaskBuilder&lt;S&gt;::try_future::closure.139341
  29:        0x10bc53cc3 - task::TaskBuilder&lt;S&gt;::spawn_internal::closure.139318
  30:        0x10e71e2ec - task::spawn_opts::closure.8459
  31:        0x10eb18b0c - rust_try_inner
  32:        0x10eb18af6 - rust_try
  33:        0x10eab1177 - unwind::try::h5bbc3fdef4df0c47k4d
  34:        0x10eab0f3b - task::Task::run::h3fd23eb8e2343898bbd
  35:        0x10e71e132 - task::spawn_opts::closure.8404
  36:        0x10eab2cb6 - thread::thread_start::hb6d4d41faea4249bXzd
  37:     0x7fff8ce03899 - _pthread_body
  38:     0x7fff8ce0372a - _pthread_struct_init
</code></pre></div>
<p dir="auto">My system:<br>
OS X 10.9.4</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ uname -v
Darwin Kernel Version 13.3.0: Tue Jun  3 21:27:35 PDT 2014; root:xnu-2422.110.17~1/RELEASE_X86_64
$ rustc --version
rustc 0.12.0-pre (0d3bd7720 2014-08-27 21:31:13 +0000)
$ cargo --version
cargo 0.0.1-pre (89259f1 2014-08-28 18:28:57 +0000)"><pre class="notranslate"><code class="notranslate">$ uname -v
Darwin Kernel Version 13.3.0: Tue Jun  3 21:27:35 PDT 2014; root:xnu-2422.110.17~1/RELEASE_X86_64
$ rustc --version
rustc 0.12.0-pre (0d3bd7720 2014-08-27 21:31:13 +0000)
$ cargo --version
cargo 0.0.1-pre (89259f1 2014-08-28 18:28:57 +0000)
</code></pre></div>
<p dir="auto">Thanks,<br>
Ollie</p>