-
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
Rustfmt-ify expansion of macro #10548
Comments
Either that, or allow me to run Format Document on the resulting editor. Trying to do so right now gives me a "Cannot edit in read-only editor" error (in VSCode). Probably formatting the initial expansion is better though. |
The problem here is that macros don't necessarily expand to something on its own that rustfmt can format(to my knowledge) so this wouldn't always work as we don't expand macros into the source file. |
It should be possible to wrap the macro output in for example |
I did just realize yesterday that the expansion does still include > echo 'fn foo() { $crate::print("Bar"); }' | rustfmt
error: expected expression, found `$`
--> <stdin>:1:12
|
1 | fn foo() { $crate::print("Bar"); }
| ^ expected expression |
Mmh ye that is a problem since we can't always replace them with the crate name its referring to since the crate in question isn't necessarily in the nameable dependencies of the current crate. We could replace |
CC #7532 |
Just like
cargo-expand
, it'd be cool if Rust Analyzer had an option to format the expansion of macros.The text was updated successfully, but these errors were encountered: