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

ICE: Relating argument and result lifetimes causes 'cannot relate bound' panic #25598

Closed
pierzchalski opened this issue May 19, 2015 · 0 comments
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@pierzchalski
Copy link
Contributor

I tried using higher-order lifetimes to bound the lifetimes of the returned value, got an ICE.

I tried this code:

trait T {}
impl T for () {}

pub fn closure<A>()
    -> Box<for<'a> Fn(&'a A) -> Box<T + 'a>>
{
    Box::new(|a: &A| {
        Box::new(())
    })
}

I expected to get, at worst, an error about the return box outliving a, and so requiring an explicit lifetime on a.

Instead, when compiled with rustc --crate-type=lib, I got an ICE:

test.rs:7:5: 9:7 error: internal compiler error: cannot relate bound region: ReScope(DestructionScope(24)) <= ReLateBound(DebruijnIndex { depth: 1 }, BrNamed(DefId { krate: 0, node: 13 }, 'a))
test.rs:7     Box::new(|a: &A| {
test.rs:8         Box::new(())
test.rs:9     })

Meta

rustc --version --verbose:

rustc 1.2.0-nightly (0cc99f9cc 2015-05-17) (built 2015-05-18)
binary: rustc
commit-hash: 0cc99f9cc9b59518f618a2c3f5011000e60f922e
commit-date: 2015-05-17
build-date: 2015-05-18
host: x86_64-unknown-linux-gnu
release: 1.2.0-nightly

Backtrace:

thread 'rustc' panicked at 'Box<Any>', /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libsyntax/diagnostic.rs:176

stack backtrace:
   1:     0x7f3db886f169 - sys::backtrace::write::h4052d6a51ba10f8105r
   2:     0x7f3db88770b9 - panicking::on_panic::h90cadee2464dd3b41Kw
   3:     0x7f3db8838192 - rt::unwind::begin_unwind_inner::ha0307b6be50a7723bqw
   4:     0x7f3db5c1405d - rt::unwind::begin_unwind::h1117890260308880149
   5:     0x7f3db5c13ff2 - diagnostic::SpanHandler::span_bug::h549aac4617510b93f6B
   6:     0x7f3db68f632a - middle::infer::region_inference::RegionVarBindings<'a, 'tcx>::make_subregion::h151182c416f4068dkfv
   7:     0x7f3db690ec2f - middle::infer::mk_subr::h45ed748f70b8a8516ty
   8:     0x7f3db7fb4f5f - check::regionck::type_must_outlive::h6330ac58585719f9Lue
   9:     0x7f3db7fb310a - check::dropck::iterate_over_potentially_unsafe_regions_in_type::ha5ed1d4709738abfMDa
  10:     0x7f3db7fb1c98 - check::dropck::check_safety_of_destructor_if_necessary::h5a4d6b86a46f915dWxa
  11:     0x7f3db7fe2ead - check::regionck::check_safety_of_rvalue_destructor_if_necessary::hb017fa90b92435b9bQd
  12:     0x7f3db7fdcc01 - check::regionck::visit_expr::h8e3f06644616962c7ad
  13:     0x7f3db7fdacfa - check::regionck::Rcx<'a, 'tcx>::visit_fn_body::h31bf9eff19779ab3zNc
  14:     0x7f3db805365d - check::check_bare_fn::h6168788eb123df8aTun
  15:     0x7f3db8051442 - check::CheckItemBodiesVisitor<'a, 'tcx>.Visitor<'tcx>::visit_item::hc2da6145fe079e8eWrn
  16:     0x7f3db811103a - check_crate::closure.38914
  17:     0x7f3db810aaac - check_crate::hf6e0aa588aa35f58hIC
  18:     0x7f3db8dbf29f - driver::phase_3_run_analysis_passes::h83b5112ae07f494ftGa
  19:     0x7f3db8da30cc - driver::compile_input::h0a7842b43c159d70Qba
  20:     0x7f3db8e59011 - run_compiler::hb2dfa1770188c5e175b
  21:     0x7f3db8e56862 - boxed::F.FnBox<A>::call_box::h10739628233630710986
  22:     0x7f3db8e55e29 - rt::unwind::try::try_fn::h12004866116241301408
  23:     0x7f3db88ef7c8 - rust_try_inner
  24:     0x7f3db88ef7b5 - rust_try
  25:     0x7f3db8e560c4 - boxed::F.FnBox<A>::call_box::h9242018289459349633
  26:     0x7f3db8875e51 - sys::thread::Thread::new::thread_start::he4baa243e39f5dd6ixv
  27:     0x7f3db2914373 - start_thread
  28:     0x7f3db84c827c - clone
  29:                0x0 - <unknown>

Other issues for the same panic:

I'm comparing against the first 4 results for searching for 'cannot relate bound', ordered from most recent to least:

I'm hoping that since #19009 was closed on 2014-12-19, it's safe to assume all the issues before that date aren't going to be relevant.

@pierzchalski pierzchalski changed the title ICE: Higher order lifetimes cause 'cannot relate bound' panic ICE: Relating argument and result lifetimes causes 'cannot relate bound' panic May 19, 2015
@steveklabnik steveklabnik added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label May 21, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

2 participants