Skip to content

"cannot relate bound region" ICE caused by Drop implementation #24086

Closed
@japaric

Description

@japaric

STR:

pub struct Registry<'a> {
    listener: &'a mut (),
}

pub struct Listener<'a> {
    pub announce: Option<Box<FnMut(&mut Registry) + 'a>>,
    pub remove: Option<Box<FnMut(&mut Registry) + 'a>>,
}

#[cfg(ice)]
impl<'a> Drop for Registry<'a> {
    fn drop(&mut self) {}
}

fn main() {
    let mut registry_listener = Listener {
        announce: None,
        remove: None,
    };
}

Backtrace

$ RUST_BACKTRACE=1 rustc --cfg ice ice.rs
ice.rs:16:9: 16:30 error: internal compiler error: cannot relate bound region: ReScope(Misc(44)) <= ReLateBound(DebruijnIndex { depth: 1 }, BrAnon(1))
ice.rs:16     let mut registry_listener = Listener {
                  ^~~~~~~~~~~~~~~~~~~~~
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>', /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libsyntax/diagnostic.rs:130

stack backtrace:
   1:     0x7f60f3bc6708 - sys::backtrace::write::he3059e6bc8c10ccbZGC
   2:     0x7f60f3bf1ad7 - panicking::on_panic::h4b318d56839ed7af9TI
   3:     0x7f60f3b297e3 - rt::unwind::begin_unwind_inner::hbbbefb3640cc608bhzI
   4:     0x7f60f0ef1efd - rt::unwind::begin_unwind::h10258443395685540836
   5:     0x7f60f0ef1ea3 - diagnostic::SpanHandler::span_bug::he0c1a59febe6c207YmB
   6:     0x7f60f1a295ee - middle::infer::region_inference::RegionVarBindings<'a, 'tcx>::make_subregion::h87dd23f538f1eeeajjv
   7:     0x7f60f1a489bf - middle::infer::mk_subr::hb7d1db897203c304KWy
   8:     0x7f60f280e4dd - check::regionck::type_must_outlive::h1e6fc599a86efdb6l3e
   9:     0x7f60f280bfd4 - check::dropck::iterate_over_potentially_unsafe_regions_in_type::h7f75223739c50980IDa
  10:     0x7f60f280c25e - check::dropck::iterate_over_potentially_unsafe_regions_in_type::h7f75223739c50980IDa
  11:     0x7f60f280a6af - check::dropck::check_safety_of_destructor_if_necessary::had92a0dd251d07deSxa
  12:     0x7f60f28551a3 - ast_util::walk_pat::walk_pat_::h16792876270867621303
  13:     0x7f60f2854885 - check::regionck::constrain_bindings_in_pat::hffae1d6859777115nHd
  14:     0x7f60f28545f6 - check::regionck::visit_local::h0334da4335b8c86bUGd
  15:     0x7f60f284ebc5 - check::regionck::Rcx<'a, 'tcx>::visit_fn_body::hf9bf452987e31f45amd
  16:     0x7f60f28e98f1 - check::check_bare_fn::h3bd8f9ddb42906aevPn
  17:     0x7f60f28e33d4 - check::check_item::h9d147ebfae788c9cg8n
  18:     0x7f60f29baec6 - check_crate::closure.36252
  19:     0x7f60f29b5413 - check_crate::hf86b00a9a711df871oC
  20:     0x7f60f42465ad - driver::phase_3_run_analysis_passes::h7afb182e7d24bba2gGa
  21:     0x7f60f422a405 - driver::compile_input::hd7743659db68d680Qba
  22:     0x7f60f42e1875 - run_compiler::h8e4dca3e7b3dd900S4b
  23:     0x7f60f42df18d - boxed::F.FnBox<A>::call_box::h4911342064246001069
  24:     0x7f60f42de6c9 - rt::unwind::try::try_fn::h1593779289253196900
  25:     0x7f60f3c6e288 - rust_try_inner
  26:     0x7f60f3c6e275 - rust_try
  27:     0x7f60f42de99b - boxed::F.FnBox<A>::call_box::h13493051407817611035
  28:     0x7f60f3bdcac1 - sys::thread::create::thread_start::hf5d11b227fd9319cruH
  29:     0x7f60ed9d1373 - start_thread
  30:     0x7f60f379c27c - __clone
  31:                0x0 - <unknown>

Version

rustc 1.0.0-nightly (f207ecbe0 2015-04-03) (built 2015-04-04)

cc @nikomatsakis @pnkfelix

Metadata

Metadata

Assignees

Labels

A-destructorsArea: Destructors (`Drop`, …)A-lifetimesArea: Lifetimes / regions

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions