Skip to content

ICE with new borrowck and macros #6304

Closed
@alexcrichton

Description

@alexcrichton

This code (attempted to whittle down as much as possible) yields an ICE:

struct Foo {
  a: int
}

pub enum Bar {
  Bar1, Bar2(int, ~Bar),
}

impl Foo {
  fn elaborate_stm(&mut self, s: ~Bar) -> ~Bar {
    macro_rules! declare(
      ($id:expr, $rest:expr) => ({
        self.check_id($id);
        ~Bar2($id, $rest)
      })
    );
    match s {
      ~Bar2(id, rest) => declare!(id, self.elaborate_stm(rest)),
      _ => fail!()
    }
  }

  fn check_id(&mut self, s: int) { fail!() }
}
$ RUST_LOG=rustc=1,::rt::backtrace rustc --test ./foo.rs
./foo.rs:23:25: 23:26 warning: unused variable: `s`
./foo.rs:23   fn check_id(&mut self, s: int) { fail!() }
                                           ^
rust: task failed at 'assertion failed: region_maps.scopes_intersect(old_loan.kill_scope, new_loan.kill_scope)', /Users/alex/code/rust-src/
src/librustc/middle/borrowck/check_loans.rs:174
error: internal compiler error: unexpected failure
note: the compiler hit an unexpected failure path. this is a bug
note: try running with RUST_LOG=rustc=1,::rt::backtrace to get further details and report the results to github.com/mozilla/rust/issues
rust: task failed at 'explicit failure', /Users/alex/code/rust-src/src/librustc/rustc.rc:353
rust: domain main @0x7f8924017810 root task failed
rust: domain main @0x7f8924017810 root task failed

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions