Uh oh!
There was an error while loading. Please reload this page.
Add -Zast and -Zast-noexpand to pretty-print AST (without the JSON conversion) - #38083
Add -Zast and -Zast-noexpand to pretty-print AST (without the JSON conversion)#38083spinda wants to merge 3 commits into
Conversation
rust-highfive
commented
Nov 30, 2016
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @eddyb (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
eddyb
commented
Nov 30, 2016
r? @nrc |
sanxiyn
commented
Nov 30, 2016
I'd like to see an example output. |
spinda
commented
Nov 30, 2016
|
nrc
commented
Nov 30, 2016
Could this be a pretty printing option rather than a |
spinda
commented
Dec 1, 2016
Is that the right place to put it? The |
spinda
commented
Dec 1, 2016
Ah, I see now that there's already |
spinda
commented
Dec 1, 2016
This is working now: fnmain(){println!("Hello, World!");go(there);}However, the printing of statements isn't very useful for exploring the AST: This is because impl fmt::DebugforStmt{fnfmt(&self,f:&mut fmt::Formatter) -> fmt::Result{write!(f,"stmt({}: {})",self.id.to_string(), pprust::stmt_to_string(self))}}Is there a good way around this? |
nrc
commented
Dec 2, 2016
I don't think there is a good way around this. You could try creating your own trait and use specialisation so that by default is calls the debug implementation, but you override this for statements and expressions. I'm not sure if that will work though, it might fall foul of the specialisation/coherence rules. You could also just change the debug impls for Stmt and Expr, I'm not sure how the rest of @rust-lang/compiler feel, but I'd prefer Debug to contain what you want and maybe implement Display for the current stuff. |
eddyb
commented
Dec 2, 2016
Definitely agree with keeping |
nikomatsakis
commented
Dec 2, 2016
Hmm. I...agree with auto-generating Debug, though I do find it really useful to be able to search the RUST_LOG output for specific expressions. I do this all the time when tracking down type-checking or region-inference failures. Probably the solution is to change a lot of those debug logs to |
steveklabnik
commented
Jan 3, 2017
Ping! It's been a month since there's been any activity on this PR; can we move it forward? |
sanxiyn
commented
Jan 6, 2017
I think the main consideration here is whether |
bors
commented
Jan 21, 2017
☔ The latest upstream changes (presumably #39199) made this pull request unmergeable. Please resolve the merge conflicts. |
-Zast behaves like -Zast-json but uses {:#?} pretty-printing instead of
converting to JSON.
-Zast-noexpand is the pretty-printing counterpart to -Zast-json-noexpand.spinda
commented
Jan 26, 2017
I don't think I'm familiar enough with the |
mrhota
commented
Feb 23, 2017
@spinda@steveklabnik can someone close this? |
nikomatsakis
commented
Mar 2, 2017
Will do. |
-Zast behaves like -Zast-json but uses
{:#?}pretty-printing instead of converting to JSON.-Zast-noexpand is the pretty-printing counterpart to -Zast-json-noexpand.
Fixes#37873.