-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Fix incorrect inlining of functions that come from MBE macros #16497
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
Fix incorrect inlining of functions that come from MBE macros #16497
Conversation
98995e0
to
4c5e89e
Compare
Rebasing should fix the CI. |
088756a
to
1fcac0d
Compare
1fcac0d
to
57a4542
Compare
It looks like when the function body comes from a macro, rust-analyzer/crates/ide-assists/src/handlers/inline_call.rs Lines 361 to 370 in 57a4542
Specifically, in my second test (at the end of the file), we have self.value.$0hash2(state) // function comes from macro, fails to inline but, as can be seen from other tests, a small change makes it pass: self.value.$0write2_u64(state) // function was written by hand, inlines correctly Perhaps there is some kind of analysis that needs to be run on the function body if it comes from a macro so it is "parsed" into a syntax tree instead of being "opaque" like it seems to be here...? |
The usage only exists in a macro expansion so usage search can't find it. That is currently expected and non-trivial to fix as we can't look through all macro expansions that there are for obvious performance reasons. We could special case this search for locals as the scope of macro expansions is contained to the body the local belongs to, implementing that is already tricky though I believe. |
@Veykril would you be okay with me removing the second test and merging the other fix for now then? I can try to do the other one separately. |
That's fine yes |
To be added back later once we have a fix. See rust-lang#16471 and rust-lang#16497 (comment).
This comment was marked as outdated.
This comment was marked as outdated.
That clippy issue should be fixed on master already, thanks! |
☀️ Test successful - checks-actions |
Partial fix for #16471.
As a reminder, there are two issues there:
self
parameter not being replaced bythis
in the function body (the second test)The first part is fixed in this PR. See this comment for the second.