NLL promotes arbitrary code to be evaluated by miri if the result is unused · Issue #53606 · rust-lang/rust (original) (raw)

Skip to content

Provide feedback

Saved searches

Use saved searches to filter your results more quickly

Sign up

@oli-obk

Description

@oli-obk

This takes a while to compile. I presume because loop {} needs to hit the loop checker in miri. Changing the _ to _foo or foo will immediately bail out due to &(loop{}, 1).1 not living for the 'static lifetime.

#![feature(nll)]

fn main() {

let _: &'static usize = &(loop {}, 1).1;

}

(Playground)

Errors:

   Compiling playground v0.0.1 (file:///playground)
warning: unreachable expression
 --> src/main.rs:4:40
  |
4 |     let _: &'static usize = &(loop {}, 1).1;
  |                                        ^
  |
  = note: #[warn(unreachable_code)] on by default

    Finished dev [unoptimized + debuginfo] target(s) in 1.09s
     Running `target/debug/playground`
/root/entrypoint.sh: line 8:     7 Killed                  timeout --signal=KILL <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mrow><mi>t</mi><mi>i</mi><mi>m</mi><mi>e</mi><mi>o</mi><mi>u</mi><mi>t</mi></mrow><mi mathvariant="normal">&quot;</mi></mrow><annotation encoding="application/x-tex">{timeout} &quot;</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord"><span class="mord mathnormal">t</span><span class="mord mathnormal">im</span><span class="mord mathnormal">eo</span><span class="mord mathnormal">u</span><span class="mord mathnormal">t</span></span><span class="mord">&quot;</span></span></span></span>@"