format_args!
"decompiler": forced warnings and fmt::Arguments::new_v1_formatted
"support".
#326
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
(Each commit should be reviewed separately)
The main "externally" visible change is the "force warnings" one - thought it's still mostly just for us.
Due to Cargo using
--cap-lints
, you normally can't see warnings in non-local dependencies - and that includes the standard library when using-Zbuild-std
(like we do).So every time the "
format_args!
decompiler" would fail (e.g. while working on arustup
, before updating it) for apanic!
in e.g.core
, it would silently cause issues downstream (while making it harder to diagnose)After this PR, it will always warn in the crate responsible (though hopefully never, for Rust-GPU users).
I've had this "force warnings" change around for a while, but never submitted it because there were always a few warnings from
core
- turns out they were caused byfmt::Arguments::new_v1_formatted
, which is used forformat_args!
with any non-default options (e.g. padding) or non-trivial argument numbering, etc.I decided to "support" those cases - however, actually extracting the necessary information would be too much effort (and require relying on unstable implementation details of
core::fmt::rt
), so thedebugPrintf
form includes all the arguments but in a very general "these N args go into M placeholders somehow".Also, there's some really hacky skipping of
core::fmt::rt::Placeholder::new
calls, due tomain
predating:Thankfully, that PR landed between 1.87 and 1.88, so #249 (the ~1.88 rustup) should be able to remove the hacks (as the entire
&[core::fmt::rt::Placeholder]
slice should be a constant then, just like the&[&str]
one is).(In theory, due to the level of simplification done upstream, it may be plausible to start decoding the
Placeholder
values, but I would not want to put effort into it until an usecase is revealed)There are also some changes that in theory aren't needed before #320 (the ~1.89 rustup), but which I've found invaluable while debugging any changes to the
format_args!
"decompiler" logic (and which I wish I had done much sooner).