<p dir="auto">Source is very simple.</p>
<p dir="auto">//<br>
//<br>
static F : Box&lt; Fn(i32) -&gt; i32 &gt; = Box::new(move |x:i32| x);</p>
<p dir="auto">fn main() {<br>
}<br>
//<br>
//</p>
<p dir="auto">this code generate fault as follows.</p>
<p dir="auto">src\main.rs:2:34: 2:58 error: function calls in statics are limited to struct an<br>
d enum constructors [E0015]<br>
src\main.rs:2 static F : Box&lt;Fn(i32) -&gt; i32&gt; = Box::new(move |x:i32| x);<br>
^~~~~~~~~~~~~~~~~~~~~~~~<br>
error: internal compiler error: unexpected panic<br>
note: the compiler unexpectedly panicked. this is a bug.<br>
note: we would appreciate a bug report: <a href="https://github.com/rust-lang/rust/blob/m">https://github.com/rust-lang/rust/blob/m</a><br>
aster/CONTRIBUTING.md#bug-reports<br>
note: run with <code class="notranslate">RUST_BACKTRACE=1</code> for a backtrace<br>
thread 'rustc' panicked at 'assertion failed: self.mode == Mode::Var', C:/bot/sl<br>
ave/beta-dist-rustc-win-64/build/src/librustc\middle\check_const.rs:232</p>
<p dir="auto">Could not compile <code class="notranslate">hello_world</code>.</p>
<p dir="auto">To learn more, run the command again with --verbose.</p>
<p dir="auto">If I try to create a <code class="notranslate">const &amp;'static Fn(u32)</code>, I trigger an ICE:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="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
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'assertion failed: self.mode == Mode::Var', /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/librustc/middle/check_const.rs:254

error code 101"><pre class="notranslate"><code class="notranslate">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
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'assertion failed: self.mode == Mode::Var', /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/librustc/middle/check_const.rs:254

error code 101
</code></pre></div>
<p dir="auto">A small example code snippet is on the playpen (see <a href="http://is.gd/U0DmxV" rel="nofollow">http://is.gd/U0DmxV</a>):</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="const x: &amp;'static Fn() = &amp;|| println!(&quot;ICE here&quot;); //ICE

fn main() {}"><pre class="notranslate"><code class="notranslate">const x: &amp;'static Fn() = &amp;|| println!("ICE here"); //ICE

fn main() {}
</code></pre></div>