Skip to content

Temporaries not extended in format_args!() with only one placeholder #145880

@m-ou-se

Description

@m-ou-se

format_args!() lifetime-extends its arguments, except when it has only one placeholder:

let a = format_args!("{}", String::new());

dbg!(a); // ERROR


let b = format_args!("{}{}", String::new(), String::new());

dbg!(b); // OK

It should lifetime-extend the temporaries in both cases.

(Originally reported in #145422, see #145422 (comment).)

Metadata

Metadata

Assignees

Labels

A-fmtArea: `core::fmt`A-temporary-lifetime-extensionArea: temporary lifetime extensionC-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-libs-apiRelevant to the library API 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