]> git.lizzy.rs Git - rust.git/commitdiff
syntax: use a better Show impl for Ident
authorCorey Richardson <corey@octayn.net>
Tue, 17 Jun 2014 06:00:49 +0000 (23:00 -0700)
committerCorey Richardson <corey@octayn.net>
Wed, 9 Jul 2014 07:06:29 +0000 (00:06 -0700)
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.

src/libsyntax/ast.rs
src/libsyntax/parse/lexer/mod.rs

index c5afc5067b6a980bd990d23ef167d1649e13e031..d96f1393bc9174dba73b662d0c29e37a93171bdc 100644 (file)
@@ -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 {
index 43bbba8527199fc8b38096bb3b9e83ed4b8f8b9a..41035ffe89edc996935e8b256e969828a2328181 100644 (file)
@@ -90,7 +90,7 @@ fn is_eof(&self) -> bool {
     }
     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) -> ! {