Skip to content

ICE with unboxed closures #18238

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
netvl opened this issue Oct 22, 2014 · 1 comment · Fixed by #18337
Closed

ICE with unboxed closures #18238

netvl opened this issue Oct 22, 2014 · 1 comment · Fixed by #18337
Labels
A-closures Area: Closures (`|…| { … }`) I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@netvl
Copy link
Contributor

netvl commented Oct 22, 2014

This very simple program:

#![feature(unboxed_closures)]

fn make_closure() {
    let mut acc = 0.0;
    box move |&mut: i: f64| {
        acc += i; 
        acc
    };
}

fn main() {}

crashes the compiler with the following error:

error: internal compiler error: unexpected failure
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 'assertion failed: `(left == right) && (right == left)` (left: `McInherited`, right: `McDeclared`)', /home/rustbuild/src/rust-buildbot/slave/nightly-linux/build/src/librustc/middle/borrowck/check_loans.rs:830

stack backtrace:
   1:     0x7fa57c579860 - rt::backtrace::imp::write::he1d07ecb5c09ef73Ocq
   2:     0x7fa57c57c990 - failure::on_fail::h76802abdf02d9229byq
   3:     0x7fa580ad6ac0 - unwind::begin_unwind_inner::hb92ca1198fd23157Yxd
   4:     0x7fa580ad6600 - unwind::begin_unwind_fmt::h5e0607d8f87b6529qvd
   5:     0x7fa58130f300 - middle::borrowck::check_loans::CheckLoanCtxt<'a, 'tcx>.euv..Delegate::mutate::h8f1bc217b6ff75a2g5f
   6:     0x7fa58131e410 - middle::expr_use_visitor::ExprUseVisitor<'d, 't, TYPER>::mutate_expr::h3610340025408968702
   7:     0x7fa581317810 - middle::expr_use_visitor::ExprUseVisitor<'d, 't, TYPER>::walk_expr::h7878549864954814134
   8:     0x7fa58131d550 - middle::expr_use_visitor::ExprUseVisitor<'d, 't, TYPER>::consume_expr::h1441929135172233355
   9:     0x7fa581317410 - middle::expr_use_visitor::ExprUseVisitor<'d, 't, TYPER>::walk_block::h1855207539966477442
  10:     0x7fa581317810 - middle::expr_use_visitor::ExprUseVisitor<'d, 't, TYPER>::walk_expr::h7878549864954814134
  11:     0x7fa58131d550 - middle::expr_use_visitor::ExprUseVisitor<'d, 't, TYPER>::consume_expr::h1441929135172233355
  12:     0x7fa581317410 - middle::expr_use_visitor::ExprUseVisitor<'d, 't, TYPER>::walk_block::h1855207539966477442
  13:     0x7fa581310be0 - middle::borrowck::check_loans::check_loans::h79a9c285140c1595y8f
  14:     0x7fa581348ca0 - middle::borrowck::borrowck_fn::h0540d52a3b7fb27b1Tj
  15:     0x7fa58134a260 - visit::walk_expr::h4135272309649785660
  16:     0x7fa58134a780 - visit::walk_block::h14476049905583047865
  17:     0x7fa581348ca0 - middle::borrowck::borrowck_fn::h0540d52a3b7fb27b1Tj
  18:     0x7fa58134abe0 - visit::walk_item::h8478938835045244904
  19:     0x7fa581349580 - middle::borrowck::check_crate::h86fc9e47401bae40MMj
  20:     0x7fa581139c90 - util::common::time::h13858161161014839769
  21:     0x7fa5819ea1b0 - driver::driver::phase_3_run_analysis_passes::h04ee49849c18416b69z
  22:     0x7fa5819e5630 - driver::driver::compile_input::hd4ba06b74713782dRQz
  23:     0x7fa581a70350 - driver::run_compiler::h014078c5025dc703vDD
  24:     0x7fa581a70200 - driver::run::closure.145641
  25:     0x7fa581153b20 - task::TaskBuilder<S>::try_future::closure.103153
  26:     0x7fa581153900 - task::TaskBuilder<S>::spawn_internal::closure.103124
  27:     0x7fa580e20740 - task::NativeSpawner.Spawner::spawn::closure.8435
  28:     0x7fa580b2fd10 - rust_try_inner
  29:     0x7fa580b2fd00 - rust_try
  30:     0x7fa580ad4380 - unwind::try::hdee5a3b0466d278eGmd
  31:     0x7fa580ad4200 - task::Task::run::h27d9c4b6d2601e28kCc
  32:     0x7fa580e20480 - task::NativeSpawner.Spawner::spawn::closure.8375
  33:     0x7fa580ad5ad0 - thread::thread_start::h5e6e53ee3afb8775vWc
  34:     0x7fa57b924060 - start_thread
  35:     0x7fa5807a5489 - __clone
  36:                0x0 - <unknown>

Without move it works.

This seems to be a regression, as this program does work with Rust nightly released at 2014-10-14.

@sfackler sfackler added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ A-closures Area: Closures (`|…| { … }`) labels Oct 22, 2014
@bkoropoff
Copy link
Contributor

This is probably my fault, taking a look

bkoropoff added a commit to bkoropoff/rust that referenced this issue Oct 26, 2014
- Correctly categorize env pointer deref for `FnMut` as declared
  rather than inherited.  This fixes an assert in borrowck.
  Closes rust-lang#18238
- Categorize env pointer deref as mutable only if the closure is
  `FnMut` *and* the original variable is declared mutable.  This
  disallows capture-by-value `FnMut` closures from mutating captured
  variables that aren't declared mutable.  This is a difference
  from the equivalent desugared code which would permit it, but
  it is consistent with the behavior of procs.  Closes rust-lang#18335
- Avoid computing info about the env pointer if there isn't one.
bkoropoff added a commit to bkoropoff/rust that referenced this issue Oct 26, 2014
lnicola pushed a commit to lnicola/rust that referenced this issue Oct 17, 2024
fix: Fix `prettify_macro_expansion()` when the node isn't the whole file

Fixes rust-lang#18238.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-closures Area: Closures (`|…| { … }`) I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants