Skip to content

NLL promotes arbitrary code to be evaluated by miri if the result is unused #53606

@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 ${timeout} "$@" 

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions