Support inside macro_rules! #15372
-
I find macro_rules! really helpful for avoiding code duplication, but it is so painful writing them sometimes because RA doesn't analyze the code inside the declaration. Sorry if this is a stupid question but is RA ever likely to support this or is it pretty much impossible? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
The code in a macro_rules declaration doesn't have any meaning by itself, it's just a bunch of tokens. So we can't analyze it in any meaningful way. It might be possible to look at the usages of the macro, if you use it, and apply the analysis from there back to the macro declaration. But this would be quite complicated, would only work once you use the macro somewhere, and would also not necessarily give you the results you might expect. So it's quite unlikely that's going to happen any time soon. |
Beta Was this translation helpful? Give feedback.
-
Thanks, good to know it is at least theoretically possible! Maybe one day... |
Beta Was this translation helpful? Give feedback.
The code in a macro_rules declaration doesn't have any meaning by itself, it's just a bunch of tokens. So we can't analyze it in any meaningful way. It might be possible to look at the usages of the macro, if you use it, and apply the analysis from there back to the macro declaration. But this would be quite complicated, would only work once you use the macro somewhere, and would also not necessarily give you the results you might expect. So it's quite unlikely that's going to happen any time soon.