Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

assertion failed: !self.has_escaping_regions() #22999

Closed
elinorbgr opened this issue Mar 3, 2015 · 1 comment
Closed

assertion failed: !self.has_escaping_regions() #22999

elinorbgr opened this issue Mar 3, 2015 · 1 comment
Labels
A-lifetimes Area: Lifetimes / regions I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@elinorbgr
Copy link
Contributor

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.

@jdm jdm added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Mar 3, 2015
@huonw huonw added the A-lifetimes Area: Lifetimes / regions label Mar 5, 2015
@frewsxcv
Copy link
Member

The original code block no longer compiles in Rust 1.0 beta2

~/Downloads $ rustc test.rs
test.rs:8:16: 8:26 error: type `A` does not implement any method in scope named `iter_mut`
test.rs:8     for p in a.iter_mut() {
                         ^~~~~~~~~~
test.rs:8:16: 8:26 help: methods from traits can only be called if the trait is implemented and in scope; the following trait defines a method `iter_mut`, perhaps you need to implement it:
test.rs:8:16: 8:26 help: candidate #1: `core::slice::SliceExt`
test.rs:15:32: 15:42 error: the trait `core::marker::Sized` is not implemented for the type `[_]` [E0277]
test.rs:15     let a: [_; 100] = unsafe { init_array(|| 0u8) };
                                          ^~~~~~~~~~
test.rs:15:32: 15:42 note: `[_]` does not have a constant size known at compile-time
test.rs:15     let a: [_; 100] = unsafe { init_array(|| 0u8) };
                                          ^~~~~~~~~~
test.rs:15:32: 15:50 error: mismatched types:
 expected `[_; 100]`,
    found `[u8]`
(expected array of 100 elements,
    found slice) [E0308]
test.rs:15     let a: [_; 100] = unsafe { init_array(|| 0u8) };
                                          ^~~~~~~~~~~~~~~~~~
error: aborting due to 3 previous errors

~/Downloads $ rustc --version
rustc 1.0.0-beta.2 (e9080ec39 2015-04-16) (built 2015-04-16)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lifetimes Area: Lifetimes / regions I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

4 participants