diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2012-11-14 18:59:30 -0800 |
|---|---|---|
| committer | Patrick Walton <pcwalton@mimiga.net> | 2012-11-19 15:33:11 -0800 |
| commit | 318e534895f20e7991abbc644eec311816010ef1 (patch) | |
| tree | 764ce1ae3e9efbecd4fdc057663beb522b10bda9 /src/libsyntax/codemap.rs | |
| parent | 4101587a88d719659d2e30feaad8437c55af9150 (diff) | |
| download | rust-318e534895f20e7991abbc644eec311816010ef1.tar.gz rust-318e534895f20e7991abbc644eec311816010ef1.zip | |
rustc: Implement explicit self for Eq and Ord. r=graydon
Diffstat (limited to 'src/libsyntax/codemap.rs')
| -rw-r--r-- | src/libsyntax/codemap.rs | 54 |
1 files changed, 48 insertions, 6 deletions
diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index d291d9545eb..fafcd09e3dc 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -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> { |
