diff options
| author | Huon Wilson <dbau.pp+github@gmail.com> | 2014-08-11 22:01:37 +1000 |
|---|---|---|
| committer | Huon Wilson <dbau.pp+github@gmail.com> | 2014-08-30 16:50:38 +1000 |
| commit | 32e437161da5e60c660b86da9003b7f73ebb5676 (patch) | |
| tree | 6de8bed0e2c88adc2f12927bebe94a3d4f395a06 /src/libsyntax | |
| parent | ddc8cc92c998b7d80c782d00d178c791ab564915 (diff) | |
| download | rust-32e437161da5e60c660b86da9003b7f73ebb5676.tar.gz rust-32e437161da5e60c660b86da9003b7f73ebb5676.zip | |
rustc: implement a pretty mode to print ident/name's ctxt & gensyms.
`--pretty expanded,hygiene` is helpful with debugging macro issues, since two identifiers/names can be textually the same, but different internally (resulting in weird "undefined variable" errors).
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/print/pprust.rs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index da265d81250..14ba4d73a4e 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -33,6 +33,8 @@ use std::io; use std::mem; pub enum AnnNode<'a> { + NodeIdent(&'a ast::Ident), + NodeName(&'a ast::Name), NodeBlock(&'a ast::Block), NodeItem(&'a ast::Item), NodeExpr(&'a ast::Expr), @@ -1725,14 +1727,16 @@ impl<'a> State<'a> { pub fn print_ident(&mut self, ident: ast::Ident) -> IoResult<()> { if self.encode_idents_with_hygiene { let encoded = ident.encode_with_hygiene(); - word(&mut self.s, encoded.as_slice()) + try!(word(&mut self.s, encoded.as_slice())) } else { - word(&mut self.s, token::get_ident(ident).get()) + try!(word(&mut self.s, token::get_ident(ident).get())) } + self.ann.post(self, NodeIdent(&ident)) } pub fn print_name(&mut self, name: ast::Name) -> IoResult<()> { - word(&mut self.s, token::get_name(name).get()) + try!(word(&mut self.s, token::get_name(name).get())); + self.ann.post(self, NodeName(&name)) } pub fn print_for_decl(&mut self, loc: &ast::Local, |
