-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Refactor FormatArgsExpn
#9349
Refactor FormatArgsExpn
#9349
Conversation
Maybe this makes #8857 unnecessary? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This all is really specific to how the format_arg!
macro expands. But that also was the previous code, so I don't see this as a blocker.
However, I noticed that the pattern is to construct those things from rpf
information. Can you give an estimation how likely it is to add this information to rpf
and give Clippy access to it? This feels like we're doing work that is/can already (be) done in rustc
.
Those are no blockers. Just a few comments how the code could maybe be improved.
17bc0ef
to
88600bf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only 2 minor comments, then we can move on with the other PR 🚀
I don't think There is talk of making |
80cbf42
to
cd8eda5
Compare
cd8eda5
to
4f049f5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, just another detail. After that r=me.
@bors r+ Thanks! |
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
It now for each format argument
{..}
has:Expr
it points to, and how it does so (named/named inline/numbered/implicit)FormatSpec
(format trait/fill/align/etc., the precision/width and any value they point to)The caller no longer needs to pair up arguments to their value, or separately interpret the
specs
Expr
s when it isn'tNone
The gist is that it combines the result of
rustc_parse_format::Parser
with the macro expansion itselfThis unfortunately makes the code a bit longer, however we need to use both as neither have all the information we're after.
rustc_parse_format
doesn't have the information to resolve named arguments to their values. The macro expansion doesn't contain whether the positions are implicit/numbered/named, or the spans for format argumentsWanted by #9233 and #8518 to be able to port the changes from #9040
Also fixes #8643, previously the format args seem to have been paired up with the wrong values somehow
changelog: [
format_in_format_args
]: Fix false positive due to misattributed argumentsr? @flip1995
cc @nyurik