You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When working with macros, it is sometimes useful to use rustc's -Zunpretty=expanded flag to see how a macro is being expanded (think of this like -E when working with gcc for C or C++).
I checked the source tree, the tests and the help of a recent build (4d7e7d9), but I couldn't see anything that looked like it matched dumping -Zunpretty=expanded to stdout/stderr/a file.
#![feature(prelude_import)]#![no_std]#[prelude_import]use::std::prelude::rust_2015::*;#[macro_use]externcrate std;// { dg-output "1\r*\n2\r*\nNaN\r*\n3\r*\n" }macro_rules! print_num {($l:literal) =>
{{unsafe{ printf("%d\n\0"as*conststras*consti8, $l);}}};}extern"C"{fnprintf(s:*consti8, ...);}// Check to make sure that expanding macros does not break the flow of callsfnmain() -> i32{{unsafe{printf("%d\n\0"as*conststras*consti8,1);}};{unsafe{printf("%d\n\0"as*conststras*consti8,2);}};unsafe{printf("NaN\n\0"as*conststras*consti8);}{unsafe{printf("%d\n\0"as*conststras*consti8,3);}};0}
So I was wondering if it is possible to do the same with gccrs.
You can use -frust-dump-expansion although it is not 100% perfect for now, it'll insert some comments for tail expressions. Some work is already on track to improve that #3212 should allow more customization and #3209 should fix a slight issue with doc comments being converted to attributes.
Activity
aytey commentedon Feb 4, 2025
By way of an example:
Gives:
So I was wondering if it is possible to do the same with
gccrs
.P-E-P commentedon Feb 4, 2025
You can use
-frust-dump-expansion
although it is not 100% perfect for now, it'll insert some comments for tail expressions. Some work is already on track to improve that #3212 should allow more customization and #3209 should fix a slight issue with doc comments being converted to attributes.aytey commentedon Feb 4, 2025
Works perfectly -- thank you!