Skip to content

Unboxed closure ICE: cannot relate bound region: ReInfer(16) <= ReLateBound #17816

Closed

Description

@tomjakubowski
#![feature(overloaded_calls, unboxed_closure_sugar, unboxed_closures)]

fn main() {
    struct Symbol<'a, F: Fn(Vec<&'a str>) -> &'a str> { function: F }
    let f = |&: x: Vec<&str>| -> &str "foobar";
    let sym = Symbol { function: f };
    (sym.function)(vec![]);
}
$ RUST_BACKTRACE=1 rustc  foo.rs 
foo.rs:7:5: 7:27 error: internal compiler error: cannot relate bound region: ReInfer(16) <= ReLateBound(33, BrAnon(0))
foo.rs:7     (sym.function)(vec![]);
             ^~~~~~~~~~~~~~~~~~~~~~
note: the compiler hit an unexpected failure path. this is a bug.
note: we would appreciate a bug report: http://doc.rust-lang.org/complement-bugreport.html
note: run with `RUST_BACKTRACE=1` for a backtrace
task 'rustc' failed at 'Box<Any>', /home/tom/src/rust/rust/src/libsyntax/diagnostic.rs:113

stack backtrace:
   1:     0x7f85d03d5800 - rt::backtrace::imp::write::hbbd9bf4ceb840fc0KAq
   2:     0x7f85d03be190 - failure::on_fail::hc28b027ccb4467c1cWq
   3:     0x7f85d0bc3c90 - unwind::begin_unwind_inner::h110735be165faa3fIxd
   4:     0x7f85cedcddc0 - unwind::begin_unwind::h293010665865661344
   5:     0x7f85cedcdd50 - diagnostic::SpanHandler::span_bug::h2ea40ca72e774bb3GMF
   6:     0x7f85d16249b0 - driver::session::Session::span_bug::hdab774e2397de37fPtx
   7:     0x7f85d1202bd0 - middle::typeck::infer::region_inference::RegionVarBindings<'a, 'tcx>::make_subregion::hdc4568b6616a2a24L47
   8:     0x7f85d11df440 - middle::typeck::infer::region_inference::RegionVarBindings<'a, 'tcx>::make_eqregion::h4aa77277dfe179e5a47
   9:     0x7f85d11df040 - middle::typeck::infer::equate::Equate<'f, 'tcx>.Combine<'tcx>::regions::h21a863ae7fa5ec80KX3
  10:     0x7f85d11d9f30 - middle::typeck::infer::equate::Equate<'f, 'tcx>.Combine<'tcx>::tys::h35f4a7237a23cc5bX43
  11:     0x7f85d11e22d0 - middle::typeck::infer::combine::Combine::substs::h324391049216757114
  12:     0x7f85d11d9f30 - middle::typeck::infer::equate::Equate<'f, 'tcx>.Combine<'tcx>::tys::h35f4a7237a23cc5bX43
  13:     0x7f85d11e4a00 - middle::typeck::infer::combine::super_tys::closure.158023
  14:     0x7f85d11e4730 - iter::Iterator::collect::h9565269870161006725
  15:     0x7f85d11d9f30 - middle::typeck::infer::equate::Equate<'f, 'tcx>.Combine<'tcx>::tys::h35f4a7237a23cc5bX43
  16:     0x7f85d1760d40 - middle::typeck::infer::combine::Combine::substs::h15550467844381804152
  17:     0x7f85d176b550 - middle::typeck::infer::InferCtxt<'a, 'tcx>::sub_trait_refs::hce3459e301875ec2Drd
  18:     0x7f85d13a63c0 - middle::traits::select::SelectionContext<'cx, 'tcx>::confirm::h67d954f9925112deqZW
  19:     0x7f85d1398700 - middle::traits::select::SelectionContext<'cx, 'tcx>::select::h1e9ce11f39286d16CtV
  20:     0x7f85d1397120 - middle::traits::fulfill::FulfillmentContext::select_where_possible::h301e00b483f5538598U
  21:     0x7f85d11b6ff0 - middle::typeck::check::vtable2::select_fcx_obligations_where_possible::h32e182d4cde2e439l9K
  22:     0x7f85d1a1aaf0 - middle::typeck::check::check_argument_types::h5d391020df5cb75fEeV
  23:     0x7f85d1a1cf30 - middle::typeck::check::check_expr_with_unifier::he6beb0ddba7fb81elNV
  24:     0x7f85d1a6a430 - middle::typeck::check::check_decl_local::h3dbf38cc6fab7488QRX
  25:     0x7f85d1a6a620 - middle::typeck::check::check_stmt::h56381332213a7caeYTX
  26:     0x7f85d19e6c30 - middle::typeck::check::check_block_with_expected::h4c36c485fa96748dbYX
  27:     0x7f85d1a1cf30 - middle::typeck::check::check_expr_with_unifier::he6beb0ddba7fb81elNV
  28:     0x7f85d1a1aaf0 - middle::typeck::check::check_argument_types::h5d391020df5cb75fEeV
  29:     0x7f85d1a1a060 - middle::typeck::check::check_method_argument_types::h58ec3324eba34260ScV
  30:     0x7f85d1a1cf30 - middle::typeck::check::check_expr_with_unifier::he6beb0ddba7fb81elNV
  31:     0x7f85d1a6a620 - middle::typeck::check::check_stmt::h56381332213a7caeYTX
  32:     0x7f85d19e6c30 - middle::typeck::check::check_block_with_expected::h4c36c485fa96748dbYX
  33:     0x7f85d19e2480 - middle::typeck::check::check_fn::hee24634b21a2885a2sS
  34:     0x7f85d19e2280 - middle::typeck::check::check_bare_fn::h6e806ee1bf2c7308aiS
  35:     0x7f85d19dd8b0 - middle::typeck::check::check_item::h51dfba04fcdcac33dKS
  36:     0x7f85d19e0cd0 - middle::typeck::check::check_item_types::hd3964d97cc4fc778khS
  37:     0x7f85d10a9190 - util::common::time::h11171893184677193938
  38:     0x7f85d1a70480 - middle::typeck::check_crate::ha819c660b3fa1ce7Xdk
  39:     0x7f85d1261d40 - driver::driver::phase_3_run_analysis_passes::ha3f2a6dccee8b431XKw
  40:     0x7f85d125ab60 - driver::driver::compile_input::hffa1c362c29e45e9Jrw
  41:     0x7f85d12bceb0 - driver::run_compiler::h72fc31697a8853f50hA
  42:     0x7f85d12bcd80 - driver::run::closure.180762
  43:     0x7f85d12ca670 - task::TaskBuilder<S>::try_future::closure.181584
  44:     0x7f85d12ca4e0 - task::TaskBuilder<S>::spawn_internal::closure.181576
  45:     0x7f85d23b0f20 - task::spawn_opts::closure.8955
  46:     0x7f85d0c32820 - rust_try_inner
  47:     0x7f85d0c32810 - rust_try
  48:     0x7f85d0bc3440 - unwind::try::he0499702d1c7d9dfqmd
  49:     0x7f85d0bbe150 - task::Task::run::h620c5fb327a4e3c14Bc
  50:     0x7f85d23b0ce0 - task::spawn_opts::closure.8893
  51:     0x7f85d0bc31e0 - thread::thread_start::haaa628b6babd0f08fWc
  52:     0x7f85cfe9e250 - start_thread
  53:     0x7f85d08813b9 - clone
  54:                0x0 - <unknown>

Seems related to #17545 but not sure if a dupe since the ReInfer and ReLateBound are on opposite sides of the <=.

Activity

  1. bkoropoff commented on Oct 13, 2014

    @bkoropoff
    Contributor

    Smaller test case:

    #![feature(overloaded_calls, unboxed_closures)]
    
    fn main() {
        let f = |:| -> &str "";
        f();
    }
  2. bkoropoff commented on Oct 13, 2014

    @bkoropoff
    Contributor

    I think the problem is that the &str return type is generating an anonymous ReLateBound region since none is specified explicitly, and this is leaking into a non-function-scope context where it doesn't belong. Specifying 'static manually fixes it, as does removing the return type annotation entirely so that a region inference variable is used instead.

    I suspect this will be fixed as a side effect of the work @nikomatsakis is doing with higher-rank trait lifetimes.

  3. japaric commented on Nov 19, 2014

    @japaric
    Contributor

    Both examples compile now that HRTB (#18993) has landed.

  4. added
    E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.
    on Nov 19, 2014
  5. added 3 commits that reference this issue on Dec 12, 2014
    20cbbff
    c59b9b7
  6. added a commit that references this issue on Aug 13, 2024
    937ef11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-closuresArea: Closures (`|…| { … }`)E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.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