1
Fork 0

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.
This commit is contained in:
Corey Richardson 2014-06-16 23:00:49 -07:00
parent b0303b3c22
commit ae9a92bd4e
2 changed files with 8 additions and 2 deletions

View 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 {

View file

@ -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) -> ! {