Skip to content

format_args!() inlining/flattening allows for longer lifetimes #110769

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
m-ou-se opened this issue Apr 24, 2023 · 2 comments · Fixed by #110770
Closed

format_args!() inlining/flattening allows for longer lifetimes #110769

m-ou-se opened this issue Apr 24, 2023 · 2 comments · Fixed by #110770
Assignees
Labels
A-fmt Area: `core::fmt` C-bug Category: This is a bug. regression-from-stable-to-nightly Performance or correctness regression from stable to nightly.

Comments

@m-ou-se
Copy link
Member

m-ou-se commented Apr 24, 2023

Before #109999, this gave an error:

let f = format_args!("{}", "abc"); // error[E0716]: temporary value dropped while borrowed
dbg!(f);

But after #109999, that no longer gives an error.

Ideally it shouldn't give an error in any case, but that's a separate issue. Inlining/flattening format_args shouldn't change what compiles and what doesn't compile, so, for now, this still shouldn't compile.

@m-ou-se m-ou-se added C-bug Category: This is a bug. A-fmt Area: `core::fmt` labels Apr 24, 2023
@m-ou-se m-ou-se self-assigned this Apr 24, 2023
@m-ou-se
Copy link
Member Author

m-ou-se commented Apr 24, 2023

Luckily the fix is easy. We just need to make sure that any format_args!(…) with arguments still results in an expansion that involves borrowing a temporary.

@m-ou-se
Copy link
Member Author

m-ou-se commented Apr 24, 2023

Fix here: #110770

@oli-obk oli-obk added the regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. label May 9, 2023
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label May 9, 2023
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue May 9, 2023
Limit lifetime of format_args!() with inlined args.

Fixes rust-lang#110769
@bors bors closed this as completed in e4c8250 May 9, 2023
@apiraino apiraino removed the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label May 10, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-fmt Area: `core::fmt` C-bug Category: This is a bug. regression-from-stable-to-nightly Performance or correctness regression from stable to nightly.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants