about summary refs log tree commit diff
diff options
context:
space:
mode:
authorCorey Richardson <corey@octayn.net>2014-06-16 23:00:49 -0700
committerCorey Richardson <corey@octayn.net>2014-07-09 00:06:29 -0700
commitae9a92bd4ef25b8aba0ef06e7ad26319691e9e5a (patch)
treea8a83cb164bc4c1ba6c214b7d43fa545d9b221a3
parentb0303b3c22eeb602ed8d51a267f52306aadc9322 (diff)
downloadrust-ae9a92bd4ef25b8aba0ef06e7ad26319691e9e5a.tar.gz
rust-ae9a92bd4ef25b8aba0ef06e7ad26319691e9e5a.zip
syntax: use a better Show impl for Ident
Rather than just dumping the id in the interner, which is useless, actually
print the interned string. Adjust the lexer logging to use Show instead of
Poly.
-rw-r--r--src/libsyntax/ast.rs8
-rw-r--r--src/libsyntax/parse/lexer/mod.rs2
2 files changed, 8 insertions, 2 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs
index c5afc5067b6..d96f1393bc9 100644
--- a/src/libsyntax/ast.rs
+++ b/src/libsyntax/ast.rs
@@ -41,7 +41,7 @@ pub fn P<T: 'static>(value: T) -> P<T> {
 /// table) and a SyntaxContext to track renaming and
 /// macro expansion per Flatt et al., "Macros
 /// That Work Together"
-#[deriving(Clone, Hash, PartialOrd, Eq, Ord, Show)]
+#[deriving(Clone, Hash, PartialOrd, Eq, Ord)]
 pub struct Ident {
     pub name: Name,
     pub ctxt: SyntaxContext
@@ -52,6 +52,12 @@ impl Ident {
     pub fn new(name: Name) -> Ident { Ident {name: name, ctxt: EMPTY_CTXT}}
 }
 
+impl Show for Ident {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        write!(f, "\"{}\"#{}", token::get_ident(*self).get(), self.ctxt)
+    }
+}
+
 impl PartialEq for Ident {
     fn eq(&self, other: &Ident) -> bool {
         if self.ctxt == other.ctxt {
diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs
index 43bbba85271..41035ffe89e 100644
--- a/src/libsyntax/parse/lexer/mod.rs
+++ b/src/libsyntax/parse/lexer/mod.rs
@@ -90,7 +90,7 @@ impl<'a> Reader for TtReader<'a> {
     }
     fn next_token(&mut self) -> TokenAndSpan {
         let r = tt_next_token(self);
-        debug!("TtReader: r={:?}", r);
+        debug!("TtReader: r={}", r);
         r
     }
     fn fatal(&self, m: &str) -> ! {