rustc: Implement explicit self for Eq and Ord. r=graydon

This commit is contained in:
Patrick Walton 2012-11-14 18:59:30 -08:00
parent 4101587a88
commit 318e534895
89 changed files with 4175 additions and 92 deletions

View file

@ -37,13 +37,20 @@ impl BytePos: Pos {
pure fn to_uint(&self) -> uint { **self }
}
#[cfg(stage0)]
impl BytePos: cmp::Eq {
pure fn eq(other: &BytePos) -> bool {
*self == **other
}
pure fn eq(other: &BytePos) -> bool { *self == **other }
pure fn ne(other: &BytePos) -> bool { !self.eq(other) }
}
#[cfg(stage1)]
#[cfg(stage2)]
impl BytePos: cmp::Eq {
pure fn eq(&self, other: &BytePos) -> bool { **self == **other }
pure fn ne(&self, other: &BytePos) -> bool { !(*self).eq(other) }
}
#[cfg(stage0)]
impl BytePos: cmp::Ord {
pure fn lt(other: &BytePos) -> bool { *self < **other }
pure fn le(other: &BytePos) -> bool { *self <= **other }
@ -51,6 +58,15 @@ impl BytePos: cmp::Ord {
pure fn gt(other: &BytePos) -> bool { *self > **other }
}
#[cfg(stage1)]
#[cfg(stage2)]
impl BytePos: cmp::Ord {
pure fn lt(&self, other: &BytePos) -> bool { **self < **other }
pure fn le(&self, other: &BytePos) -> bool { **self <= **other }
pure fn ge(&self, other: &BytePos) -> bool { **self >= **other }
pure fn gt(&self, other: &BytePos) -> bool { **self > **other }
}
impl BytePos: Num {
pure fn add(other: &BytePos) -> BytePos {
BytePos(*self + **other)
@ -85,13 +101,20 @@ impl CharPos: Pos {
pure fn to_uint(&self) -> uint { **self }
}
#[cfg(stage0)]
impl CharPos: cmp::Eq {
pure fn eq(other: &CharPos) -> bool {
*self == **other
}
pure fn eq(other: &CharPos) -> bool { *self == **other }
pure fn ne(other: &CharPos) -> bool { !self.eq(other) }
}
#[cfg(stage1)]
#[cfg(stage2)]
impl CharPos: cmp::Eq {
pure fn eq(&self, other: &CharPos) -> bool { **self == **other }
pure fn ne(&self, other: &CharPos) -> bool { !(*self).eq(other) }
}
#[cfg(stage0)]
impl CharPos: cmp::Ord {
pure fn lt(other: &CharPos) -> bool { *self < **other }
pure fn le(other: &CharPos) -> bool { *self <= **other }
@ -99,6 +122,15 @@ impl CharPos: cmp::Ord {
pure fn gt(other: &CharPos) -> bool { *self > **other }
}
#[cfg(stage1)]
#[cfg(stage2)]
impl CharPos: cmp::Ord {
pure fn lt(&self, other: &CharPos) -> bool { **self < **other }
pure fn le(&self, other: &CharPos) -> bool { **self <= **other }
pure fn ge(&self, other: &CharPos) -> bool { **self >= **other }
pure fn gt(&self, other: &CharPos) -> bool { **self > **other }
}
impl CharPos: Num {
pure fn add(other: &CharPos) -> CharPos {
CharPos(*self + **other)
@ -141,10 +173,20 @@ pub struct span {
}
impl span : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &span) -> bool {
return self.lo == (*other).lo && self.hi == (*other).hi;
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &span) -> bool {
return (*self).lo == (*other).lo && (*self).hi == (*other).hi;
}
#[cfg(stage0)]
pure fn ne(other: &span) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &span) -> bool { !(*self).eq(other) }
}
impl<S: Serializer> span: Serializable<S> {