Skip to content

Compiler error - cannot relate bound region: ReScope(Misc(1068)) <= ReLateBound(DebruijnIndex { depth: 1 }, BrAnon(0)) #26641

Closed
@zegl

Description

@zegl

Error

I've been playing around with rust for a while, and while trying something new out, this happened:

src/parser/mod.rs:21:7: 21:17 error: internal compiler error: cannot relate bound region: ReScope(Misc(1068)) <= ReLateBound(DebruijnIndex { depth: 1 }, BrAnon(0))
src/parser/mod.rs:21        let mut parser = Parser {
                                ^~~~~~~~~~
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 'Box<Any>', /Users/rustbuild/src/rust-buildbot/slave/stable-dist-rustc-mac/build/src/libsyntax/diagnostic.rs:170

Code

This code will reproduce the error:

use std::collections::HashMap;

pub struct Parser<'a> {
    symbols: HashMap<String, Symbol<'a>>,
}

impl<'a> Parser<'a> {
    pub fn new() -> Parser<'a> {
        let mut parser = Parser {
            symbols: HashMap::new(),
        };

        parser.register_symbols();

        parser
    }

    fn register_symbols(&'a mut self) {
        self.symbols.insert("name".to_string(), Symbol::new(10, Symbol::name));
    }
}

pub struct Symbol<'a> {
    function: Box<FnMut(Parser, ON) + 'a>,
    importance: u8,
}

impl<'a> Symbol<'a> {
    fn new<F: FnMut(Parser, ON) + 'a>(imp: u8, fun: F) -> Symbol<'a> {
        Symbol {
            function: Box::new(fun),
            importance: imp,
        }
    }

    fn name(parser: Parser, on: ON) {
        println!("name: {:?}", on);
    }
}

#[derive(Debug)]
enum ON {
    ONE,
    TWO,
    THREE,
}

fn main() {
    let mut parser = Parser::new();
}

Meta

rustc 1.1.0 (35ceea399 2015-06-19)
binary: rustc
commit-hash: 35ceea3997c79a3b7562e89b462ab76af5b86b22
commit-date: 2015-06-19
host: x86_64-apple-darwin
release: 1.1.0

Backtrace

   1:        0x10f16efff - sys::backtrace::write::h5a94548fe691961bc2r
   2:        0x10f177a50 - panicking::on_panic::hc33f9bf1349f5e0bLgw
   3:        0x10f132cc5 - rt::unwind::begin_unwind_inner::hb24e48e8f7bb8bb0uYv
   4:        0x10e92e0ce - rt::unwind::begin_unwind::h5631761957623898817
   5:        0x10e92e05a - diagnostic::SpanHandler::span_bug::h8656fda71ac200a8s5B
   6:        0x10c7b7e64 - middle::infer::region_inference::RegionVarBindings<'a, 'tcx>::make_subregion::ha0c4d5c20345133eBev
   7:        0x10c7d1cdb - middle::infer::mk_subr::h9220e1996be5e79fnty
   8:        0x10c2e97ea - check::regionck::type_must_outlive::h877aed0fa7c95785Lue
   9:        0x10c2e77c5 - check::dropck::iterate_over_potentially_unsafe_regions_in_type::h8c796fe6dd45f0c2MDa
  10:        0x10c2e7978 - check::dropck::iterate_over_potentially_unsafe_regions_in_type::h8c796fe6dd45f0c2MDa
  11:        0x10c2e7978 - check::dropck::iterate_over_potentially_unsafe_regions_in_type::h8c796fe6dd45f0c2MDa
  12:        0x10c2e7978 - check::dropck::iterate_over_potentially_unsafe_regions_in_type::h8c796fe6dd45f0c2MDa
  13:        0x10c2e7978 - check::dropck::iterate_over_potentially_unsafe_regions_in_type::h8c796fe6dd45f0c2MDa
  14:        0x10c2e7978 - check::dropck::iterate_over_potentially_unsafe_regions_in_type::h8c796fe6dd45f0c2MDa
  15:        0x10c2e7978 - check::dropck::iterate_over_potentially_unsafe_regions_in_type::h8c796fe6dd45f0c2MDa
  16:        0x10c2e7978 - check::dropck::iterate_over_potentially_unsafe_regions_in_type::h8c796fe6dd45f0c2MDa
  17:        0x10c2e7978 - check::dropck::iterate_over_potentially_unsafe_regions_in_type::h8c796fe6dd45f0c2MDa
  18:        0x10c2e6401 - check::dropck::check_safety_of_destructor_if_necessary::h889be3c0cfb82a13Wxa
  19:        0x10c314e5f - ast_util::walk_pat::walk_pat_::h10816250324308923423
  20:        0x10c3143e7 - check::regionck::visit_local::hb8711bd05838c05fc8c
  21:        0x10c310be8 - check::regionck::Rcx<'a, 'tcx>::visit_fn_body::h445a9a7dc920d6ffzNc
  22:        0x10c38ad4c - check::check_bare_fn::hbfad11d5a9f87954Tun
  23:        0x10c397747 - check::check_method_body::h120d7a33cef27a8dP6n
  24:        0x10c3888db - check::CheckItemBodiesVisitor<'a, 'tcx>.Visitor<'tcx>::visit_item::hf2b38fe3b992c9bcWrn
  25:        0x10c388d3e - check::CheckItemBodiesVisitor<'a, 'tcx>.Visitor<'tcx>::visit_item::hf2b38fe3b992c9bcWrn
  26:        0x10c44daba - check_crate::closure.38929
  27:        0x10c44754a - check_crate::hcd5b7e66feee2debsJC
  28:        0x10bc9f8af - driver::phase_3_run_analysis_passes::h3f61cd0eb3853b54tGa
  29:        0x10bc842d3 - driver::compile_input::h3d15d32af3f4b6bdQba
  30:        0x10bd3ff33 - run_compiler::h32c0e6c36780775b75b
  31:        0x10bd3d69a - boxed::F.FnBox<A>::call_box::h7208527504866586156
  32:        0x10bd3cbf7 - rt::unwind::try::try_fn::h4574368377636742306
  33:        0x10f1ff7a8 - rust_try_inner
  34:        0x10f1ff795 - rust_try
  35:        0x10bd3cecd - boxed::F.FnBox<A>::call_box::h14823742600371436653
  36:        0x10f17663d - sys::thread::Thread::new::thread_start::hefa4f0e4c64c9336Yjv
  37:     0x7fff902fe267 - _pthread_body
  38:     0x7fff902fe1e4 - _pthread_start

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-destructorsArea: Destructors (`Drop`, …)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