Skip to content

generated call to core::fmt::Arguments::new_const fails to constant fold #128709

Description

@lolbinarycat

normal code:

pub fn main() {
    println!("hello");
}

code that should be equivalent, but is actually more efficient

#![feature(print_internals)]
#![feature(const_fmt_arguments_new)]

pub fn main() {
    ::std::io::_print(const { format_args!("hello\n") }); 
}

godbolt link for asm comparison

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-fmtArea: `core::fmt`C-optimizationCategory: An issue highlighting optimization opportunities or PRs implementing suchT-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