Skip to content

ICE:cannot relate bound region #17165

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

Closed
hebiyan opened this issue Sep 11, 2014 · 6 comments
Closed

ICE:cannot relate bound region #17165

hebiyan opened this issue Sep 11, 2014 · 6 comments
Labels
A-lifetimes Area: Lifetimes / regions E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@hebiyan
Copy link

hebiyan commented Sep 11, 2014

'rustc -v' output:
rustc 0.12.0-pre (641b1980a 2014-09-09 04:26:18 +0000)

os:
Mac OS X 10.9.4

'uname -a' output:

Darwin server.gideon001.private 13.3.0 Darwin Kernel Version 13.3.0: Tue Jun  3 21:27:35 PDT 2014; root:xnu-2422.110.17~1/RELEASE_X86_64 x86_64

code:

fn main () {
    let addf: <'r>|int|:'r -> Box<|int|:'r -> int> = 
        |n:int|  {box |m:int| -> int {n + m }};

    println!("{}", (*addf(2))(3));
}

RUST_BACKTRACE=1 rustc output:

cl.rs:4:9: 4:47 error: internal compiler error: cannot relate bound region: ReLateBound (10, BrNamed (syntax::ast::DefId{krate: 0u32, node: 26u32}, 'r)) <= ReInfer (0)
cl.rs:4         |n:int|  {box |m:int| -> int {n + m }};
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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>', /Users/gideon/tools/rust/rust/src/libsyntax/ast_util.rs:776

stack backtrace:
   1:        0x110d45925 - rt::backtrace::imp::write::hc34efde930f36017Lhr
   2:        0x110d48c61 - failure::on_fail::h3bc40b5494fc9081Fyr
   3:        0x110ffba35 - unwind::begin_unwind_inner::h82cdbb3cd9ec0b01b0d
   4:        0x1103c2c6a - unwind::begin_unwind::h3453961218879215225
   5:        0x1103c2be5 - diagnostic::SpanHandler::span_bug::h1b86fed0ce30aee8YaF
   6:        0x10d8e49c7 - driver::session::Session::span_bug::h64074688fe14108d1IE
   7:        0x10de03e21 - middle::typeck::infer::region_inference::RegionVarBindings<'a, 'tcx>::make_subregion::h60507627917bb1c6jUc
   8:        0x10de1348f - middle::typeck::infer::sub::Sub<'f, 'tcx>.Combine<'tcx>::regions::h8af2cb6ad62249fefAf
   9:        0x10de13115 - middle::typeck::infer::sub::Sub<'f, 'tcx>.Combine<'tcx>::contraregions::hd6337c74f4ce1730Fzf
  10:        0x10ddb3cc5 - middle::typeck::infer::sub::Sub<'f, 'tcx>.Combine<'tcx>::tys::h4ff6780852b0589dNIf
  11:        0x10ddb1750 - middle::typeck::infer::coercion::Coerce<'f, 'tcx>::subtype::h3ece1fef911cabeeMn6
  12:        0x10ddb150c - middle::typeck::infer::coercion::Coerce<'f, 'tcx>::coerce_borrowed_fn::h969fec4a98356fe5h76
  13:        0x10ddb12e1 - middle::typeck::infer::coercion::Coerce<'f, 'tcx>::tys::closure.134706
  14:        0x10ddae4c4 - middle::typeck::infer::coercion::Coerce<'f, 'tcx>::unpack_actual_value::h948805772714329226
  15:        0x10ddadf79 - middle::typeck::infer::coercion::Coerce<'f, 'tcx>::tys::hb38bc87449217190If6
  16:        0x10de21648 - middle::typeck::infer::mk_coercety::closure.136784
  17:        0x10de212d0 - middle::typeck::infer::InferCtxt<'a, 'tcx>::commit_if_ok::closure.136776
  18:        0x10de21147 - middle::typeck::infer::InferCtxt<'a, 'tcx>::commit_unconditionally::h11340877979196374766
  19:        0x10dd4c305 - middle::typeck::infer::mk_coercety::hc4de794711c1d371Bgi
  20:        0x10dcf3565 - middle::typeck::check::FnCtxt<'a, 'tcx>::mk_assignty::h476edb1f6652be36yTY
  21:        0x10dcf33bd - middle::typeck::check::demand::coerce::h7c31b43dc8bb8462mxT
  22:        0x10dd5bc6a - middle::typeck::check::check_expr_coercable_to_type::closure.133678
  23:        0x10dd543ef - middle::typeck::check::check_expr_with_unifier::h6d5b3dc20f73aee9F3Z
  24:        0x10dda8474 - middle::typeck::check::check_decl_local::h5a935f957a31a756w61
  25:        0x10dda86c8 - middle::typeck::check::check_stmt::h372cfadc360693a0E81
  26:        0x10dd16662 - middle::typeck::check::check_block_with_expected::h22fe190983b7dfe2Rc2
  27:        0x10dd11d58 - middle::typeck::check::check_fn::hb51a901c65978ab9OLW
  28:        0x10dd112c9 - middle::typeck::check::check_bare_fn::h3d757c7ca707a846sAW
  29:        0x10dd09f8d - middle::typeck::check::check_item::h13627fd0014f8964mgX
  30:        0x10dd110ad - middle::typeck::check::check_item_types::h56a54a78d1f84672rzW
  31:        0x10d740b86 - util::common::time::h6774358895183961009
  32:        0x10df221f8 - middle::typeck::check_crate::h79d3f57e66bdaf51xgp
  33:        0x10dfde766 - driver::driver::phase_3_run_analysis_passes::h821dbd7bfc00cf7e6YD
  34:        0x10dfd94b2 - driver::driver::compile_input::h7817fa347452fba6JKD
  35:        0x10e064a0a - driver::run_compiler::ha557cce5753da6b01CH
  36:        0x10e062e16 - driver::main_args::closure.148073
  37:        0x10d758d6b - task::TaskBuilder<S>::try_future::closure.100105
  38:        0x10d758c73 - task::TaskBuilder<S>::spawn_internal::closure.100076
  39:        0x110bcd6cd - task::spawn_opts::closure.8474
  40:        0x11105e1cc - rust_try_inner
  41:        0x11105e1b6 - rust_try
  42:        0x110ff8ed7 - unwind::try::h083fe44507311ba0lOd
  43:        0x110ff8d4c - task::Task::run::h91e4f0552d7b8b33L0c
  44:        0x110bcd522 - task::spawn_opts::closure.8413
  45:        0x110ffa97a - thread::thread_start::h4f6e4374d46c14dbSld
  46:     0x7fff8bf53899 - _pthread_body
  47:     0x7fff8bf5372a - _pthread_struct_init
@sfackler sfackler added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ A-lifetimes Area: Lifetimes / regions labels Sep 11, 2014
@ghost ghost added E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. and removed E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. labels Nov 19, 2014
@Gankra
Copy link
Contributor

Gankra commented Dec 22, 2014

I think I'm getting this ICE on the latest nightly in collect-rs:

unused manifest key: profile.build.debug
       Fresh traverse v0.0.2
   Compiling collect v0.0.6 (file:///C:/users/alexis/documents/github/collect-rs)
     Running `rustc C:\users\alexis\documents\github\collect-rs\src\lib.rs --crate-name collect --crate-type lib --cfg ndebug --test -C metadata=507ed9788c885314 -C extra-filename=-507ed9788c885314 --out-dir C:\users\alexis\documents\github\collect-rs\target --emit=dep-info,link -L C:\users\alexis\documents\github\collect-rs\target -L C:\users\alexis\documents\github\collect-rs\target\deps --extern traverse=C:\users\alexis\documents\github\collect-rs\target\deps/libtraverse-c0a1cc9151073bab.rlib`
C:\users\alexis\documents\github\collect-rs\src\tree\set.rs:1036:5: 1042:6 error: internal compiler error: cannot relate bound region: ReLateBound(DebruijnIndex { depth: 1 }, BrAnon(0)) <= ReLateBound(DebruijnIndex { depth: 2 }, BrAnon(0))
C:\users\alexis\documents\github\collect-rs\src\tree\set.rs:1036     impl<'a, 'b> FnMut(&int) -> bool for Counter<'a, 'b> {
C:\users\alexis\documents\github\collect-rs\src\tree\set.rs:1037         extern "rust-call" fn call_mut(&mut self, (&x,): (&int,)) -> bool {
C:\users\alexis\documents\github\collect-rs\src\tree\set.rs:1038             assert_eq!(x, self.expected[*self.i]);
C:\users\alexis\documents\github\collect-rs\src\tree\set.rs:1039             *self.i += 1;
C:\users\alexis\documents\github\collect-rs\src\tree\set.rs:1040             true
C:\users\alexis\documents\github\collect-rs\src\tree\set.rs:1041         }
                                                                 ...
note: the compiler unexpectedly panicked. 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
thread 'rustc' panicked at 'Box<Any>', C:\bot\slave\nightly-win-64\build\src\libsyntax\diagnostic.rs:123

stack backtrace:
   1:         0x69bef7f8 - sys::backtrace::write::h5b0ba28ad71857afeQt
   2:         0x69c021e9 - rt::unwind::register::h91aefd9b472076aecGz
   3:         0x69b82fcb - rt::unwind::begin_unwind_inner::h04b772eae7a7fc7bJDz
   4:         0x6f8acd56 - diagnostic::SpanHandler::span_bug::h90408fcd1499494fwZF
   5:         0x6f8acd00 - diagnostic::SpanHandler::span_bug::h90408fcd1499494fwZF
   6:           0x972a31 - middle::infer::region_inference::RegionVarBindings<$u{27}a$C$$u{20}$u{27}tcx$GT$::make_subregion::h2d032b24a1882941bAw
   7:           0x90f621 - middle::infer::region_inference::RegionVarBindings<$u{27}a$C$$u{20}$u{27}tcx$GT$::make_eqregion::h2d032b24a1882941zzw
   8:           0x90f4a3 - middle::infer::equate::Equate<$u{27}f$C$$u{20}$u{27}tcx$GT$.Combine$LT$$u{27}tcx$GT$::regions::hc467de7375d80198Akr
   9:           0x908f8f - middle::infer::equate::Equate<$u{27}f$C$$u{20}$u{27}tcx$GT$.Combine$LT$$u{27}tcx$GT$::tys::h912a5dd2b206dbe1Frr
  10:           0x921c09 - middle::ty::mk_unboxed_closure::hcc6ac3bf2616fcf0sv2
  11:           0x9095c5 - middle::infer::equate::Equate<$u{27}f$C$$u{20}$u{27}tcx$GT$.Combine$LT$$u{27}tcx$GT$::tys::h912a5dd2b206dbe1Frr
  12:           0x91f43a - util::ppaux::ty..BoundRegion.Repr<$u{27}tcx$GT$::repr::hbe9f644adb44adbbPbt
  13:           0x91efd3 - util::ppaux::ty..BoundRegion.Repr<$u{27}tcx$GT$::repr::hbe9f644adb44adbbPbt
  14:           0x91eca2 - util::ppaux::ty..BoundRegion.Repr<$u{27}tcx$GT$::repr::hbe9f644adb44adbbPbt
  15:           0x99113e - middle::infer::InferCtxt<$u{27}a$C$$u{20}$u{27}tcx$GT$::sub_trait_refs::h390adbc09a3b494bgyB
  16:           0xa00c4e - middle::ty::TraitRef<$u{27}tcx$GT$...std..cmp..PartialEq::eq::h543edb6d2ba7d3b3ruZ
  17:           0xa0ca51 - middle::ty::GenericBounds<$u{27}tcx$GT$::is_empty::hc31f5ae763726d73PQ1
  18:           0xa07660 - middle::traits::select::Candidate<$u{27}tcx$GT$.Repr$LT$$u{27}tcx$GT$::repr::h48b108f0ecd54c0dbPS
  19:           0x9f8055 - middle::ty::TraitRef<$u{27}tcx$GT$.RegionEscape::has_regions_escaping_depth::he874f51e3eb2d51fZQ7
  20:           0x9f4b4c - middle::traits::select::SelectionContext<$u{27}cx$C$$u{20}$u{27}tcx$GT$::select::hf1da19fa1e7dadc9ZoQ
  21:           0x9ee4cd - middle::traits::select::SelectionContext<$u{27}cx$C$$u{20}$u{27}tcx$GT$::new::hd2f65bc2e1895228nnQ
  22:           0x8c7a83 - middle::traits::fulfill::FulfillmentContext<$u{27}tcx$GT$::select_all_or_error::hcc757e1ded501152KKP
  23:         0x6d4db274
  24:         0x6d54dbe0 - check::method::CandidateSource...std..cmp..PartialOrd::ge::he78261c7d2364bd3edi
  25:         0x6d552623 - check::wf::CheckTypeWellFormedVisitor<$u{27}ccx$C$$u{20}$u{27}tcx$GT$.Visitor$LT$$u{27}v$GT$::visit_item::h83ad74d1a29d2d8c58i
  26:         0x6d553f9f - check::wf::CheckTypeWellFormedVisitor<$u{27}ccx$C$$u{20}$u{27}tcx$GT$.Visitor$LT$$u{27}v$GT$::visit_item::h83ad74d1a29d2d8c58i
  27:         0x6d5526f6 - check::wf::CheckTypeWellFormedVisitor<$u{27}ccx$C$$u{20}$u{27}tcx$GT$.Visitor$LT$$u{27}v$GT$::visit_item::h83ad74d1a29d2d8c58i
  28:         0x6d553f9f - check::wf::CheckTypeWellFormedVisitor<$u{27}ccx$C$$u{20}$u{27}tcx$GT$.Visitor$LT$$u{27}v$GT$::visit_item::h83ad74d1a29d2d8c58i
  29:         0x6d5526f6 - check::wf::CheckTypeWellFormedVisitor<$u{27}ccx$C$$u{20}$u{27}tcx$GT$.Visitor$LT$$u{27}v$GT$::visit_item::h83ad74d1a29d2d8c58i
  30:         0x6d553f9f - check::wf::CheckTypeWellFormedVisitor<$u{27}ccx$C$$u{20}$u{27}tcx$GT$.Visitor$LT$$u{27}v$GT$::visit_item::h83ad74d1a29d2d8c58i
  31:         0x6d5526f6 - check::wf::CheckTypeWellFormedVisitor<$u{27}ccx$C$$u{20}$u{27}tcx$GT$.Visitor$LT$$u{27}v$GT$::visit_item::h83ad74d1a29d2d8c58i
  32:         0x6d8273db - check_crate::hd1761d8b5c95808dQZy
  33:         0x6d822422 - check_crate::hd1761d8b5c95808dQZy
  34:         0x70b227ae - driver::phase_3_run_analysis_passes::h50b942faf81eb47bIta
  35:         0x70b03695 - driver::compile_input::hd01226bf772688afvba
  36:         0x70ca3e95 - run::h9cdc49dc8c011aeedYb
  37:         0x70ca05b9 - run::h9cdc49dc8c011aeedYb
  38:         0x69c6648c - rust_try
  39:         0x69c66469 - rust_try
  40:         0x70ca0d0f - run::h9cdc49dc8c011aeedYb
  41:         0x69bf4ee7 - sys::tcp::TcpListener::bind::hb1b42652ff0a60d9Fqw
  42:     0x7ffcd28616ad - BaseThreadInitThunk

Could not compile `collect`.

Caused by:
  Process didn't exit successfully: `rustc C:\users\alexis\documents\github\collect-rs\src\lib.rs --crate-name collect --crate-type lib --cfg ndebug --test -C metadata=507ed9788c885314 -C extra-filename=-507ed9788c885314 --out-dir C:\users\alexis\documents\github\collect-rs\target --emit=dep-info,link -L C:\users\alexis\documents\github\collect-rs\target -L C:\users\alexis\documents\github\collect-rs\target\deps --extern traverse=C:\users\alexis\documents\github\collect-rs\target\deps/libtraverse-c0a1cc9151073bab.rlib` (status=101)

This is of course hidden behind a second ICE about for loop debug info. Good way to start the day.

Haven't had a chance to creduce.

@Gankra
Copy link
Contributor

Gankra commented Dec 22, 2014

Small code:

#![feature(unboxed_closures)]

struct Counter<'a, 'b> {
    i: &'a mut uint,
    expected: &'b [int],
}

impl<'a, 'b> FnMut(&int) -> bool for Counter<'a, 'b> {
    extern "rust-call" fn call_mut(&mut self, (&x,): (&int,)) -> bool {
        assert_eq!(x, self.expected[*self.i]);
        *self.i += 1;
        true
    }
}

fn main() {}

@Gankra
Copy link
Contributor

Gankra commented Dec 22, 2014

Tiny code:

struct Counter;

impl FnMut(&int) -> bool for Counter {
    extern "rust-call" fn call_mut(&mut self, (&x,): (&int,)) -> bool {}
}

Run by cargo test with this as main.rs.

Using rustc 0.13.0-nightly (34d680009 2014-12-22 00:12:47 +0000)

@Gankra
Copy link
Contributor

Gankra commented Dec 22, 2014

@nikomatsakis Showed me that it was actually #19982

@tamird
Copy link
Contributor

tamird commented Dec 23, 2014

Crazy, this ICEs with cargo test, but not with cargo build.

@Gankra
Copy link
Contributor

Gankra commented Dec 25, 2014

It ICEs only on test because the snippet I posted is is missing a fn main() {} declaration, and the compiler errors out there first.

@bors bors closed this as completed in 3a93bdb Mar 17, 2015
lnicola pushed a commit to lnicola/rust that referenced this issue Jun 23, 2024
minor: Remove Changelog: XXX title from Github release notes

Fixes rust-lang#16455
Closes rust-lang#17165
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lifetimes Area: Lifetimes / regions E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

4 participants