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

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().)