Closed
Description
I was playing around and hit this:
unsafe fn init_array<A, F, T>(mut f: F) -> A
where F: FnMut() -> T,
T: 'static,
for<'a> &'a mut A: ::std::ops::DerefMut<Target=[T]>,
A: 'static
{
let mut a: A = std::mem::uninitialized();
for p in a.iter_mut() {
std::ptr::write(p, f());
}
a
}
fn main() {
let a: [_; 100] = unsafe { init_array(|| 0u8) };
}
causing
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 'assertion failed: !self.has_escaping_regions()', /var/tmp/portage/dev-lang/rust-9999/work/rust-9999/src/librustc/middle/ty.rs:1932
running with RUST_BACKTRACE=1
simply dies from SIGILL
without outputting anything.
rustc --version
rustc 1.0.0-dev (0eb0ba38d 2015-03-01) (built 2015-03-01)
I can reproduce it on the playpen as well, which is a more recent version.