Skip to content

Commit ae9a92b

Browse files
committed
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.
1 parent b0303b3 commit ae9a92b

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/libsyntax/ast.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub fn P<T: 'static>(value: T) -> P<T> {
4141
/// table) and a SyntaxContext to track renaming and
4242
/// macro expansion per Flatt et al., "Macros
4343
/// That Work Together"
44-
#[deriving(Clone, Hash, PartialOrd, Eq, Ord, Show)]
44+
#[deriving(Clone, Hash, PartialOrd, Eq, Ord)]
4545
pub struct Ident {
4646
pub name: Name,
4747
pub ctxt: SyntaxContext
@@ -52,6 +52,12 @@ impl Ident {
5252
pub fn new(name: Name) -> Ident { Ident {name: name, ctxt: EMPTY_CTXT}}
5353
}
5454

55+
impl Show for Ident {
56+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
57+
write!(f, "\"{}\"#{}", token::get_ident(*self).get(), self.ctxt)
58+
}
59+
}
60+
5561
impl PartialEq for Ident {
5662
fn eq(&self, other: &Ident) -> bool {
5763
if self.ctxt == other.ctxt {

src/libsyntax/parse/lexer/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ impl<'a> Reader for TtReader<'a> {
9090
}
9191
fn next_token(&mut self) -> TokenAndSpan {
9292
let r = tt_next_token(self);
93-
debug!("TtReader: r={:?}", r);
93+
debug!("TtReader: r={}", r);
9494
r
9595
}
9696
fn fatal(&self, m: &str) -> ! {

0 commit comments

Comments
 (0)