-
Notifications
You must be signed in to change notification settings - Fork 209
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
Add a way to see expanded macros #158
Comments
An interesting idea! Is that a stable flag, do you know? Any suggestions or hastily mocked-up drawings for how this could fit in the UI? |
It's an unstable flag. I imagine it could sit within the It's probably worth running it through the formatter as part of the expansion, or maybe use |
I'd really like to see this as well. @shepmaster This should sit next to Clippy, and open another output tab labeled "Expanded Macros" or similar. I don't think it makes sense to change the original code; this should be an output format. For a first pass, it can just dump the output directly into an output tab. As a second pass, it'd be incredible to have a diff-like mechanism that lets you move through the code on the left and highlight the corresponding expanded span on the right. The compiler has that information; you'd just need to dump it and turn it into JSON to hand to the client. |
I was looking for this feature just now. The first place i looked was in the "WHAT DO YOU WANT TO DO?" menu next to the build button, because macro-expanded pseudo-source feels like a kind of intermediate output, like MIR or LLVM IR. The second place i looked was in the "Tools" menu, because that's where random useful things live. The playground's UI is small enough that people will probably find it soon enough, wherever it is! From the discussion on rust-lang/rust#43364, it sounds like the rustc flag won't be stabilised any time soon. Could this be an option which only works on nightly? I wouldn't mind that. About formatting, the discussion on rust-lang/rust#43364 includes a comment about "an issue where a macro expansion results in unparseable output". So perhaps it's unwise to assume that the output can always be formatted, and either not format it at all, or handle failure, or make it optional. |
It would be useful even it it was just an "Expand Macros" option under "Tools", which create a tab in the right pane, with unformatted text in it. |
I'd also like to see this, I believe it'd be useful for derives |
Wanted. |
@shepmaster I attempted to implement this feature in #599. It currently very simple and don't include any option to format output, also rely on nightly compiler. |
Closed via #599 |
@Flowneee Fantastic, thank you! |
There's currently no way to experiment with
macro_rules
online. I think having a--pretty=expanded
option on the playground would be great.The text was updated successfully, but these errors were encountered: