mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-23 05:03:47 +00:00
disallow ident equality checks when contexts are not equal
This commit is contained in:
parent
6e3b2ab44d
commit
77c96d754e
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user