Skip to content

Allow storing format_args!() in variable or const #139135

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 and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

m-ou-se
Copy link
Member

@m-ou-se m-ou-se commented Mar 30, 2025

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
@m-ou-se m-ou-se self-assigned this 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, so needs a completed 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
@rust-log-analyzer

This comment was marked as outdated.

@m-ou-se m-ou-se force-pushed the super-format-args branch from 3b4d57d to 627b48c Compare March 30, 2025 11:50
@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.

@m-ou-se m-ou-se force-pushed the super-format-args branch from 627b48c to 25d0db8 Compare March 30, 2025 12:14
@rust-log-analyzer

This comment has been minimized.

@m-ou-se m-ou-se force-pushed the super-format-args branch from 25d0db8 to 2a4d503 Compare March 30, 2025 12:43
@rust-log-analyzer

This comment has been minimized.

@m-ou-se m-ou-se force-pushed the super-format-args branch from 2a4d503 to 44b1861 Compare March 30, 2025 12:51
@m-ou-se
Copy link
Member Author

m-ou-se commented Mar 30, 2025

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.

@m-ou-se m-ou-se added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 9, 2025
@m-ou-se

This comment was marked as resolved.

@RalfJung

This comment was marked as resolved.

@oli-obk

This comment was marked as resolved.

Copy link
Member

@RalfJung RalfJung Apr 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree these tests should not rely on formatting machinery, but they also should not be deleted.

And this particular test here does not even seem to rely on formating machinery...?

@m-ou-se

This comment was marked as resolved.

@RalfJung

This comment was marked as resolved.

@m-ou-se

This comment was marked as resolved.

@oli-obk

This comment was marked as resolved.

@RalfJung

This comment was marked as resolved.

@oli-obk

This comment was marked as resolved.

@m-ou-se
Copy link
Member Author

m-ou-se commented Apr 10, 2025

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

@bors
Copy link
Collaborator

bors commented Apr 15, 2025

☔ The latest upstream changes (presumably #139632) made this pull request unmergeable. Please resolve the merge conflicts.

@m-ou-se m-ou-se force-pushed the super-format-args branch from 3db7f57 to a364c4b Compare April 22, 2025 14:25
@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 m-ou-se removed the A-tidy Area: The tidy tool label Apr 22, 2025
m-ou-se added 5 commits April 22, 2025 16:38
This makes it posisble to do:

    let f = format_args!("Hello, {name}!");
We can now just make new_v1_formatted an unsafe fn.
These tests rely on internal implementation details of format_args!(),
which have changed now.
@m-ou-se m-ou-se force-pushed the super-format-args branch from a364c4b to 3fbcdc0 Compare April 22, 2025 14:40
@rustbot rustbot added the A-tidy Area: The tidy tool label Apr 22, 2025
@rust-log-analyzer

This comment has been minimized.

@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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tidy Area: The tidy tool needs-fcp This change is insta-stable, so needs a completed 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, which will review and decide on the PR/issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow storing format_args! in a let binding
6 participants