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: "global closures can't capture anything" #37550

Closed
aidanhs opened this issue Nov 3, 2016 · 3 comments · Fixed by #42230
Closed

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

aidanhs opened this issue Nov 3, 2016 · 3 comments · Fixed by #42230
Labels
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

@aidanhs
Copy link
Member

aidanhs commented Nov 3, 2016

#![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)

@TimNN TimNN added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Nov 3, 2016
@eddyb
Copy link
Member

eddyb commented Nov 12, 2016

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

@Mark-Simulacrum
Copy link
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

@Mark-Simulacrum
Copy link
Member

E-needstest as per previous comment.

@Mark-Simulacrum Mark-Simulacrum added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label May 19, 2017
venkatagiri added a commit to venkatagiri/rust that referenced this issue May 26, 2017
venkatagiri added a commit to venkatagiri/rust that referenced this issue May 26, 2017
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this issue May 26, 2017
frewsxcv added a commit to frewsxcv/rust that referenced this issue May 26, 2017
frewsxcv added a commit to frewsxcv/rust that referenced this issue May 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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

Successfully merging a pull request may close this issue.

4 participants