Skip to content

ICE: "global closures can't capture anything" #37550

Closed

Description

@aidanhs
#![feature(const_fn)]
fn main() {}
const fn x() {
    let t = true;
    let x = || t;
}

https://is.gd/JFNOLu

rustc 1.14.0-nightly (3f4408347 2016-10-27)
error: internal compiler error: unexpected panic

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

thread 'rustc' panicked at 'global closures can't capture anything', ../src/librustc_passes/consts.rs:587
note: Run with `RUST_BACKTRACE=1` for a backtrace.

(const fn tracking issue #24111)

Activity

  1. added
    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
    on Nov 3, 2016
  2. eddyb commented on Nov 12, 2016

    @eddyb
    Contributor

    This sounds like a pass ordering issue, MIR check passes should come first (which would error about the variables).

  3. Mark-Simulacrum commented on Jan 5, 2017

    @Mark-Simulacrum
    Member

    Appears to be fixed on rustc 1.16.0-nightly (468227129 2017-01-03).

    error[E0016]: blocks in constant functions are limited to items and tail expressions
     --> test.rs:4:13
      |
    4 |     let t = true;
      |             ^^^^
    
    error[E0016]: blocks in constant functions are limited to items and tail expressions
     --> test.rs:5:13
      |
    5 |     let x = || t;
      |             ^^^^
    
    error: aborting due to 2 previous errors
    
  4. Mark-Simulacrum commented on May 19, 2017

    @Mark-Simulacrum
    Member

    E-needstest as per previous comment.

  5. added
    E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.
    on May 19, 2017
  6. added a commit that references this issue on May 26, 2017
    e988851
  7. added 2 commits that reference this issue on May 26, 2017
    076a422
    2c3aa91
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

    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