diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index c7ebc344a9c8..8a9bd5192ad8 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -24,7 +24,7 @@ use extra::serialize::{Encodable, Decodable, Encoder, Decoder}; // table) and a SyntaxContext to track renaming and // macro expansion per Flatt et al., "Macros // That Work Together" -#[deriving(Clone, Eq, IterBytes, ToStr)] +#[deriving(Clone, IterBytes, ToStr)] pub struct Ident { name: Name, ctxt: SyntaxContext } impl Ident { @@ -32,6 +32,19 @@ impl Ident { pub fn new(name: Name) -> Ident { Ident {name: name, ctxt: EMPTY_CTXT}} } +impl Eq for Ident { + fn eq(&self, other: &Ident) -> bool { + if (self.ctxt == other.ctxt) { + self.name == other.name + } else { + fail!(fmt!("not allowed to compare these idents: %?, %?", self, other)); + } + } + fn ne(&self, other: &Ident) -> bool { + ! self.eq(other) + } +} + /// A SyntaxContext represents a chain of macro-expandings /// and renamings. Each macro expansion corresponds to /// a fresh uint