-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
feat: Implement builtin#format_args, using rustc's format_args parser #15559
Conversation
a491b92
to
815b7dc
Compare
815b7dc
to
abe8f1e
Compare
Note this currently copies rustc's format_args parser crate, as it depends on rustc_datastructures and I am waiting for my upstream PR to get merged at which point we can depend on a published copy of it instead, hence why the PR is even more massive than it should be |
84dd5e0
to
6f55b8c
Compare
6f55b8c
to
c0e4026
Compare
e7c11a7
to
3fa0bf0
Compare
This does increase analysis-stats mir memory consumption by ~80 mb though, definitely something we wanna take a look at again (as in to optimize if possible). That makes me wonder if there is some easy to write MIR opt that can optimize for MIR size? |
3752488
to
078c5d5
Compare
@@ -247,160 +243,22 @@ fn format_args_expand_general( | |||
_db: &dyn ExpandDatabase, | |||
_id: MacroCallId, | |||
tt: &tt::Subtree, | |||
end_string: &str, | |||
// FIXME: Make use of this so that mir interpretation works properly |
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.
Note, (I'm probably not fixing this in this PR) format_args_nl!
will behave the same as format_args!
that is no newline will be appended. This is fine for most hings but mir eval.
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.
I'm unsure how to solve this, we could give the construct an extra "parameter" or something that tells it to emit an additional newline, make a builtin#format_args_nl
construct or try to fiddle with the template string which I really do not want to do (and I don't think we can reasonably do that).
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.
I'm leaning towards adding a second builtin# variant, it seems simplest
078c5d5
to
5046889
Compare
Let's see how this goes |
☀️ Test successful - checks-actions |
Yes, there are some easy optimization passes that we can implement. Generating a better MIR in first place is also something we can try, which may achieve somethings that easy optimizations can't.
Yes, also failed mirs on self count is 2488, while I hoped it to be dropped to near zero after this PR. Will look at it. |
format_args!
now expands tobuiltin#format_args(template, args...)
, the actual expansion now instead happens in lowering where we desugar this expression by using lang paths.As a bonus, we no longer need to evaluate
format_args
as an eager macro which means less macro expansions overall -> less cache thrashing!Fixes #15082
cc rust-lang/rust#110680