Skip to content

--unpretty everybody_loops is not compatible with const fn. #43636

Closed
@kennytm

Description

@kennytm

Test case:

#![feature(const_fn)]
const fn foo() -> u32 {
    1
}
fn main() {
    foo();
}

everybody_loops (#19964) will generate this, as expected:

$ rustc -Z unstable-options --unpretty everybody_loops 1.rs
#![feature(const_fn)]
const fn foo() -> u32 { loop  { } }
fn main() { loop  { } }

However, loop is not supported in const fn, so this will produce E0019

$ rustc -Z unstable-options --unpretty everybody_loops 1.rs | rustc -
error[E0019]: constant function contains unimplemented expression type
 --> <anon>:3:25
  |
3 | const fn foo() -> u32 { loop  { } }
  |                         ^^^^^^^^^

error: aborting due to previous error

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)A-prettyArea: Pretty printing (including `-Z unpretty`)C-enhancementCategory: An issue proposing an enhancement or a PR with one.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