Allow storing format_args!() in variable or const by m-ou-se · Pull Request #139135 · rust-lang/rust (original) (raw)

New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation25 Commits6 Checks6 Files changed

Conversation

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})

m-ou-se

Fixes #92698

Tracking issue for super let: #139076

This change allows:

let name = "world"; let f = format_args!("hello {name}!");

println!("{f}");

This will need an FCP.


This accidentally 'fixes' a bunch of tests/ui/codegen/equal-pointers-unequal/* tests. Those tests seem very fragile and should probably not depend on formatting implementation details.

This accidentally 'fixes' tests/ui/consts/const-eval/format.rs: it now allows any panic!() in a const fn. This might be expected. But we should then work on a better error when such a panic!() is const evaluated. (Now it reaches unreachable_unchecked().)

@m-ou-se m-ou-se added the S-blocked

Status: Blocked on something else such as an RFC or other implementation work.

label

Mar 30, 2025

@rustbot rustbot added A-tidy

Area: The tidy tool

S-waiting-on-review

Status: Awaiting review from the assignee but also interested parties.

T-bootstrap

Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

T-compiler

Relevant to the compiler team, which will review and decide on the PR/issue.

T-libs

Relevant to the library team, which will review and decide on the PR/issue.

labels

Mar 30, 2025

@m-ou-se m-ou-se added needs-fcp

This change is insta-stable, or significant enough to need a team FCP to proceed.

and removed T-compiler

Relevant to the compiler team, which will review and decide on the PR/issue.

T-bootstrap

Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

S-waiting-on-review

Status: Awaiting review from the assignee but also interested parties.

T-libs

Relevant to the library team, which will review and decide on the PR/issue.

A-tidy

Area: The tidy tool

labels

Mar 30, 2025

This was referenced

Mar 30, 2025

@rust-log-analyzer

This comment was marked as outdated.

@rustbot rustbot added A-tidy

Area: The tidy tool

T-bootstrap

Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

T-compiler

Relevant to the compiler team, which will review and decide on the PR/issue.

T-libs

Relevant to the library team, which will review and decide on the PR/issue.

labels

Mar 30, 2025

@rust-log-analyzer

This comment was marked as outdated.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@m-ou-se

The job x86_64-gnu-tools failed! Check out the build log: (web) (plain)
Click to see the possible cause of the failure (guessed by this bot)

FAILED TEST: tests/ui/manual_inspect.rs
command: CLIPPY_CONF_DIR="tests" RUSTC_ICE="0" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/x86_64-unknown-linux-gnu/release/clippy-driver" [..]

One day, clippy will not break when I make any change to format_args!(). That day is not today.

@rust-log-analyzer

This comment has been minimized.

@oli-obk

This comment was marked as resolved.

@m-ou-se

I've opened a separate issue for the panic discussion: #139621

@bors

@rustbot rustbot added the T-bootstrap

Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

label

Apr 22, 2025

@m-ou-se

This makes it posisble to do:

let f = format_args!("Hello, {name}!");

@m-ou-se

We can now just make new_v1_formatted an unsafe fn.

@m-ou-se

@m-ou-se

@m-ou-se

These tests rely on internal implementation details of format_args!(), which have changed now.

@rust-log-analyzer

This comment has been minimized.

@m-ou-se

@m-ou-se m-ou-se added T-libs-api

Relevant to the library API team, which will review and decide on the PR/issue.

and removed T-bootstrap

Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

T-libs

Relevant to the library team, which will review and decide on the PR/issue.

labels

Apr 22, 2025

@bors

@m-ou-se

Closing this in favor of a slightly improved implementation without the const issues discussed above: #140748

bors added a commit to rust-lang-ci/rust that referenced this pull request

May 7, 2025

@bors

Allow storing format_args!() in variable

Fixes rust-lang#92698

Tracking issue for super let: rust-lang#139076

This change allows:

let name = "world";
let f = format_args!("hello {name}!");

println!("{f}");

This will need an FCP.

This implementation makes use of super let, which is unstable and might not exist in the future in its current form. However, it is entirely reasonable to assume future Rust will always have a way of expressing temporary lifetimes like this, since the (stable) pin!() macro needs this. (This was also the motivation for merging rust-lang#139114.)

[!NOTE] This PR causes many subtle changes in diagnostics output. Most of those are good. Some of those are bad. I've collected all the bad ones in the last commit. Those still need fixing. Marking this PR as draft.

(This is a second version of rust-lang#139135)

bors added a commit that referenced this pull request

Jun 19, 2025

@bors

Allow storing format_args!() in variable

Fixes #92698

Tracking issue for super let: #139076

Tracking issue for format_args: #99012

This change allows:

let name = "world";
let f = format_args!("hello {name}!"); // New: Store format_args!() for later!

println!("{f}");

This will need an FCP.

This implementation makes use of super let, which is unstable and might not exist in the future in its current form. However, it is entirely reasonable to assume future Rust will always have a way of expressing temporary lifetimes like this, since the (stable) pin!() macro needs this too. (This was also the motivation for merging #139114.)

(This is a second version of #139135)

github-actions bot pushed a commit to rust-lang/miri that referenced this pull request

Jun 20, 2025

@bors

Allow storing format_args!() in variable

Fixes rust-lang/rust#92698

Tracking issue for super let: rust-lang/rust#139076

Tracking issue for format_args: rust-lang/rust#99012

This change allows:

let name = "world";
let f = format_args!("hello {name}!"); // New: Store format_args!() for later!

println!("{f}");

This will need an FCP.

This implementation makes use of super let, which is unstable and might not exist in the future in its current form. However, it is entirely reasonable to assume future Rust will always have a way of expressing temporary lifetimes like this, since the (stable) pin!() macro needs this too. (This was also the motivation for merging rust-lang/rust#139114.)

(This is a second version of rust-lang/rust#139135)

github-actions bot pushed a commit to rust-lang/rustc-dev-guide that referenced this pull request

Jun 23, 2025

@bors

Allow storing format_args!() in variable

Fixes rust-lang/rust#92698

Tracking issue for super let: rust-lang/rust#139076

Tracking issue for format_args: rust-lang/rust#99012

This change allows:

let name = "world";
let f = format_args!("hello {name}!"); // New: Store format_args!() for later!

println!("{f}");

This will need an FCP.

This implementation makes use of super let, which is unstable and might not exist in the future in its current form. However, it is entirely reasonable to assume future Rust will always have a way of expressing temporary lifetimes like this, since the (stable) pin!() macro needs this too. (This was also the motivation for merging rust-lang/rust#139114.)

(This is a second version of rust-lang/rust#139135)

flip1995 pushed a commit to flip1995/rust-clippy that referenced this pull request

Jun 26, 2025

@bors

Allow storing format_args!() in variable

Fixes rust-lang/rust#92698

Tracking issue for super let: rust-lang/rust#139076

Tracking issue for format_args: rust-lang/rust#99012

This change allows:

let name = "world";
let f = format_args!("hello {name}!"); // New: Store format_args!() for later!

println!("{f}");

This will need an FCP.

This implementation makes use of super let, which is unstable and might not exist in the future in its current form. However, it is entirely reasonable to assume future Rust will always have a way of expressing temporary lifetimes like this, since the (stable) pin!() macro needs this too. (This was also the motivation for merging rust-lang/rust#139114.)

(This is a second version of rust-lang/rust#139135)

tautschnig pushed a commit to model-checking/verify-rust-std that referenced this pull request

Jul 3, 2025

@bors

…elmann

Allow storing format_args!() in variable

Fixes rust-lang#92698

Tracking issue for super let: rust-lang#139076

Tracking issue for format_args: rust-lang#99012

This change allows:

let name = "world";
let f = format_args!("hello {name}!"); // New: Store format_args!() for later!

println!("{f}");

This will need an FCP.

This implementation makes use of super let, which is unstable and might not exist in the future in its current form. However, it is entirely reasonable to assume future Rust will always have a way of expressing temporary lifetimes like this, since the (stable) pin!() macro needs this too. (This was also the motivation for merging rust-lang#139114.)

(This is a second version of rust-lang#139135)

Labels

needs-fcp

This change is insta-stable, or significant enough to need a team FCP to proceed.

S-waiting-on-review

Status: Awaiting review from the assignee but also interested parties.

T-compiler

Relevant to the compiler team, which will review and decide on the PR/issue.

T-lang

Relevant to the language team

T-libs-api

Relevant to the library API team, which will review and decide on the PR/issue.