Closed
Description
This appears to reproduce across stable/beta/nightly, and basically makes format_args!
unusable as far as I can tell. Nothing I've managed to pass in has compiled, though I have not experimented extensively. I've also included the expanded code (rustc -Zunstable-options --pretty=expanded
) which shows why this is the case.
fn a() {
let a = 10;
let msg = format_args!("{}", a);
}
fails with:
error: borrowed value does not live long enough
--> test.rs:3:36
|
3 | let msg = format_args!("{}", a);
| ---- ^ temporary value dropped here while still borrowed
| |
| temporary value created here
4 | }
| - temporary value needs to live until here
|
= note: consider using a `let` binding to increase its lifetime
expanded:
fn a() {
let a = 10;
let msg =
::std::fmt::Arguments::new_v1({
static __STATIC_FMTSTR:
&'static [&'static str] =
&[""];
__STATIC_FMTSTR
},
&match (&a,) { // I believe the problem is here
(__arg0,) =>
[::std::fmt::ArgumentV1::new(__arg0,
::std::fmt::Display::fmt)],
});
}