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

@ -1,11 +1,20 @@
enum mode { mode_compile_fail, mode_run_fail, mode_run_pass, mode_pretty, }
#[cfg(stage0)]
impl mode : cmp::Eq {
pure fn eq(other: &mode) -> bool {
(*other) as int == self as int
}
pure fn ne(other: &mode) -> bool { !self.eq(other) }
}
#[cfg(stage1)]
#[cfg(stage2)]
impl mode : cmp::Eq {
pure fn eq(&self, other: &mode) -> bool {
(*other) as int == (*self) as int
}
pure fn ne(&self, other: &mode) -> bool { !(*self).eq(other) }
}
type config = {
// The library paths required for running the compiler

View File

@ -30,6 +30,7 @@ struct Package {
}
impl Package : cmp::Ord {
#[cfg(stage0)]
pure fn lt(other: &Package) -> bool {
if self.name.lt(&(*other).name) { return true; }
if (*other).name.lt(&self.name) { return false; }
@ -46,9 +47,39 @@ impl Package : cmp::Ord {
if self.versions.lt(&(*other).versions) { return true; }
return false;
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn lt(&self, other: &Package) -> bool {
if (*self).name.lt(&(*other).name) { return true; }
if (*other).name.lt(&(*self).name) { return false; }
if (*self).uuid.lt(&(*other).uuid) { return true; }
if (*other).uuid.lt(&(*self).uuid) { return false; }
if (*self).url.lt(&(*other).url) { return true; }
if (*other).url.lt(&(*self).url) { return false; }
if (*self).method.lt(&(*other).method) { return true; }
if (*other).method.lt(&(*self).method) { return false; }
if (*self).description.lt(&(*other).description) { return true; }
if (*other).description.lt(&(*self).description) { return false; }
if (*self).tags.lt(&(*other).tags) { return true; }
if (*other).tags.lt(&(*self).tags) { return false; }
if (*self).versions.lt(&(*other).versions) { return true; }
return false;
}
#[cfg(stage0)]
pure fn le(other: &Package) -> bool { !(*other).lt(&self) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn le(&self, other: &Package) -> bool { !(*other).lt(&(*self)) }
#[cfg(stage0)]
pure fn ge(other: &Package) -> bool { !self.lt(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ge(&self, other: &Package) -> bool { !(*self).lt(other) }
#[cfg(stage0)]
pure fn gt(other: &Package) -> bool { (*other).lt(&self) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn gt(&self, other: &Package) -> bool { (*other).lt(&(*self)) }
}
struct Source {
@ -94,10 +125,20 @@ struct Options {
enum Mode { SystemMode, UserMode, LocalMode }
impl Mode : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &Mode) -> bool {
(self as uint) == ((*other) as uint)
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &Mode) -> bool {
((*self) as uint) == ((*other) as uint)
}
#[cfg(stage0)]
pure fn ne(other: &Mode) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &Mode) -> bool { !(*self).eq(other) }
}
fn opts() -> ~[getopts::Opt] {

View File

@ -66,8 +66,16 @@ pub fn all_values(blk: fn(v: bool)) {
pub pure fn to_bit(v: bool) -> u8 { if v { 1u8 } else { 0u8 } }
impl bool : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &bool) -> bool { self == (*other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &bool) -> bool { (*self) == (*other) }
#[cfg(stage0)]
pure fn ne(other: &bool) -> bool { self != (*other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &bool) -> bool { (*self) != (*other) }
}
#[test]

View File

@ -28,15 +28,39 @@ pub pure fn ptr_eq<T>(a: @T, b: @T) -> bool {
}
impl<T:Eq> @const T : Eq {
#[cfg(stage0)]
pure fn eq(other: &@const T) -> bool { *self == *(*other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &@const T) -> bool { *(*self) == *(*other) }
#[cfg(stage0)]
pure fn ne(other: &@const T) -> bool { *self != *(*other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &@const T) -> bool { *(*self) != *(*other) }
}
impl<T:Ord> @const T : Ord {
#[cfg(stage0)]
pure fn lt(other: &@const T) -> bool { *self < *(*other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn lt(&self, other: &@const T) -> bool { *(*self) < *(*other) }
#[cfg(stage0)]
pure fn le(other: &@const T) -> bool { *self <= *(*other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn le(&self, other: &@const T) -> bool { *(*self) <= *(*other) }
#[cfg(stage0)]
pure fn ge(other: &@const T) -> bool { *self >= *(*other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ge(&self, other: &@const T) -> bool { *(*self) >= *(*other) }
#[cfg(stage0)]
pure fn gt(other: &@const T) -> bool { *self > *(*other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn gt(&self, other: &@const T) -> bool { *(*self) > *(*other) }
}
#[test]

View File

@ -181,8 +181,16 @@ pub pure fn cmp(a: char, b: char) -> int {
}
impl char : Eq {
#[cfg(stage0)]
pure fn eq(other: &char) -> bool { self == (*other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &char) -> bool { (*self) == (*other) }
#[cfg(stage0)]
pure fn ne(other: &char) -> bool { self != (*other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &char) -> bool { (*self) != (*other) }
}
#[test]

View File

@ -30,6 +30,7 @@ mod nounittest {
* default implementations.
*/
#[lang="ord"]
#[cfg(stage0)]
pub trait Ord {
pure fn lt(other: &self) -> bool;
pure fn le(other: &self) -> bool;
@ -37,6 +38,16 @@ mod nounittest {
pure fn gt(other: &self) -> bool;
}
#[lang="ord"]
#[cfg(stage1)]
#[cfg(stage2)]
pub trait Ord {
pure fn lt(&self, other: &self) -> bool;
pure fn le(&self, other: &self) -> bool;
pure fn ge(&self, other: &self) -> bool;
pure fn gt(&self, other: &self) -> bool;
}
#[lang="eq"]
/**
* Trait for values that can be compared for equality
@ -47,10 +58,19 @@ mod nounittest {
* a default implementation.
*/
#[lang="eq"]
#[cfg(stage0)]
pub trait Eq {
pure fn eq(other: &self) -> bool;
pure fn ne(other: &self) -> bool;
}
#[lang="eq"]
#[cfg(stage1)]
#[cfg(stage2)]
pub trait Eq {
pure fn eq(&self, other: &self) -> bool;
pure fn ne(&self, other: &self) -> bool;
}
}
#[cfg(test)]
@ -60,6 +80,8 @@ mod nounittest {
#[cfg(test)]
mod unittest {
#[legacy_exports];
#[cfg(stage0)]
pub trait Ord {
pure fn lt(other: &self) -> bool;
pure fn le(other: &self) -> bool;
@ -67,10 +89,27 @@ mod unittest {
pure fn gt(other: &self) -> bool;
}
#[cfg(stage1)]
#[cfg(stage2)]
pub trait Ord {
pure fn lt(&self, other: &self) -> bool;
pure fn le(&self, other: &self) -> bool;
pure fn ge(&self, other: &self) -> bool;
pure fn gt(&self, other: &self) -> bool;
}
#[cfg(stage0)]
pub trait Eq {
pure fn eq(other: &self) -> bool;
pure fn ne(other: &self) -> bool;
}
#[cfg(stage1)]
#[cfg(stage2)]
pub trait Eq {
pure fn eq(&self, other: &self) -> bool;
pure fn ne(&self, other: &self) -> bool;
}
}
#[cfg(notest)]

View File

@ -132,6 +132,7 @@ pub pure fn unwrap_right<T,U>(eith: Either<T,U>) -> U {
}
impl<T:Eq,U:Eq> Either<T,U> : Eq {
#[cfg(stage0)]
pure fn eq(other: &Either<T,U>) -> bool {
match self {
Left(ref a) => {
@ -148,7 +149,29 @@ impl<T:Eq,U:Eq> Either<T,U> : Eq {
}
}
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &Either<T,U>) -> bool {
match (*self) {
Left(ref a) => {
match (*other) {
Left(ref b) => (*a).eq(b),
Right(_) => false
}
}
Right(ref a) => {
match (*other) {
Left(_) => false,
Right(ref b) => (*a).eq(b)
}
}
}
}
#[cfg(stage0)]
pure fn ne(other: &Either<T,U>) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &Either<T,U>) -> bool { !(*self).eq(other) }
}
#[test]

View File

@ -394,6 +394,7 @@ pub mod rt {
pub enum PadMode { PadSigned, PadUnsigned, PadNozero, PadFloat }
pub impl PadMode : Eq {
#[cfg(stage0)]
pure fn eq(other: &PadMode) -> bool {
match (self, (*other)) {
(PadSigned, PadSigned) => true,
@ -406,7 +407,25 @@ pub mod rt {
(PadFloat, _) => false
}
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &PadMode) -> bool {
match ((*self), (*other)) {
(PadSigned, PadSigned) => true,
(PadUnsigned, PadUnsigned) => true,
(PadNozero, PadNozero) => true,
(PadFloat, PadFloat) => true,
(PadSigned, _) => false,
(PadUnsigned, _) => false,
(PadNozero, _) => false,
(PadFloat, _) => false
}
}
#[cfg(stage0)]
pure fn ne(other: &PadMode) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &PadMode) -> bool { !(*self).eq(other) }
}
pub fn pad(cv: Conv, s: ~str, mode: PadMode) -> ~str {

View File

@ -400,15 +400,39 @@ pub pure fn cos(x: float) -> float { f64::cos(x as f64) as float }
pub pure fn tan(x: float) -> float { f64::tan(x as f64) as float }
impl float : Eq {
#[cfg(stage0)]
pub pure fn eq(other: &float) -> bool { self == (*other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &float) -> bool { (*self) == (*other) }
#[cfg(stage0)]
pub pure fn ne(other: &float) -> bool { self != (*other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &float) -> bool { (*self) != (*other) }
}
impl float : Ord {
#[cfg(stage0)]
pub pure fn lt(other: &float) -> bool { self < (*other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn lt(&self, other: &float) -> bool { (*self) < (*other) }
#[cfg(stage0)]
pub pure fn le(other: &float) -> bool { self <= (*other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn le(&self, other: &float) -> bool { (*self) <= (*other) }
#[cfg(stage0)]
pub pure fn ge(other: &float) -> bool { self >= (*other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ge(&self, other: &float) -> bool { (*self) >= (*other) }
#[cfg(stage0)]
pub pure fn gt(other: &float) -> bool { self > (*other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn gt(&self, other: &float) -> bool { (*self) > (*other) }
}
impl float: num::Num {

View File

@ -55,15 +55,39 @@ pub pure fn abs(i: T) -> T {
}
impl T : Ord {
#[cfg(stage0)]
pure fn lt(other: &T) -> bool { return self < (*other); }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn lt(&self, other: &T) -> bool { return (*self) < (*other); }
#[cfg(stage0)]
pure fn le(other: &T) -> bool { return self <= (*other); }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn le(&self, other: &T) -> bool { return (*self) <= (*other); }
#[cfg(stage0)]
pure fn ge(other: &T) -> bool { return self >= (*other); }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ge(&self, other: &T) -> bool { return (*self) >= (*other); }
#[cfg(stage0)]
pure fn gt(other: &T) -> bool { return self > (*other); }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn gt(&self, other: &T) -> bool { return (*self) > (*other); }
}
impl T : Eq {
#[cfg(stage0)]
pure fn eq(other: &T) -> bool { return self == (*other); }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &T) -> bool { return (*self) == (*other); }
#[cfg(stage0)]
pure fn ne(other: &T) -> bool { return self != (*other); }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &T) -> bool { return (*self) != (*other); }
}
impl T: num::Num {

View File

@ -523,13 +523,26 @@ pub enum FileFlag { Append, Create, Truncate, NoFlag, }
pub enum WriterType { Screen, File }
pub impl WriterType : Eq {
#[cfg(stage0)]
pure fn eq(other: &WriterType) -> bool {
match (self, (*other)) {
(Screen, Screen) | (File, File) => true,
(Screen, _) | (File, _) => false
}
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &WriterType) -> bool {
match ((*self), (*other)) {
(Screen, Screen) | (File, File) => true,
(Screen, _) | (File, _) => false
}
}
#[cfg(stage0)]
pure fn ne(other: &WriterType) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &WriterType) -> bool { !(*self).eq(other) }
}
// FIXME (#2004): Seekable really should be orthogonal.

View File

@ -301,6 +301,7 @@ impl<T: Copy> Option<T> {
}
impl<T: Eq> Option<T> : Eq {
#[cfg(stage0)]
pure fn eq(other: &Option<T>) -> bool {
match self {
None => {
@ -318,7 +319,30 @@ impl<T: Eq> Option<T> : Eq {
}
}
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &Option<T>) -> bool {
match (*self) {
None => {
match (*other) {
None => true,
Some(_) => false
}
}
Some(ref self_contents) => {
match (*other) {
None => false,
Some(ref other_contents) =>
(*self_contents).eq(other_contents)
}
}
}
}
#[cfg(stage0)]
pure fn ne(other: &Option<T>) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &Option<T>) -> bool { !(*self).eq(other) }
}
#[test]

View File

@ -7,14 +7,38 @@
use cmp::{Eq, Ord};
impl<T:Eq> ~const T : Eq {
#[cfg(stage0)]
pure fn eq(other: &~const T) -> bool { *self == *(*other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &~const T) -> bool { *(*self) == *(*other) }
#[cfg(stage0)]
pure fn ne(other: &~const T) -> bool { *self != *(*other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &~const T) -> bool { *(*self) != *(*other) }
}
impl<T:Ord> ~const T : Ord {
#[cfg(stage0)]
pure fn lt(other: &~const T) -> bool { *self < *(*other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn lt(&self, other: &~const T) -> bool { *(*self) < *(*other) }
#[cfg(stage0)]
pure fn le(other: &~const T) -> bool { *self <= *(*other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn le(&self, other: &~const T) -> bool { *(*self) <= *(*other) }
#[cfg(stage0)]
pure fn ge(other: &~const T) -> bool { *self >= *(*other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ge(&self, other: &~const T) -> bool { *(*self) >= *(*other) }
#[cfg(stage0)]
pure fn gt(other: &~const T) -> bool { *self > *(*other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn gt(&self, other: &~const T) -> bool { *(*self) > *(*other) }
}

View File

@ -71,21 +71,45 @@ impl PosixPath : ToStr {
}
impl PosixPath : Eq {
#[cfg(stage0)]
pure fn eq(other: &PosixPath) -> bool {
return self.is_absolute == (*other).is_absolute &&
self.components == (*other).components;
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &PosixPath) -> bool {
return (*self).is_absolute == (*other).is_absolute &&
(*self).components == (*other).components;
}
#[cfg(stage0)]
pure fn ne(other: &PosixPath) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &PosixPath) -> bool { !(*self).eq(other) }
}
impl WindowsPath : Eq {
#[cfg(stage0)]
pure fn eq(other: &WindowsPath) -> bool {
return self.host == (*other).host &&
self.device == (*other).device &&
self.is_absolute == (*other).is_absolute &&
self.components == (*other).components;
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &WindowsPath) -> bool {
return (*self).host == (*other).host &&
(*self).device == (*other).device &&
(*self).is_absolute == (*other).is_absolute &&
(*self).components == (*other).components;
}
#[cfg(stage0)]
pure fn ne(other: &WindowsPath) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &WindowsPath) -> bool { !(*self).eq(other) }
}
// FIXME (#3227): when default methods in traits are working, de-duplicate

View File

@ -98,10 +98,20 @@ enum State {
}
impl State : Eq {
#[cfg(stage0)]
pure fn eq(other: &State) -> bool {
(self as uint) == ((*other) as uint)
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &State) -> bool {
((*self) as uint) == ((*other) as uint)
}
#[cfg(stage0)]
pure fn ne(other: &State) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &State) -> bool { !(*self).eq(other) }
}
pub struct BufferHeader {

View File

@ -208,50 +208,130 @@ impl<T> *mut T: Ptr<T> {
// Equality for pointers
impl<T> *const T : Eq {
#[cfg(stage0)]
pure fn eq(other: &*const T) -> bool unsafe {
let a: uint = cast::reinterpret_cast(&self);
let b: uint = cast::reinterpret_cast(&(*other));
return a == b;
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &*const T) -> bool unsafe {
let a: uint = cast::reinterpret_cast(&(*self));
let b: uint = cast::reinterpret_cast(&(*other));
return a == b;
}
#[cfg(stage0)]
pure fn ne(other: &*const T) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &*const T) -> bool { !(*self).eq(other) }
}
// Comparison for pointers
impl<T> *const T : Ord {
#[cfg(stage0)]
pure fn lt(other: &*const T) -> bool unsafe {
let a: uint = cast::reinterpret_cast(&self);
let b: uint = cast::reinterpret_cast(&(*other));
return a < b;
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn lt(&self, other: &*const T) -> bool unsafe {
let a: uint = cast::reinterpret_cast(&(*self));
let b: uint = cast::reinterpret_cast(&(*other));
return a < b;
}
#[cfg(stage0)]
pure fn le(other: &*const T) -> bool unsafe {
let a: uint = cast::reinterpret_cast(&self);
let b: uint = cast::reinterpret_cast(&(*other));
return a <= b;
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn le(&self, other: &*const T) -> bool unsafe {
let a: uint = cast::reinterpret_cast(&(*self));
let b: uint = cast::reinterpret_cast(&(*other));
return a <= b;
}
#[cfg(stage0)]
pure fn ge(other: &*const T) -> bool unsafe {
let a: uint = cast::reinterpret_cast(&self);
let b: uint = cast::reinterpret_cast(&(*other));
return a >= b;
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ge(&self, other: &*const T) -> bool unsafe {
let a: uint = cast::reinterpret_cast(&(*self));
let b: uint = cast::reinterpret_cast(&(*other));
return a >= b;
}
#[cfg(stage0)]
pure fn gt(other: &*const T) -> bool unsafe {
let a: uint = cast::reinterpret_cast(&self);
let b: uint = cast::reinterpret_cast(&(*other));
return a > b;
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn gt(&self, other: &*const T) -> bool unsafe {
let a: uint = cast::reinterpret_cast(&(*self));
let b: uint = cast::reinterpret_cast(&(*other));
return a > b;
}
}
// Equality for region pointers
impl<T:Eq> &const T : Eq {
#[cfg(stage0)]
pure fn eq(other: & &self/const T) -> bool { return *self == *(*other); }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: & &self/const T) -> bool {
return *(*self) == *(*other);
}
#[cfg(stage0)]
pure fn ne(other: & &self/const T) -> bool { return *self != *(*other); }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: & &self/const T) -> bool {
return *(*self) != *(*other);
}
}
// Comparison for region pointers
impl<T:Ord> &const T : Ord {
#[cfg(stage0)]
pure fn lt(other: & &self/const T) -> bool { *self < *(*other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn lt(&self, other: & &self/const T) -> bool {
*(*self) < *(*other)
}
#[cfg(stage0)]
pure fn le(other: & &self/const T) -> bool { *self <= *(*other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn le(&self, other: & &self/const T) -> bool {
*(*self) <= *(*other)
}
#[cfg(stage0)]
pure fn ge(other: & &self/const T) -> bool { *self >= *(*other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ge(&self, other: & &self/const T) -> bool {
*(*self) >= *(*other)
}
#[cfg(stage0)]
pure fn gt(other: & &self/const T) -> bool { *self > *(*other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn gt(&self, other: & &self/const T) -> bool {
*(*self) > *(*other)
}
}
#[test]

View File

@ -516,10 +516,20 @@ enum EnumVisitState {
}
impl EnumVisitState : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &EnumVisitState) -> bool {
(self as uint) == ((*other) as uint)
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &EnumVisitState) -> bool {
((*self) as uint) == ((*other) as uint)
}
#[cfg(stage0)]
pure fn ne(other: &EnumVisitState) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &EnumVisitState) -> bool { !(*self).eq(other) }
}
struct EnumState {

View File

@ -365,6 +365,7 @@ pub fn unwrap_err<T, U>(res: Result<T, U>) -> U {
}
impl<T:Eq,U:Eq> Result<T,U> : Eq {
#[cfg(stage0)]
pure fn eq(other: &Result<T,U>) -> bool {
match self {
Ok(ref e0a) => {
@ -381,7 +382,29 @@ impl<T:Eq,U:Eq> Result<T,U> : Eq {
}
}
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &Result<T,U>) -> bool {
match (*self) {
Ok(ref e0a) => {
match (*other) {
Ok(ref e0b) => *e0a == *e0b,
_ => false
}
}
Err(ref e0a) => {
match (*other) {
Err(ref e0b) => *e0a == *e0b,
_ => false
}
}
}
}
#[cfg(stage0)]
pure fn ne(other: &Result<T,U>) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &Result<T,U>) -> bool { !(*self).eq(other) }
}
#[cfg(test)]

View File

@ -737,62 +737,140 @@ pure fn gt(a: &str, b: &str) -> bool {
impl &str : Eq {
#[inline(always)]
#[cfg(stage0)]
pure fn eq(other: & &self/str) -> bool {
eq_slice(self, (*other))
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: & &self/str) -> bool {
eq_slice((*self), (*other))
}
#[inline(always)]
#[cfg(stage0)]
pure fn ne(other: & &self/str) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: & &self/str) -> bool { !(*self).eq(other) }
}
impl ~str : Eq {
#[inline(always)]
#[cfg(stage0)]
pure fn eq(other: &~str) -> bool {
eq_slice(self, (*other))
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &~str) -> bool {
eq_slice((*self), (*other))
}
#[inline(always)]
#[cfg(stage0)]
pure fn ne(other: &~str) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &~str) -> bool { !(*self).eq(other) }
}
impl @str : Eq {
#[inline(always)]
#[cfg(stage0)]
pure fn eq(other: &@str) -> bool {
eq_slice(self, (*other))
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &@str) -> bool {
eq_slice((*self), (*other))
}
#[inline(always)]
#[cfg(stage0)]
pure fn ne(other: &@str) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &@str) -> bool { !(*self).eq(other) }
}
impl ~str : Ord {
#[inline(always)]
#[cfg(stage0)]
pure fn lt(other: &~str) -> bool { lt(self, (*other)) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn lt(&self, other: &~str) -> bool { lt((*self), (*other)) }
#[inline(always)]
#[cfg(stage0)]
pure fn le(other: &~str) -> bool { le(self, (*other)) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn le(&self, other: &~str) -> bool { le((*self), (*other)) }
#[inline(always)]
#[cfg(stage0)]
pure fn ge(other: &~str) -> bool { ge(self, (*other)) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ge(&self, other: &~str) -> bool { ge((*self), (*other)) }
#[inline(always)]
#[cfg(stage0)]
pure fn gt(other: &~str) -> bool { gt(self, (*other)) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn gt(&self, other: &~str) -> bool { gt((*self), (*other)) }
}
impl &str : Ord {
#[inline(always)]
#[cfg(stage0)]
pure fn lt(other: & &self/str) -> bool { lt(self, (*other)) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn lt(&self, other: & &self/str) -> bool { lt((*self), (*other)) }
#[inline(always)]
#[cfg(stage0)]
pure fn le(other: & &self/str) -> bool { le(self, (*other)) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn le(&self, other: & &self/str) -> bool { le((*self), (*other)) }
#[inline(always)]
#[cfg(stage0)]
pure fn ge(other: & &self/str) -> bool { ge(self, (*other)) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ge(&self, other: & &self/str) -> bool { ge((*self), (*other)) }
#[inline(always)]
#[cfg(stage0)]
pure fn gt(other: & &self/str) -> bool { gt(self, (*other)) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn gt(&self, other: & &self/str) -> bool { gt((*self), (*other)) }
}
impl @str : Ord {
#[inline(always)]
#[cfg(stage0)]
pure fn lt(other: &@str) -> bool { lt(self, (*other)) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn lt(&self, other: &@str) -> bool { lt((*self), (*other)) }
#[inline(always)]
#[cfg(stage0)]
pure fn le(other: &@str) -> bool { le(self, (*other)) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn le(&self, other: &@str) -> bool { le((*self), (*other)) }
#[inline(always)]
#[cfg(stage0)]
pure fn ge(other: &@str) -> bool { ge(self, (*other)) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ge(&self, other: &@str) -> bool { ge((*self), (*other)) }
#[inline(always)]
#[cfg(stage0)]
pure fn gt(other: &@str) -> bool { gt(self, (*other)) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn gt(&self, other: &@str) -> bool { gt((*self), (*other)) }
}
/*

View File

@ -43,8 +43,16 @@ pub enum Task {
}
impl Task : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &Task) -> bool { *self == *(*other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &Task) -> bool { *(*self) == *(*other) }
#[cfg(stage0)]
pure fn ne(other: &Task) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &Task) -> bool { !(*self).eq(other) }
}
/**
@ -64,13 +72,26 @@ pub enum TaskResult {
}
impl TaskResult : Eq {
#[cfg(stage0)]
pure fn eq(other: &TaskResult) -> bool {
match (self, (*other)) {
(Success, Success) | (Failure, Failure) => true,
(Success, _) | (Failure, _) => false
}
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &TaskResult) -> bool {
match ((*self), (*other)) {
(Success, Success) | (Failure, Failure) => true,
(Success, _) | (Failure, _) => false
}
}
#[cfg(stage0)]
pure fn ne(other: &TaskResult) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &TaskResult) -> bool { !(*self).eq(other) }
}
/// Scheduler modes
@ -93,6 +114,7 @@ pub enum SchedMode {
}
impl SchedMode : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &SchedMode) -> bool {
match self {
SingleThreaded => {
@ -127,9 +149,51 @@ impl SchedMode : cmp::Eq {
}
}
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &SchedMode) -> bool {
match (*self) {
SingleThreaded => {
match (*other) {
SingleThreaded => true,
_ => false
}
}
ThreadPerCore => {
match (*other) {
ThreadPerCore => true,
_ => false
}
}
ThreadPerTask => {
match (*other) {
ThreadPerTask => true,
_ => false
}
}
ManualThreads(e0a) => {
match (*other) {
ManualThreads(e0b) => e0a == e0b,
_ => false
}
}
PlatformThread => {
match (*other) {
PlatformThread => true,
_ => false
}
}
}
}
#[cfg(stage0)]
pure fn ne(other: &SchedMode) -> bool {
!self.eq(other)
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &SchedMode) -> bool {
!(*self).eq(other)
}
}
/**

View File

@ -7,12 +7,24 @@ pub trait LocalData { }
impl<T: Owned> @T: LocalData { }
impl LocalData: Eq {
#[cfg(stage0)]
pure fn eq(other: &@LocalData) -> bool unsafe {
let ptr_a: (uint, uint) = cast::reinterpret_cast(&self);
let ptr_b: (uint, uint) = cast::reinterpret_cast(other);
return ptr_a == ptr_b;
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &@LocalData) -> bool unsafe {
let ptr_a: (uint, uint) = cast::reinterpret_cast(&(*self));
let ptr_b: (uint, uint) = cast::reinterpret_cast(other);
return ptr_a == ptr_b;
}
#[cfg(stage0)]
pure fn ne(other: &@LocalData) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &@LocalData) -> bool { !(*self).eq(other) }
}
// We use dvec because it's the best data structure in core. If TLS is used

View File

@ -95,6 +95,7 @@ impl<A: Copy, B: Copy> (~[A], ~[B]): ExtendedTupleOps<A,B> {
}
impl<A: Eq, B: Eq> (A, B) : Eq {
#[cfg(stage0)]
pure fn eq(other: &(A, B)) -> bool {
match self {
(ref self_a, ref self_b) => match other {
@ -104,10 +105,26 @@ impl<A: Eq, B: Eq> (A, B) : Eq {
}
}
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &(A, B)) -> bool {
match (*self) {
(ref self_a, ref self_b) => match other {
&(ref other_a, ref other_b) => {
(*self_a).eq(other_a) && (*self_b).eq(other_b)
}
}
}
}
#[cfg(stage0)]
pure fn ne(other: &(A, B)) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &(A, B)) -> bool { !(*self).eq(other) }
}
impl<A: Ord, B: Ord> (A, B) : Ord {
#[cfg(stage0)]
pure fn lt(other: &(A, B)) -> bool {
match self {
(ref self_a, ref self_b) => {
@ -122,12 +139,41 @@ impl<A: Ord, B: Ord> (A, B) : Ord {
}
}
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn lt(&self, other: &(A, B)) -> bool {
match (*self) {
(ref self_a, ref self_b) => {
match (*other) {
(ref other_a, ref other_b) => {
if (*self_a).lt(other_a) { return true; }
if (*other_a).lt(self_a) { return false; }
if (*self_b).lt(other_b) { return true; }
return false;
}
}
}
}
}
#[cfg(stage0)]
pure fn le(other: &(A, B)) -> bool { !(*other).lt(&self) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn le(&self, other: &(A, B)) -> bool { !(*other).lt(&(*self)) }
#[cfg(stage0)]
pure fn ge(other: &(A, B)) -> bool { !self.lt(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ge(&self, other: &(A, B)) -> bool { !(*self).lt(other) }
#[cfg(stage0)]
pure fn gt(other: &(A, B)) -> bool { (*other).lt(&self) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn gt(&self, other: &(A, B)) -> bool { (*other).lt(&(*self)) }
}
impl<A: Eq, B: Eq, C: Eq> (A, B, C) : Eq {
#[cfg(stage0)]
pure fn eq(other: &(A, B, C)) -> bool {
match self {
(ref self_a, ref self_b, ref self_c) => match other {
@ -138,10 +184,27 @@ impl<A: Eq, B: Eq, C: Eq> (A, B, C) : Eq {
}
}
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &(A, B, C)) -> bool {
match (*self) {
(ref self_a, ref self_b, ref self_c) => match other {
&(ref other_a, ref other_b, ref other_c) => {
(*self_a).eq(other_a) && (*self_b).eq(other_b)
&& (*self_c).eq(other_c)
}
}
}
}
#[cfg(stage0)]
pure fn ne(other: &(A, B, C)) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &(A, B, C)) -> bool { !(*self).eq(other) }
}
impl<A: Ord, B: Ord, C: Ord> (A, B, C) : Ord {
#[cfg(stage0)]
pure fn lt(other: &(A, B, C)) -> bool {
match self {
(ref self_a, ref self_b, ref self_c) => {
@ -158,9 +221,39 @@ impl<A: Ord, B: Ord, C: Ord> (A, B, C) : Ord {
}
}
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn lt(&self, other: &(A, B, C)) -> bool {
match (*self) {
(ref self_a, ref self_b, ref self_c) => {
match (*other) {
(ref other_a, ref other_b, ref other_c) => {
if (*self_a).lt(other_a) { return true; }
if (*other_a).lt(self_a) { return false; }
if (*self_b).lt(other_b) { return true; }
if (*other_b).lt(self_b) { return false; }
if (*self_c).lt(other_c) { return true; }
return false;
}
}
}
}
}
#[cfg(stage0)]
pure fn le(other: &(A, B, C)) -> bool { !(*other).lt(&self) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn le(&self, other: &(A, B, C)) -> bool { !(*other).lt(&(*self)) }
#[cfg(stage0)]
pure fn ge(other: &(A, B, C)) -> bool { !self.lt(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ge(&self, other: &(A, B, C)) -> bool { !(*self).lt(other) }
#[cfg(stage0)]
pure fn gt(other: &(A, B, C)) -> bool { (*other).lt(&self) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn gt(&self, other: &(A, B, C)) -> bool { (*other).lt(&(*self)) }
}
#[test]

View File

@ -49,15 +49,39 @@ pub pure fn compl(i: T) -> T {
}
impl T : Ord {
#[cfg(stage0)]
pure fn lt(other: &T) -> bool { self < (*other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn lt(&self, other: &T) -> bool { (*self) < (*other) }
#[cfg(stage0)]
pure fn le(other: &T) -> bool { self <= (*other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn le(&self, other: &T) -> bool { (*self) <= (*other) }
#[cfg(stage0)]
pure fn ge(other: &T) -> bool { self >= (*other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ge(&self, other: &T) -> bool { (*self) >= (*other) }
#[cfg(stage0)]
pure fn gt(other: &T) -> bool { self > (*other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn gt(&self, other: &T) -> bool { (*self) > (*other) }
}
impl T : Eq {
#[cfg(stage0)]
pure fn eq(other: &T) -> bool { return self == (*other); }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &T) -> bool { return (*self) == (*other); }
#[cfg(stage0)]
pure fn ne(other: &T) -> bool { return self != (*other); }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &T) -> bool { return (*self) != (*other); }
}
impl T: num::Num {

View File

@ -11,14 +11,38 @@ Functions for the unit type.
use cmp::{Eq, Ord};
impl () : Eq {
#[cfg(stage0)]
pure fn eq(_other: &()) -> bool { true }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, _other: &()) -> bool { true }
#[cfg(stage0)]
pure fn ne(_other: &()) -> bool { false }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, _other: &()) -> bool { false }
}
impl () : Ord {
#[cfg(stage0)]
pure fn lt(_other: &()) -> bool { false }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn lt(&self, _other: &()) -> bool { false }
#[cfg(stage0)]
pure fn le(_other: &()) -> bool { true }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn le(&self, _other: &()) -> bool { true }
#[cfg(stage0)]
pure fn ge(_other: &()) -> bool { true }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ge(&self, _other: &()) -> bool { true }
#[cfg(stage0)]
pure fn gt(_other: &()) -> bool { false }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn gt(&self, _other: &()) -> bool { false }
}

View File

@ -1319,24 +1319,48 @@ pure fn eq<T: Eq>(a: &[T], b: &[T]) -> bool {
impl<T: Eq> &[T] : Eq {
#[inline(always)]
#[cfg(stage0)]
pure fn eq(other: & &self/[T]) -> bool { eq(self, (*other)) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: & &self/[T]) -> bool { eq((*self), (*other)) }
#[inline(always)]
#[cfg(stage0)]
pure fn ne(other: & &self/[T]) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: & &self/[T]) -> bool { !(*self).eq(other) }
}
impl<T: Eq> ~[T] : Eq {
#[inline(always)]
#[cfg(stage0)]
pure fn eq(other: &~[T]) -> bool { eq(self, (*other)) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &~[T]) -> bool { eq((*self), (*other)) }
#[inline(always)]
#[cfg(stage0)]
pure fn ne(other: &~[T]) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &~[T]) -> bool { !(*self).eq(other) }
}
impl<T: Eq> @[T] : Eq {
#[inline(always)]
#[cfg(stage0)]
pure fn eq(other: &@[T]) -> bool { eq(self, (*other)) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &@[T]) -> bool { eq((*self), (*other)) }
#[inline(always)]
#[cfg(stage0)]
pure fn ne(other: &@[T]) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &@[T]) -> bool { !(*self).eq(other) }
}
// Lexicographical comparison
@ -1362,35 +1386,83 @@ pure fn gt<T: Ord>(a: &[T], b: &[T]) -> bool { lt(b, a) }
impl<T: Ord> &[T] : Ord {
#[inline(always)]
#[cfg(stage0)]
pure fn lt(other: & &self/[T]) -> bool { lt(self, (*other)) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn lt(&self, other: & &self/[T]) -> bool { lt((*self), (*other)) }
#[inline(always)]
#[cfg(stage0)]
pure fn le(other: & &self/[T]) -> bool { le(self, (*other)) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn le(&self, other: & &self/[T]) -> bool { le((*self), (*other)) }
#[inline(always)]
#[cfg(stage0)]
pure fn ge(other: & &self/[T]) -> bool { ge(self, (*other)) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ge(&self, other: & &self/[T]) -> bool { ge((*self), (*other)) }
#[inline(always)]
#[cfg(stage0)]
pure fn gt(other: & &self/[T]) -> bool { gt(self, (*other)) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn gt(&self, other: & &self/[T]) -> bool { gt((*self), (*other)) }
}
impl<T: Ord> ~[T] : Ord {
#[inline(always)]
#[cfg(stage0)]
pure fn lt(other: &~[T]) -> bool { lt(self, (*other)) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn lt(&self, other: &~[T]) -> bool { lt((*self), (*other)) }
#[inline(always)]
#[cfg(stage0)]
pure fn le(other: &~[T]) -> bool { le(self, (*other)) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn le(&self, other: &~[T]) -> bool { le((*self), (*other)) }
#[inline(always)]
#[cfg(stage0)]
pure fn ge(other: &~[T]) -> bool { ge(self, (*other)) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ge(&self, other: &~[T]) -> bool { ge((*self), (*other)) }
#[inline(always)]
#[cfg(stage0)]
pure fn gt(other: &~[T]) -> bool { gt(self, (*other)) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn gt(&self, other: &~[T]) -> bool { gt((*self), (*other)) }
}
impl<T: Ord> @[T] : Ord {
#[inline(always)]
#[cfg(stage0)]
pure fn lt(other: &@[T]) -> bool { lt(self, (*other)) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn lt(&self, other: &@[T]) -> bool { lt((*self), (*other)) }
#[inline(always)]
#[cfg(stage0)]
pure fn le(other: &@[T]) -> bool { le(self, (*other)) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn le(&self, other: &@[T]) -> bool { le((*self), (*other)) }
#[inline(always)]
#[cfg(stage0)]
pure fn ge(other: &@[T]) -> bool { ge(self, (*other)) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ge(&self, other: &@[T]) -> bool { ge((*self), (*other)) }
#[inline(always)]
#[cfg(stage0)]
pure fn gt(other: &@[T]) -> bool { gt(self, (*other)) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn gt(&self, other: &@[T]) -> bool { gt((*self), (*other)) }
}
#[cfg(notest)]

View File

@ -10,6 +10,7 @@ use syntax::diagnostic;
enum test_mode { tm_converge, tm_run, }
type context = { mode: test_mode }; // + rng
#[cfg(stage0)]
impl test_mode : cmp::Eq {
pure fn eq(other: &test_mode) -> bool {
(self as uint) == ((*other) as uint)
@ -17,6 +18,15 @@ impl test_mode : cmp::Eq {
pure fn ne(other: &test_mode) -> bool { !self.eq(other) }
}
#[cfg(stage1)]
#[cfg(stage2)]
impl test_mode : cmp::Eq {
pure fn eq(&self, other: &test_mode) -> bool {
((*self) as uint) == ((*other) as uint)
}
pure fn ne(&self, other: &test_mode) -> bool { !(*self).eq(other) }
}
fn write_file(filename: &Path, content: ~str) {
result::get(
&io::file_writer(filename, ~[io::Create, io::Truncate]))

View File

@ -27,10 +27,20 @@ enum output_type {
}
impl output_type : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &output_type) -> bool {
(self as uint) == ((*other) as uint)
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &output_type) -> bool {
((*self) as uint) == ((*other) as uint)
}
#[cfg(stage0)]
pure fn ne(other: &output_type) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &output_type) -> bool { !(*self).eq(other) }
}
fn llvm_err(sess: Session, msg: ~str) -> ! unsafe {

View File

@ -141,10 +141,20 @@ enum compile_upto {
}
impl compile_upto : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &compile_upto) -> bool {
(self as uint) == ((*other) as uint)
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &compile_upto) -> bool {
((*self) as uint) == ((*other) as uint)
}
#[cfg(stage0)]
pure fn ne(other: &compile_upto) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &compile_upto) -> bool { !(*self).eq(other) }
}
fn compile_upto(sess: Session, cfg: ast::crate_cfg,

View File

@ -13,19 +13,39 @@ use middle::lint;
enum os { os_win32, os_macos, os_linux, os_freebsd, }
impl os : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &os) -> bool {
(self as uint) == ((*other) as uint)
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &os) -> bool {
((*self) as uint) == ((*other) as uint)
}
#[cfg(stage0)]
pure fn ne(other: &os) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &os) -> bool { !(*self).eq(other) }
}
enum arch { arch_x86, arch_x86_64, arch_arm, }
impl arch : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &arch) -> bool {
(self as uint) == ((*other) as uint)
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &arch) -> bool {
((*self) as uint) == ((*other) as uint)
}
#[cfg(stage0)]
pure fn ne(other: &arch) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &arch) -> bool { !(*self).eq(other) }
}
enum crate_type { bin_crate, lib_crate, unknown_crate, }
@ -91,10 +111,20 @@ enum OptLevel {
}
impl OptLevel : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &OptLevel) -> bool {
(self as uint) == ((*other) as uint)
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &OptLevel) -> bool {
((*self) as uint) == ((*other) as uint)
}
#[cfg(stage0)]
pure fn ne(other: &OptLevel) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &OptLevel) -> bool { !(*self).eq(other) }
}
type options =

View File

@ -131,6 +131,7 @@ enum TypeKind {
}
impl TypeKind : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &TypeKind) -> bool {
match (self, (*other)) {
(Void, Void) => true,
@ -167,7 +168,49 @@ impl TypeKind : cmp::Eq {
(X86_MMX, _) => false,
}
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &TypeKind) -> bool {
match ((*self), (*other)) {
(Void, Void) => true,
(Half, Half) => true,
(Float, Float) => true,
(Double, Double) => true,
(X86_FP80, X86_FP80) => true,
(FP128, FP128) => true,
(PPC_FP128, PPC_FP128) => true,
(Label, Label) => true,
(Integer, Integer) => true,
(Function, Function) => true,
(Struct, Struct) => true,
(Array, Array) => true,
(Pointer, Pointer) => true,
(Vector, Vector) => true,
(Metadata, Metadata) => true,
(X86_MMX, X86_MMX) => true,
(Void, _) => false,
(Half, _) => false,
(Float, _) => false,
(Double, _) => false,
(X86_FP80, _) => false,
(FP128, _) => false,
(PPC_FP128, _) => false,
(Label, _) => false,
(Integer, _) => false,
(Function, _) => false,
(Struct, _) => false,
(Array, _) => false,
(Pointer, _) => false,
(Vector, _) => false,
(Metadata, _) => false,
(X86_MMX, _) => false,
}
}
#[cfg(stage0)]
pure fn ne(other: &TypeKind) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &TypeKind) -> bool { !(*self).eq(other) }
}
enum AtomicBinOp {

View File

@ -139,10 +139,20 @@ enum Family {
}
impl Family : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &Family) -> bool {
(self as uint) == ((*other) as uint)
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &Family) -> bool {
((*self) as uint) == ((*other) as uint)
}
#[cfg(stage0)]
pure fn ne(other: &Family) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &Family) -> bool { !(*self).eq(other) }
}
fn item_family(item: ebml::Doc) -> Family {

View File

@ -323,6 +323,7 @@ enum bckerr_code {
}
impl bckerr_code : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &bckerr_code) -> bool {
match self {
err_mut_uniq => {
@ -364,7 +365,54 @@ impl bckerr_code : cmp::Eq {
}
}
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &bckerr_code) -> bool {
match (*self) {
err_mut_uniq => {
match (*other) {
err_mut_uniq => true,
_ => false
}
}
err_mut_variant => {
match (*other) {
err_mut_variant => true,
_ => false
}
}
err_root_not_permitted => {
match (*other) {
err_root_not_permitted => true,
_ => false
}
}
err_mutbl(e0a) => {
match (*other) {
err_mutbl(e0b) => e0a == e0b,
_ => false
}
}
err_out_of_root_scope(e0a, e1a) => {
match (*other) {
err_out_of_root_scope(e0b, e1b) =>
e0a == e0b && e1a == e1b,
_ => false
}
}
err_out_of_scope(e0a, e1a) => {
match (*other) {
err_out_of_scope(e0b, e1b) => e0a == e0b && e1a == e1b,
_ => false
}
}
}
}
#[cfg(stage0)]
pure fn ne(other: &bckerr_code) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &bckerr_code) -> bool { !(*self).eq(other) }
}
// Combination of an error code and the categorization of the expression
@ -372,10 +420,20 @@ impl bckerr_code : cmp::Eq {
type bckerr = {cmt: cmt, code: bckerr_code};
impl bckerr : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &bckerr) -> bool {
self.cmt == (*other).cmt && self.code == (*other).code
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &bckerr) -> bool {
(*self).cmt == (*other).cmt && (*self).code == (*other).code
}
#[cfg(stage0)]
pure fn ne(other: &bckerr) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &bckerr) -> bool { !(*self).eq(other) }
}
// shorthand for something that fails with `bckerr` or succeeds with `T`
@ -405,12 +463,24 @@ fn save_and_restore<T:Copy,U>(save_and_restore_t: &mut T, f: fn() -> U) -> U {
/// Creates and returns a new root_map
impl root_map_key : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &root_map_key) -> bool {
self.id == (*other).id && self.derefs == (*other).derefs
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &root_map_key) -> bool {
(*self).id == (*other).id && (*self).derefs == (*other).derefs
}
#[cfg(stage0)]
pure fn ne(other: &root_map_key) -> bool {
! (self == (*other))
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &root_map_key) -> bool {
! ((*self) == (*other))
}
}
impl root_map_key : to_bytes::IterBytes {

View File

@ -33,6 +33,7 @@ enum purity_cause {
}
impl purity_cause : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &purity_cause) -> bool {
match self {
pc_pure_fn => {
@ -49,7 +50,29 @@ impl purity_cause : cmp::Eq {
}
}
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &purity_cause) -> bool {
match (*self) {
pc_pure_fn => {
match (*other) {
pc_pure_fn => true,
_ => false
}
}
pc_cmt(e0a) => {
match (*other) {
pc_cmt(e0b) => e0a == e0b,
_ => false
}
}
}
}
#[cfg(stage0)]
pure fn ne(other: &purity_cause) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &purity_cause) -> bool { !(*self).eq(other) }
}
fn check_loans(bccx: borrowck_ctxt,
@ -74,10 +97,20 @@ enum assignment_type {
}
impl assignment_type : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &assignment_type) -> bool {
(self as uint) == ((*other) as uint)
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &assignment_type) -> bool {
((*self) as uint) == ((*other) as uint)
}
#[cfg(stage0)]
pure fn ne(other: &assignment_type) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &assignment_type) -> bool { !(*self).eq(other) }
}
impl assignment_type {

View File

@ -126,6 +126,7 @@ enum ctor {
}
impl ctor : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &ctor) -> bool {
match (self, (*other)) {
(single, single) => true,
@ -139,7 +140,26 @@ impl ctor : cmp::Eq {
}
}
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &ctor) -> bool {
match ((*self), (*other)) {
(single, single) => true,
(variant(did_self), variant(did_other)) => did_self == did_other,
(val(cv_self), val(cv_other)) => cv_self == cv_other,
(range(cv0_self, cv1_self), range(cv0_other, cv1_other)) => {
cv0_self == cv0_other && cv1_self == cv1_other
}
(single, _) | (variant(_), _) | (val(_), _) | (range(*), _) => {
false
}
}
}
#[cfg(stage0)]
pure fn ne(other: &ctor) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &ctor) -> bool { !(*self).eq(other) }
}
// Algorithm from http://moscova.inria.fr/~maranget/papers/warn/index.html

View File

@ -206,6 +206,7 @@ enum const_val {
}
impl const_val : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &const_val) -> bool {
match (self, (*other)) {
(const_float(a), const_float(b)) => a == b,
@ -217,7 +218,24 @@ impl const_val : cmp::Eq {
(const_str(_), _) | (const_bool(_), _) => false
}
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &const_val) -> bool {
match ((*self), (*other)) {
(const_float(a), const_float(b)) => a == b,
(const_int(a), const_int(b)) => a == b,
(const_uint(a), const_uint(b)) => a == b,
(const_str(a), const_str(b)) => a == b,
(const_bool(a), const_bool(b)) => a == b,
(const_float(_), _) | (const_int(_), _) | (const_uint(_), _) |
(const_str(_), _) | (const_bool(_), _) => false
}
}
#[cfg(stage0)]
pure fn ne(other: &const_val) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &const_val) -> bool { !(*self).eq(other) }
}
fn eval_const_expr(tcx: middle::ty::ctxt, e: @expr) -> const_val {

View File

@ -68,10 +68,20 @@ enum lint {
}
impl lint : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &lint) -> bool {
(self as uint) == ((*other) as uint)
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &lint) -> bool {
((*self) as uint) == ((*other) as uint)
}
#[cfg(stage0)]
pure fn ne(other: &lint) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &lint) -> bool { !(*self).eq(other) }
}
fn level_to_str(lv: level) -> ~str {
@ -88,10 +98,20 @@ enum level {
}
impl level : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &level) -> bool {
(self as uint) == ((*other) as uint)
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &level) -> bool {
((*self) as uint) == ((*other) as uint)
}
#[cfg(stage0)]
pure fn ne(other: &level) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &level) -> bool { !(*self).eq(other) }
}
type lint_spec = @{lint: lint,

View File

@ -119,13 +119,29 @@ enum Variable = uint;
enum LiveNode = uint;
impl Variable : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &Variable) -> bool { *self == *(*other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &Variable) -> bool { *(*self) == *(*other) }
#[cfg(stage0)]
pure fn ne(other: &Variable) -> bool { *self != *(*other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &Variable) -> bool { *(*self) != *(*other) }
}
impl LiveNode : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &LiveNode) -> bool { *self == *(*other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &LiveNode) -> bool { *(*self) == *(*other) }
#[cfg(stage0)]
pure fn ne(other: &LiveNode) -> bool { *self != *(*other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &LiveNode) -> bool { *(*self) != *(*other) }
}
enum LiveNodeKind {
@ -136,6 +152,7 @@ enum LiveNodeKind {
}
impl LiveNodeKind : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &LiveNodeKind) -> bool {
match self {
FreeVarNode(e0a) => {
@ -164,7 +181,41 @@ impl LiveNodeKind : cmp::Eq {
}
}
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &LiveNodeKind) -> bool {
match (*self) {
FreeVarNode(e0a) => {
match (*other) {
FreeVarNode(e0b) => e0a == e0b,
_ => false
}
}
ExprNode(e0a) => {
match (*other) {
ExprNode(e0b) => e0a == e0b,
_ => false
}
}
VarDefNode(e0a) => {
match (*other) {
VarDefNode(e0b) => e0a == e0b,
_ => false
}
}
ExitNode => {
match (*other) {
ExitNode => true,
_ => false
}
}
}
}
#[cfg(stage0)]
pure fn ne(other: &LiveNodeKind) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &LiveNodeKind) -> bool { !(*self).eq(other) }
}
fn live_node_kind_to_str(lnk: LiveNodeKind, cx: ty::ctxt) -> ~str {

View File

@ -56,6 +56,7 @@ enum categorization {
}
impl categorization : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &categorization) -> bool {
match self {
cat_rvalue => {
@ -115,7 +116,72 @@ impl categorization : cmp::Eq {
}
}
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &categorization) -> bool {
match (*self) {
cat_rvalue => {
match (*other) {
cat_rvalue => true,
_ => false
}
}
cat_special(e0a) => {
match (*other) {
cat_special(e0b) => e0a == e0b,
_ => false
}
}
cat_local(e0a) => {
match (*other) {
cat_local(e0b) => e0a == e0b,
_ => false
}
}
cat_binding(e0a) => {
match (*other) {
cat_binding(e0b) => e0a == e0b,
_ => false
}
}
cat_arg(e0a) => {
match (*other) {
cat_arg(e0b) => e0a == e0b,
_ => false
}
}
cat_stack_upvar(e0a) => {
match (*other) {
cat_stack_upvar(e0b) => e0a == e0b,
_ => false
}
}
cat_deref(e0a, e1a, e2a) => {
match (*other) {
cat_deref(e0b, e1b, e2b) =>
e0a == e0b && e1a == e1b && e2a == e2b,
_ => false
}
}
cat_comp(e0a, e1a) => {
match (*other) {
cat_comp(e0b, e1b) => e0a == e0b && e1a == e1b,
_ => false
}
}
cat_discr(e0a, e1a) => {
match (*other) {
cat_discr(e0b, e1b) => e0a == e0b && e1a == e1b,
_ => false
}
}
}
}
#[cfg(stage0)]
pure fn ne(other: &categorization) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &categorization) -> bool { !(*self).eq(other) }
}
// different kinds of pointers:
@ -127,6 +193,7 @@ enum ptr_kind {
}
impl ptr_kind : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &ptr_kind) -> bool {
match self {
uniq_ptr => {
@ -155,7 +222,41 @@ impl ptr_kind : cmp::Eq {
}
}
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &ptr_kind) -> bool {
match (*self) {
uniq_ptr => {
match (*other) {
uniq_ptr => true,
_ => false
}
}
gc_ptr => {
match (*other) {
gc_ptr => true,
_ => false
}
}
region_ptr(e0a) => {
match (*other) {
region_ptr(e0b) => e0a == e0b,
_ => false
}
}
unsafe_ptr => {
match (*other) {
unsafe_ptr => true,
_ => false
}
}
}
}
#[cfg(stage0)]
pure fn ne(other: &ptr_kind) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &ptr_kind) -> bool { !(*self).eq(other) }
}
// I am coining the term "components" to mean "pieces of a data
@ -172,6 +273,7 @@ enum comp_kind {
}
impl comp_kind : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &comp_kind) -> bool {
match self {
comp_tuple => {
@ -206,7 +308,47 @@ impl comp_kind : cmp::Eq {
}
}
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &comp_kind) -> bool {
match (*self) {
comp_tuple => {
match (*other) {
comp_tuple => true,
_ => false
}
}
comp_anon_field => {
match (*other) {
comp_anon_field => true,
_ => false
}
}
comp_variant(e0a) => {
match (*other) {
comp_variant(e0b) => e0a == e0b,
_ => false
}
}
comp_field(e0a, e1a) => {
match (*other) {
comp_field(e0b, e1b) => e0a == e0b && e1a == e1b,
_ => false
}
}
comp_index(e0a, e1a) => {
match (*other) {
comp_index(e0b, e1b) => e0a == e0b && e1a == e1b,
_ => false
}
}
}
}
#[cfg(stage0)]
pure fn ne(other: &comp_kind) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &comp_kind) -> bool { !(*self).eq(other) }
}
// different kinds of expressions we might evaluate
@ -218,10 +360,20 @@ enum special_kind {
}
impl special_kind : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &special_kind) -> bool {
(self as uint) == ((*other) as uint)
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &special_kind) -> bool {
((*self) as uint) == ((*other) as uint)
}
#[cfg(stage0)]
pure fn ne(other: &special_kind) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &special_kind) -> bool { !(*self).eq(other) }
}
// a complete categorization of a value indicating where it originated
@ -237,6 +389,7 @@ type cmt_ = {id: ast::node_id, // id of expr/pat producing this value
type cmt = @cmt_;
impl cmt_ : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &cmt_) -> bool {
self.id == (*other).id &&
self.span == (*other).span &&
@ -245,7 +398,21 @@ impl cmt_ : cmp::Eq {
self.mutbl == (*other).mutbl &&
self.ty == (*other).ty
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &cmt_) -> bool {
(*self).id == (*other).id &&
(*self).span == (*other).span &&
(*self).cat == (*other).cat &&
(*self).lp == (*other).lp &&
(*self).mutbl == (*other).mutbl &&
(*self).ty == (*other).ty
}
#[cfg(stage0)]
pure fn ne(other: &cmt_) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &cmt_) -> bool { !(*self).eq(other) }
}
// a loan path is like a category, but it exists only when the data is
@ -259,6 +426,7 @@ enum loan_path {
}
impl loan_path : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &loan_path) -> bool {
match self {
lp_local(e0a) => {
@ -287,7 +455,41 @@ impl loan_path : cmp::Eq {
}
}
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &loan_path) -> bool {
match (*self) {
lp_local(e0a) => {
match (*other) {
lp_local(e0b) => e0a == e0b,
_ => false
}
}
lp_arg(e0a) => {
match (*other) {
lp_arg(e0b) => e0a == e0b,
_ => false
}
}
lp_deref(e0a, e1a) => {
match (*other) {
lp_deref(e0b, e1b) => e0a == e0b && e1a == e1b,
_ => false
}
}
lp_comp(e0a, e1a) => {
match (*other) {
lp_comp(e0b, e1b) => e0a == e0b && e1a == e1b,
_ => false
}
}
}
}
#[cfg(stage0)]
pure fn ne(other: &loan_path) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &loan_path) -> bool { !(*self).eq(other) }
}
// We pun on *T to mean both actual deref of a ptr as well

View File

@ -374,11 +374,22 @@ type region_dep = {ambient_variance: region_variance, id: ast::node_id};
type dep_map = HashMap<ast::node_id, @DVec<region_dep>>;
impl region_dep : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &region_dep) -> bool {
self.ambient_variance == (*other).ambient_variance &&
self.id == (*other).id
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &region_dep) -> bool {
(*self).ambient_variance == (*other).ambient_variance &&
(*self).id == (*other).id
}
#[cfg(stage0)]
pure fn ne(other: &region_dep) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &region_dep) -> bool { !(*self).eq(other) }
}
type determine_rp_ctxt_ = {

View File

@ -108,6 +108,7 @@ enum PatternBindingMode {
}
impl PatternBindingMode : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &PatternBindingMode) -> bool {
match self {
RefutableMode => {
@ -130,7 +131,37 @@ impl PatternBindingMode : cmp::Eq {
}
}
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &PatternBindingMode) -> bool {
match (*self) {
RefutableMode => {
match *other {
RefutableMode => true,
_ => false
}
}
LocalIrrefutableMode => {
match *other {
LocalIrrefutableMode => true,
_ => false
}
}
ArgumentIrrefutableMode(mode_a) => {
match *other {
ArgumentIrrefutableMode(mode_b) => mode_a == mode_b,
_ => false
}
}
}
}
#[cfg(stage0)]
pure fn ne(other: &PatternBindingMode) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &PatternBindingMode) -> bool {
!(*self).eq(other)
}
}
@ -167,10 +198,20 @@ enum Mutability {
}
impl Mutability : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &Mutability) -> bool {
(self as uint) == ((*other) as uint)
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &Mutability) -> bool {
((*self) as uint) == ((*other) as uint)
}
#[cfg(stage0)]
pure fn ne(other: &Mutability) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &Mutability) -> bool { !(*self).eq(other) }
}
enum SelfBinding {
@ -191,10 +232,22 @@ enum ImportDirectiveNS {
}
impl ImportDirectiveNS : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &ImportDirectiveNS) -> bool {
(self as uint) == ((*other) as uint)
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &ImportDirectiveNS) -> bool {
((*self) as uint) == ((*other) as uint)
}
#[cfg(stage0)]
pure fn ne(other: &ImportDirectiveNS) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &ImportDirectiveNS) -> bool {
!(*self).eq(other)
}
}
/// Contains data for specific types of import directives.
@ -290,10 +343,20 @@ enum XrayFlag {
}
impl XrayFlag : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &XrayFlag) -> bool {
(self as uint) == ((*other) as uint)
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &XrayFlag) -> bool {
((*self) as uint) == ((*other) as uint)
}
#[cfg(stage0)]
pure fn ne(other: &XrayFlag) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &XrayFlag) -> bool { !(*self).eq(other) }
}
enum AllowCapturingSelfFlag {
@ -302,10 +365,22 @@ enum AllowCapturingSelfFlag {
}
impl AllowCapturingSelfFlag : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &AllowCapturingSelfFlag) -> bool {
(self as uint) == ((*other) as uint)
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &AllowCapturingSelfFlag) -> bool {
((*self) as uint) == ((*other) as uint)
}
#[cfg(stage0)]
pure fn ne(other: &AllowCapturingSelfFlag) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &AllowCapturingSelfFlag) -> bool {
!(*self).eq(other)
}
}
enum BareIdentifierPatternResolution {
@ -325,10 +400,22 @@ enum DuplicateCheckingMode {
}
impl DuplicateCheckingMode : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &DuplicateCheckingMode) -> bool {
(self as uint) == (*other as uint)
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &DuplicateCheckingMode) -> bool {
((*self) as uint) == (*other as uint)
}
#[cfg(stage0)]
pure fn ne(other: &DuplicateCheckingMode) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &DuplicateCheckingMode) -> bool {
!(*self).eq(other)
}
}
// Returns the namespace associated with the given duplicate checking mode,
@ -532,10 +619,20 @@ enum Privacy {
}
impl Privacy : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &Privacy) -> bool {
(self as uint) == ((*other) as uint)
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &Privacy) -> bool {
((*self) as uint) == ((*other) as uint)
}
#[cfg(stage0)]
pure fn ne(other: &Privacy) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &Privacy) -> bool { !(*self).eq(other) }
}
// Records a possibly-private type definition.

View File

@ -907,10 +907,20 @@ fn pick_col(m: &[@Match]) -> uint {
enum branch_kind { no_branch, single, switch, compare, }
impl branch_kind : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &branch_kind) -> bool {
(self as uint) == ((*other) as uint)
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &branch_kind) -> bool {
((*self) as uint) == ((*other) as uint)
}
#[cfg(stage0)]
pure fn ne(other: &branch_kind) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &branch_kind) -> bool { !(*self).eq(other) }
}
// Compiles a comparison between two things.

View File

@ -296,6 +296,7 @@ enum cleanup {
}
impl cleantype : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &cleantype) -> bool {
match self {
normal_exit_only => {
@ -312,7 +313,29 @@ impl cleantype : cmp::Eq {
}
}
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &cleantype) -> bool {
match (*self) {
normal_exit_only => {
match (*other) {
normal_exit_only => true,
_ => false
}
}
normal_exit_and_unwind => {
match (*other) {
normal_exit_and_unwind => true,
_ => false
}
}
}
}
#[cfg(stage0)]
pure fn ne(other: &cleantype) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &cleantype) -> bool { !(*self).eq(other) }
}
// Used to remember and reuse existing cleanup paths
@ -1144,6 +1167,7 @@ type mono_id_ = {
type mono_id = @mono_id_;
impl mono_param_id : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &mono_param_id) -> bool {
match (self, (*other)) {
(mono_precise(ty_a, ids_a), mono_precise(ty_b, ids_b)) => {
@ -1160,14 +1184,46 @@ impl mono_param_id : cmp::Eq {
(mono_repr(*), _) => false
}
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &mono_param_id) -> bool {
match ((*self), (*other)) {
(mono_precise(ty_a, ids_a), mono_precise(ty_b, ids_b)) => {
ty_a == ty_b && ids_a == ids_b
}
(mono_any, mono_any) => true,
(mono_repr(size_a, align_a, is_float_a, mode_a),
mono_repr(size_b, align_b, is_float_b, mode_b)) => {
size_a == size_b && align_a == align_b &&
is_float_a == is_float_b && mode_a == mode_b
}
(mono_precise(*), _) => false,
(mono_any, _) => false,
(mono_repr(*), _) => false
}
}
#[cfg(stage0)]
pure fn ne(other: &mono_param_id) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &mono_param_id) -> bool { !(*self).eq(other) }
}
impl mono_id_ : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &mono_id_) -> bool {
return self.def == (*other).def && self.params == (*other).params;
self.def == (*other).def && self.params == (*other).params
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &mono_id_) -> bool {
(*self).def == (*other).def && (*self).params == (*other).params
}
#[cfg(stage0)]
pure fn ne(other: &mono_id_) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &mono_id_) -> bool { !(*self).eq(other) }
}
impl mono_param_id : to_bytes::IterBytes {

View File

@ -139,10 +139,20 @@ impl DatumMode {
}
impl DatumMode: cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &DatumMode) -> bool {
self as uint == (*other as uint)
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &DatumMode) -> bool {
(*self) as uint == (*other as uint)
}
#[cfg(stage0)]
pure fn ne(other: &DatumMode) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &DatumMode) -> bool { !(*self).eq(other) }
}
impl DatumMode: to_bytes::IterBytes {
@ -799,6 +809,7 @@ impl DatumBlock {
}
impl CopyAction : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &CopyAction) -> bool {
match (self, (*other)) {
(INIT, INIT) => true,
@ -807,5 +818,19 @@ impl CopyAction : cmp::Eq {
(DROP_EXISTING, _) => false,
}
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &CopyAction) -> bool {
match ((*self), (*other)) {
(INIT, INIT) => true,
(DROP_EXISTING, DROP_EXISTING) => true,
(INIT, _) => false,
(DROP_EXISTING, _) => false,
}
}
#[cfg(stage0)]
pure fn ne(other: &CopyAction) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &CopyAction) -> bool { !(*self).eq(other) }
}

View File

@ -148,6 +148,7 @@ impl Dest {
}
impl Dest : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &Dest) -> bool {
match (self, (*other)) {
(SaveIn(e0a), SaveIn(e0b)) => e0a == e0b,
@ -156,7 +157,21 @@ impl Dest : cmp::Eq {
(Ignore, _) => false,
}
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &Dest) -> bool {
match ((*self), (*other)) {
(SaveIn(e0a), SaveIn(e0b)) => e0a == e0b,
(Ignore, Ignore) => true,
(SaveIn(*), _) => false,
(Ignore, _) => false,
}
}
#[cfg(stage0)]
pure fn ne(other: &Dest) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &Dest) -> bool { !(*self).eq(other) }
}
fn drop_and_cancel_clean(bcx: block, dat: Datum) -> block {
@ -1429,6 +1444,7 @@ enum cast_kind {
}
impl cast_kind : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &cast_kind) -> bool {
match (self, (*other)) {
(cast_pointer, cast_pointer) => true,
@ -1443,7 +1459,27 @@ impl cast_kind : cmp::Eq {
(cast_other, _) => false,
}
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &cast_kind) -> bool {
match ((*self), (*other)) {
(cast_pointer, cast_pointer) => true,
(cast_integral, cast_integral) => true,
(cast_float, cast_float) => true,
(cast_enum, cast_enum) => true,
(cast_other, cast_other) => true,
(cast_pointer, _) => false,
(cast_integral, _) => false,
(cast_float, _) => false,
(cast_enum, _) => false,
(cast_other, _) => false,
}
}
#[cfg(stage0)]
pure fn ne(other: &cast_kind) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &cast_kind) -> bool { !(*self).eq(other) }
}
fn cast_type_kind(t: ty::t) -> cast_kind {

View File

@ -41,10 +41,20 @@ enum x86_64_reg_class {
}
impl x86_64_reg_class : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &x86_64_reg_class) -> bool {
(self as uint) == ((*other) as uint)
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &x86_64_reg_class) -> bool {
((*self) as uint) == ((*other) as uint)
}
#[cfg(stage0)]
pure fn ne(other: &x86_64_reg_class) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &x86_64_reg_class) -> bool { !(*self).eq(other) }
}
fn is_sse(++c: x86_64_reg_class) -> bool {

View File

@ -243,14 +243,28 @@ type creader_cache_key = {cnum: int, pos: uint, len: uint};
type creader_cache = HashMap<creader_cache_key, t>;
impl creader_cache_key : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &creader_cache_key) -> bool {
self.cnum == (*other).cnum &&
self.pos == (*other).pos &&
self.len == (*other).len
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &creader_cache_key) -> bool {
(*self).cnum == (*other).cnum &&
(*self).pos == (*other).pos &&
(*self).len == (*other).len
}
#[cfg(stage0)]
pure fn ne(other: &creader_cache_key) -> bool {
!(self == (*other))
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &creader_cache_key) -> bool {
!((*self) == (*other))
}
}
impl creader_cache_key : to_bytes::IterBytes {
@ -262,10 +276,20 @@ impl creader_cache_key : to_bytes::IterBytes {
type intern_key = {sty: sty, o_def_id: Option<ast::def_id>};
impl intern_key : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &intern_key) -> bool {
self.sty == (*other).sty && self.o_def_id == (*other).o_def_id
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &intern_key) -> bool {
(*self).sty == (*other).sty && (*self).o_def_id == (*other).o_def_id
}
#[cfg(stage0)]
pure fn ne(other: &intern_key) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &intern_key) -> bool { !(*self).eq(other) }
}
impl intern_key : to_bytes::IterBytes {
@ -286,6 +310,7 @@ type opt_region_variance = Option<region_variance>;
enum region_variance { rv_covariant, rv_invariant, rv_contravariant }
impl region_variance : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &region_variance) -> bool {
match (self, (*other)) {
(rv_covariant, rv_covariant) => true,
@ -296,7 +321,23 @@ impl region_variance : cmp::Eq {
(rv_contravariant, _) => false
}
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &region_variance) -> bool {
match ((*self), (*other)) {
(rv_covariant, rv_covariant) => true,
(rv_invariant, rv_invariant) => true,
(rv_contravariant, rv_contravariant) => true,
(rv_covariant, _) => false,
(rv_invariant, _) => false,
(rv_contravariant, _) => false
}
}
#[cfg(stage0)]
pure fn ne(other: &region_variance) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &region_variance) -> bool { !(*self).eq(other) }
}
#[auto_serialize]
@ -504,10 +545,20 @@ type FnTy = FnTyBase<FnMeta>;
type param_ty = {idx: uint, def_id: def_id};
impl param_ty : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &param_ty) -> bool {
self.idx == (*other).idx && self.def_id == (*other).def_id
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &param_ty) -> bool {
(*self).idx == (*other).idx && (*self).def_id == (*other).def_id
}
#[cfg(stage0)]
pure fn ne(other: &param_ty) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &param_ty) -> bool { !(*self).eq(other) }
}
impl param_ty : to_bytes::IterBytes {
@ -720,6 +771,7 @@ impl InferRegion : to_bytes::IterBytes {
}
impl InferRegion : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &InferRegion) -> bool {
match (self, *other) {
(ReVar(rva), ReVar(rvb)) => {
@ -731,9 +783,28 @@ impl InferRegion : cmp::Eq {
_ => false
}
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &InferRegion) -> bool {
match ((*self), *other) {
(ReVar(rva), ReVar(rvb)) => {
rva == rvb
}
(ReSkolemized(rva, _), ReSkolemized(rvb, _)) => {
rva == rvb
}
_ => false
}
}
#[cfg(stage0)]
pure fn ne(other: &InferRegion) -> bool {
!(self == (*other))
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &InferRegion) -> bool {
!((*self) == (*other))
}
}
impl param_bound : to_bytes::IterBytes {
@ -4172,27 +4243,58 @@ pure fn determine_inherited_purity(parent_purity: ast::purity,
}
impl mt : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &mt) -> bool {
self.ty == (*other).ty && self.mutbl == (*other).mutbl
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &mt) -> bool {
(*self).ty == (*other).ty && (*self).mutbl == (*other).mutbl
}
#[cfg(stage0)]
pure fn ne(other: &mt) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &mt) -> bool { !(*self).eq(other) }
}
impl arg : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &arg) -> bool {
self.mode == (*other).mode && self.ty == (*other).ty
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &arg) -> bool {
(*self).mode == (*other).mode && (*self).ty == (*other).ty
}
#[cfg(stage0)]
pure fn ne(other: &arg) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &arg) -> bool { !(*self).eq(other) }
}
impl field : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &field) -> bool {
self.ident == (*other).ident && self.mt == (*other).mt
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &field) -> bool {
(*self).ident == (*other).ident && (*self).mt == (*other).mt
}
#[cfg(stage0)]
pure fn ne(other: &field) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &field) -> bool { !(*self).eq(other) }
}
impl vstore : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &vstore) -> bool {
match self {
vstore_fixed(e0a) => {
@ -4221,60 +4323,169 @@ impl vstore : cmp::Eq {
}
}
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &vstore) -> bool {
match (*self) {
vstore_fixed(e0a) => {
match (*other) {
vstore_fixed(e0b) => e0a == e0b,
_ => false
}
}
vstore_uniq => {
match (*other) {
vstore_uniq => true,
_ => false
}
}
vstore_box => {
match (*other) {
vstore_box => true,
_ => false
}
}
vstore_slice(e0a) => {
match (*other) {
vstore_slice(e0b) => e0a == e0b,
_ => false
}
}
}
}
#[cfg(stage0)]
pure fn ne(other: &vstore) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &vstore) -> bool { !(*self).eq(other) }
}
impl FnMeta : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &FnMeta) -> bool {
self.purity == (*other).purity &&
self.proto == (*other).proto &&
self.bounds == (*other).bounds &&
self.ret_style == (*other).ret_style
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &FnMeta) -> bool {
(*self).purity == (*other).purity &&
(*self).proto == (*other).proto &&
(*self).bounds == (*other).bounds &&
(*self).ret_style == (*other).ret_style
}
#[cfg(stage0)]
pure fn ne(other: &FnMeta) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &FnMeta) -> bool { !(*self).eq(other) }
}
impl FnSig : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &FnSig) -> bool {
self.inputs == (*other).inputs &&
self.output == (*other).output
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &FnSig) -> bool {
(*self).inputs == (*other).inputs &&
(*self).output == (*other).output
}
#[cfg(stage0)]
pure fn ne(other: &FnSig) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &FnSig) -> bool { !(*self).eq(other) }
}
impl<M: cmp::Eq> FnTyBase<M> : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &FnTyBase<M>) -> bool {
self.meta == (*other).meta && self.sig == (*other).sig
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &FnTyBase<M>) -> bool {
(*self).meta == (*other).meta && (*self).sig == (*other).sig
}
#[cfg(stage0)]
pure fn ne(other: &FnTyBase<M>) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &FnTyBase<M>) -> bool { !(*self).eq(other) }
}
impl TyVid : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &TyVid) -> bool { *self == *(*other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &TyVid) -> bool { *(*self) == *(*other) }
#[cfg(stage0)]
pure fn ne(other: &TyVid) -> bool { *self != *(*other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &TyVid) -> bool { *(*self) != *(*other) }
}
impl IntVid : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &IntVid) -> bool { *self == *(*other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &IntVid) -> bool { *(*self) == *(*other) }
#[cfg(stage0)]
pure fn ne(other: &IntVid) -> bool { *self != *(*other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &IntVid) -> bool { *(*self) != *(*other) }
}
impl FloatVid : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &FloatVid) -> bool { *self == *(*other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &FloatVid) -> bool { *(*self) == *(*other) }
#[cfg(stage0)]
pure fn ne(other: &FloatVid) -> bool { *self != *(*other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &FloatVid) -> bool { *(*self) != *(*other) }
}
impl FnVid : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &FnVid) -> bool { *self == *(*other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &FnVid) -> bool { *(*self) == *(*other) }
#[cfg(stage0)]
pure fn ne(other: &FnVid) -> bool { *self != *(*other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &FnVid) -> bool { *(*self) != *(*other) }
}
impl RegionVid : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &RegionVid) -> bool { *self == *(*other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &RegionVid) -> bool { *(*self) == *(*other) }
#[cfg(stage0)]
pure fn ne(other: &RegionVid) -> bool { *self != *(*other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &RegionVid) -> bool { *(*self) != *(*other) }
}
impl Region : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &Region) -> bool {
match self {
re_bound(e0a) => {
@ -4309,10 +4520,51 @@ impl Region : cmp::Eq {
}
}
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &Region) -> bool {
match (*self) {
re_bound(e0a) => {
match (*other) {
re_bound(e0b) => e0a == e0b,
_ => false
}
}
re_free(e0a, e1a) => {
match (*other) {
re_free(e0b, e1b) => e0a == e0b && e1a == e1b,
_ => false
}
}
re_scope(e0a) => {
match (*other) {
re_scope(e0b) => e0a == e0b,
_ => false
}
}
re_static => {
match (*other) {
re_static => true,
_ => false
}
}
re_infer(e0a) => {
match (*other) {
re_infer(e0b) => e0a == e0b,
_ => false
}
}
}
}
#[cfg(stage0)]
pure fn ne(other: &Region) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &Region) -> bool { !(*self).eq(other) }
}
impl bound_region : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &bound_region) -> bool {
match self {
br_self => {
@ -4341,26 +4593,83 @@ impl bound_region : cmp::Eq {
}
}
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &bound_region) -> bool {
match (*self) {
br_self => {
match (*other) {
br_self => true,
_ => false
}
}
br_anon(e0a) => {
match (*other) {
br_anon(e0b) => e0a == e0b,
_ => false
}
}
br_named(e0a) => {
match (*other) {
br_named(e0b) => e0a == e0b,
_ => false
}
}
br_cap_avoid(e0a, e1a) => {
match (*other) {
br_cap_avoid(e0b, e1b) => e0a == e0b && e1a == e1b,
_ => false
}
}
}
}
#[cfg(stage0)]
pure fn ne(other: &bound_region) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &bound_region) -> bool { !(*self).eq(other) }
}
impl substs : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &substs) -> bool {
self.self_r == (*other).self_r &&
self.self_ty == (*other).self_ty &&
self.tps == (*other).tps
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &substs) -> bool {
(*self).self_r == (*other).self_r &&
(*self).self_ty == (*other).self_ty &&
(*self).tps == (*other).tps
}
#[cfg(stage0)]
pure fn ne(other: &substs) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &substs) -> bool { !(*self).eq(other) }
}
impl InferTy : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &InferTy) -> bool {
self.to_hash() == (*other).to_hash()
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &InferTy) -> bool {
(*self).to_hash() == (*other).to_hash()
}
#[cfg(stage0)]
pure fn ne(other: &InferTy) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &InferTy) -> bool { !(*self).eq(other) }
}
impl sty : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &sty) -> bool {
match self {
ty_nil => {
@ -4516,10 +4825,172 @@ impl sty : cmp::Eq {
}
}
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &sty) -> bool {
match (*self) {
ty_nil => {
match (*other) {
ty_nil => true,
_ => false
}
}
ty_bot => {
match (*other) {
ty_bot => true,
_ => false
}
}
ty_bool => {
match (*other) {
ty_bool => true,
_ => false
}
}
ty_int(e0a) => {
match (*other) {
ty_int(e0b) => e0a == e0b,
_ => false
}
}
ty_uint(e0a) => {
match (*other) {
ty_uint(e0b) => e0a == e0b,
_ => false
}
}
ty_float(e0a) => {
match (*other) {
ty_float(e0b) => e0a == e0b,
_ => false
}
}
ty_estr(e0a) => {
match (*other) {
ty_estr(e0b) => e0a == e0b,
_ => false
}
}
ty_enum(e0a, e1a) => {
match (*other) {
ty_enum(e0b, e1b) => e0a == e0b && e1a == e1b,
_ => false
}
}
ty_box(e0a) => {
match (*other) {
ty_box(e0b) => e0a == e0b,
_ => false
}
}
ty_uniq(e0a) => {
match (*other) {
ty_uniq(e0b) => e0a == e0b,
_ => false
}
}
ty_evec(e0a, e1a) => {
match (*other) {
ty_evec(e0b, e1b) => e0a == e0b && e1a == e1b,
_ => false
}
}
ty_ptr(e0a) => {
match (*other) {
ty_ptr(e0b) => e0a == e0b,
_ => false
}
}
ty_rptr(e0a, e1a) => {
match (*other) {
ty_rptr(e0b, e1b) => e0a == e0b && e1a == e1b,
_ => false
}
}
ty_rec(e0a) => {
match (*other) {
ty_rec(e0b) => e0a == e0b,
_ => false
}
}
ty_fn(e0a) => {
match (*other) {
ty_fn(e0b) => e0a == e0b,
_ => false
}
}
ty_trait(e0a, e1a, e2a) => {
match (*other) {
ty_trait(e0b, e1b, e2b) =>
e0a == e0b && e1a == e1b && e2a == e2b,
_ => false
}
}
ty_class(e0a, e1a) => {
match (*other) {
ty_class(e0b, e1b) => e0a == e0b && e1a == e1b,
_ => false
}
}
ty_tup(e0a) => {
match (*other) {
ty_tup(e0b) => e0a == e0b,
_ => false
}
}
ty_infer(e0a) => {
match (*other) {
ty_infer(e0b) => e0a == e0b,
_ => false
}
}
ty_param(e0a) => {
match (*other) {
ty_param(e0b) => e0a == e0b,
_ => false
}
}
ty_self => {
match (*other) {
ty_self => true,
_ => false
}
}
ty_type => {
match (*other) {
ty_type => true,
_ => false
}
}
ty_opaque_box => {
match (*other) {
ty_opaque_box => true,
_ => false
}
}
ty_opaque_closure_ptr(e0a) => {
match (*other) {
ty_opaque_closure_ptr(e0b) => e0a == e0b,
_ => false
}
}
ty_unboxed_vec(e0a) => {
match (*other) {
ty_unboxed_vec(e0b) => e0a == e0b,
_ => false
}
}
}
}
#[cfg(stage0)]
pure fn ne(other: &sty) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &sty) -> bool { !(*self).eq(other) }
}
impl param_bound : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &param_bound) -> bool {
match self {
bound_copy => {
@ -4554,12 +5025,60 @@ impl param_bound : cmp::Eq {
}
}
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &param_bound) -> bool {
match (*self) {
bound_copy => {
match (*other) {
bound_copy => true,
_ => false
}
}
bound_owned => {
match (*other) {
bound_owned => true,
_ => false
}
}
bound_send => {
match (*other) {
bound_send => true,
_ => false
}
}
bound_const => {
match (*other) {
bound_const => true,
_ => false
}
}
bound_trait(e0a) => {
match (*other) {
bound_trait(e0b) => e0a == e0b,
_ => false
}
}
}
}
#[cfg(stage0)]
pure fn ne(other: &param_bound) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &param_bound) -> bool { !(*self).eq(other) }
}
impl Kind : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &Kind) -> bool { *self == *(*other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &Kind) -> bool { *(*self) == *(*other) }
#[cfg(stage0)]
pure fn ne(other: &Kind) -> bool { *self != *(*other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &Kind) -> bool { *(*self) != *(*other) }
}

View File

@ -956,7 +956,7 @@ fn lookup_field_ty(tcx: ty::ctxt,
// Controls whether the arguments are automatically referenced. This is useful
// for overloaded binary and unary operators.
enum DerefArgs {
pub enum DerefArgs {
DontDerefArgs,
DoDerefArgs
}
@ -1182,7 +1182,8 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
-> Option<(ty::t, bool)>
{
match method::lookup(fcx, op_ex, self_ex,
op_ex.callee_id, opname, self_t, ~[]) {
op_ex.callee_id, opname, self_t, ~[],
deref_args) {
Some(origin) => {
let {fty: method_ty, bot: bot} = {
let method_ty = fcx.node_ty(op_ex.callee_id);
@ -1439,7 +1440,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
let tps = vec::map(tys, |ty| fcx.to_ty(*ty));
match method::lookup(fcx, expr, base, expr.id,
field, expr_t, tps) {
field, expr_t, tps, DontDerefArgs) {
Some(entry) => {
fcx.ccx.method_map.insert(expr.id, entry);

View File

@ -89,7 +89,8 @@ fn lookup(
callee_id: node_id, // Where to store the type of `a.b`
m_name: ast::ident, // The ident `b`.
self_ty: ty::t, // The type of `a`.
supplied_tps: &[ty::t]) // The list of types X, Y, ... .
supplied_tps: &[ty::t], // The list of types X, Y, ... .
deref_args: check::DerefArgs) // Whether we autopointer first.
-> Option<method_map_entry>
{
let lcx = LookupContext {
@ -101,7 +102,8 @@ fn lookup(
supplied_tps: supplied_tps,
impl_dups: HashMap(),
inherent_candidates: DVec(),
extension_candidates: DVec()
extension_candidates: DVec(),
deref_args: deref_args,
};
let mme = lcx.do_lookup(self_ty);
debug!("method lookup for %s yielded %?",
@ -118,7 +120,8 @@ struct LookupContext {
supplied_tps: &[ty::t],
impl_dups: HashMap<def_id, ()>,
inherent_candidates: DVec<Candidate>,
extension_candidates: DVec<Candidate>
extension_candidates: DVec<Candidate>,
deref_args: check::DerefArgs,
}
/**
@ -155,14 +158,33 @@ impl LookupContext {
debug!("loop: self_ty=%s autoderefs=%u",
self.ty_to_str(self_ty), autoderefs);
match self.search_for_autoderefd_method(self_ty, autoderefs) {
Some(move mme) => { return Some(mme); }
None => {}
}
match self.deref_args {
check::DontDerefArgs => {
match self.search_for_autoderefd_method(self_ty,
autoderefs) {
Some(move mme) => { return Some(mme); }
None => {}
}
match self.search_for_autoptrd_method(self_ty, autoderefs) {
Some(move mme) => { return Some(move mme); }
None => {}
match self.search_for_autoptrd_method(self_ty,
autoderefs) {
Some(move mme) => { return Some(move mme); }
None => {}
}
}
check::DoDerefArgs => {
match self.search_for_autoptrd_method(self_ty,
autoderefs) {
Some(move mme) => { return Some(move mme); }
None => {}
}
match self.search_for_autoderefd_method(self_ty,
autoderefs) {
Some(move mme) => { return Some(mme); }
None => {}
}
}
}
match self.deref(self_ty, &enum_dids) {

View File

@ -351,6 +351,7 @@ enum Constraint {
}
impl Constraint : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &Constraint) -> bool {
match (self, (*other)) {
(ConstrainVarSubVar(v0a, v1a), ConstrainVarSubVar(v0b, v1b)) => {
@ -367,7 +368,29 @@ impl Constraint : cmp::Eq {
(ConstrainVarSubReg(*), _) => false
}
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &Constraint) -> bool {
match ((*self), (*other)) {
(ConstrainVarSubVar(v0a, v1a), ConstrainVarSubVar(v0b, v1b)) => {
v0a == v0b && v1a == v1b
}
(ConstrainRegSubVar(ra, va), ConstrainRegSubVar(rb, vb)) => {
ra == rb && va == vb
}
(ConstrainVarSubReg(va, ra), ConstrainVarSubReg(vb, rb)) => {
va == vb && ra == rb
}
(ConstrainVarSubVar(*), _) => false,
(ConstrainRegSubVar(*), _) => false,
(ConstrainVarSubReg(*), _) => false
}
}
#[cfg(stage0)]
pure fn ne(other: &Constraint) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &Constraint) -> bool { !(*self).eq(other) }
}
impl Constraint : to_bytes::IterBytes {
@ -391,10 +414,20 @@ struct TwoRegions {
}
impl TwoRegions : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &TwoRegions) -> bool {
self.a == (*other).a && self.b == (*other).b
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &TwoRegions) -> bool {
(*self).a == (*other).a && (*self).b == (*other).b
}
#[cfg(stage0)]
pure fn ne(other: &TwoRegions) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &TwoRegions) -> bool { !(*self).eq(other) }
}
impl TwoRegions : to_bytes::IterBytes {
@ -891,19 +924,39 @@ priv impl RegionVarBindings {
enum Direction { Incoming = 0, Outgoing = 1 }
impl Direction : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &Direction) -> bool {
(self as uint) == ((*other) as uint)
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &Direction) -> bool {
((*self) as uint) == ((*other) as uint)
}
#[cfg(stage0)]
pure fn ne(other: &Direction) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &Direction) -> bool { !(*self).eq(other) }
}
enum Classification { Expanding, Contracting }
impl Classification : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &Classification) -> bool {
(self as uint) == ((*other) as uint)
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &Classification) -> bool {
((*self) as uint) == ((*other) as uint)
}
#[cfg(stage0)]
pure fn ne(other: &Classification) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &Classification) -> bool { !(*self).eq(other) }
}
enum GraphNodeValue { NoValue, Value(Region), ErrorValue }

View File

@ -167,10 +167,20 @@ enum monitor_msg {
}
impl monitor_msg : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &monitor_msg) -> bool {
(self as uint) == ((*other) as uint)
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &monitor_msg) -> bool {
((*self) as uint) == ((*other) as uint)
}
#[cfg(stage0)]
pure fn ne(other: &monitor_msg) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &monitor_msg) -> bool { !(*self).eq(other) }
}
/*

View File

@ -19,10 +19,20 @@ enum OutputFormat {
}
impl OutputFormat : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &OutputFormat) -> bool {
(self as uint) == ((*other) as uint)
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &OutputFormat) -> bool {
((*self) as uint) == ((*other) as uint)
}
#[cfg(stage0)]
pure fn ne(other: &OutputFormat) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &OutputFormat) -> bool { !(*self).eq(other) }
}
/// How to organize the output
@ -34,10 +44,20 @@ enum OutputStyle {
}
impl OutputStyle : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &OutputStyle) -> bool {
(self as uint) == ((*other) as uint)
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &OutputStyle) -> bool {
((*self) as uint) == ((*other) as uint)
}
#[cfg(stage0)]
pure fn ne(other: &OutputStyle) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &OutputStyle) -> bool { !(*self).eq(other) }
}
/// The configuration for a rustdoc session

View File

@ -7,10 +7,20 @@ type Doc_ = {
};
impl Doc_ : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &Doc_) -> bool {
self.pages == (*other).pages
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &Doc_) -> bool {
(*self).pages == (*other).pages
}
#[cfg(stage0)]
pure fn ne(other: &Doc_) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &Doc_) -> bool { !(*self).eq(other) }
}
enum Doc {
@ -18,8 +28,16 @@ enum Doc {
}
impl Doc : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &Doc) -> bool { *self == *(*other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &Doc) -> bool { *(*self) == *(*other) }
#[cfg(stage0)]
pure fn ne(other: &Doc) -> bool { *self != *(*other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &Doc) -> bool { *(*self) != *(*other) }
}
enum Page {
@ -28,6 +46,7 @@ enum Page {
}
impl Page : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &Page) -> bool {
match self {
CratePage(e0a) => {
@ -44,7 +63,29 @@ impl Page : cmp::Eq {
}
}
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &Page) -> bool {
match (*self) {
CratePage(e0a) => {
match (*other) {
CratePage(e0b) => e0a == e0b,
_ => false
}
}
ItemPage(e0a) => {
match (*other) {
ItemPage(e0b) => e0a == e0b,
_ => false
}
}
}
}
#[cfg(stage0)]
pure fn ne(other: &Page) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &Page) -> bool { !(*self).eq(other) }
}
enum Implementation {
@ -53,10 +94,20 @@ enum Implementation {
}
impl Implementation : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &Implementation) -> bool {
(self as uint) == ((*other) as uint)
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &Implementation) -> bool {
((*self) as uint) == ((*other) as uint)
}
#[cfg(stage0)]
pure fn ne(other: &Implementation) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &Implementation) -> bool { !(*self).eq(other) }
}
@ -70,10 +121,20 @@ type Section = {
};
impl Section : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &Section) -> bool {
self.header == (*other).header && self.body == (*other).body
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &Section) -> bool {
(*self).header == (*other).header && (*self).body == (*other).body
}
#[cfg(stage0)]
pure fn ne(other: &Section) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &Section) -> bool { !(*self).eq(other) }
}
// FIXME (#2596): We currently give topmod the name of the crate. There
@ -84,10 +145,20 @@ type CrateDoc = {
};
impl CrateDoc : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &CrateDoc) -> bool {
self.topmod == (*other).topmod
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &CrateDoc) -> bool {
(*self).topmod == (*other).topmod
}
#[cfg(stage0)]
pure fn ne(other: &CrateDoc) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &CrateDoc) -> bool { !(*self).eq(other) }
}
enum ItemTag {
@ -103,6 +174,7 @@ enum ItemTag {
}
impl ItemTag : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &ItemTag) -> bool {
match self {
ModTag(e0a) => {
@ -161,7 +233,71 @@ impl ItemTag : cmp::Eq {
}
}
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &ItemTag) -> bool {
match (*self) {
ModTag(e0a) => {
match (*other) {
ModTag(e0b) => e0a == e0b,
_ => false
}
}
NmodTag(e0a) => {
match (*other) {
NmodTag(e0b) => e0a == e0b,
_ => false
}
}
ConstTag(e0a) => {
match (*other) {
ConstTag(e0b) => e0a == e0b,
_ => false
}
}
FnTag(e0a) => {
match (*other) {
FnTag(e0b) => e0a == e0b,
_ => false
}
}
EnumTag(e0a) => {
match (*other) {
EnumTag(e0b) => e0a == e0b,
_ => false
}
}
TraitTag(e0a) => {
match (*other) {
TraitTag(e0b) => e0a == e0b,
_ => false
}
}
ImplTag(e0a) => {
match (*other) {
ImplTag(e0b) => e0a == e0b,
_ => false
}
}
TyTag(e0a) => {
match (*other) {
TyTag(e0b) => e0a == e0b,
_ => false
}
}
StructTag(e0a) => {
match (*other) {
StructTag(e0b) => e0a == e0b,
_ => false
}
}
}
}
#[cfg(stage0)]
pure fn ne(other: &ItemTag) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &ItemTag) -> bool { !(*self).eq(other) }
}
type ItemDoc = {
@ -176,6 +312,7 @@ type ItemDoc = {
};
impl ItemDoc : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &ItemDoc) -> bool {
self.id == (*other).id &&
self.name == (*other).name &&
@ -185,7 +322,22 @@ impl ItemDoc : cmp::Eq {
self.sections == (*other).sections &&
self.reexport == (*other).reexport
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &ItemDoc) -> bool {
(*self).id == (*other).id &&
(*self).name == (*other).name &&
(*self).path == (*other).path &&
(*self).brief == (*other).brief &&
(*self).desc == (*other).desc &&
(*self).sections == (*other).sections &&
(*self).reexport == (*other).reexport
}
#[cfg(stage0)]
pure fn ne(other: &ItemDoc) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &ItemDoc) -> bool { !(*self).eq(other) }
}
type SimpleItemDoc = {
@ -194,10 +346,20 @@ type SimpleItemDoc = {
};
impl SimpleItemDoc : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &SimpleItemDoc) -> bool {
self.item == (*other).item && self.sig == (*other).sig
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &SimpleItemDoc) -> bool {
(*self).item == (*other).item && (*self).sig == (*other).sig
}
#[cfg(stage0)]
pure fn ne(other: &SimpleItemDoc) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &SimpleItemDoc) -> bool { !(*self).eq(other) }
}
type ModDoc_ = {
@ -207,12 +369,24 @@ type ModDoc_ = {
};
impl ModDoc_ : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &ModDoc_) -> bool {
self.item == (*other).item &&
self.items == (*other).items &&
self.index == (*other).index
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &ModDoc_) -> bool {
(*self).item == (*other).item &&
(*self).items == (*other).items &&
(*self).index == (*other).index
}
#[cfg(stage0)]
pure fn ne(other: &ModDoc_) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &ModDoc_) -> bool { !(*self).eq(other) }
}
enum ModDoc {
@ -220,8 +394,16 @@ enum ModDoc {
}
impl ModDoc : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &ModDoc) -> bool { *self == *(*other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &ModDoc) -> bool { *(*self) == *(*other) }
#[cfg(stage0)]
pure fn ne(other: &ModDoc) -> bool { *self != *(*other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &ModDoc) -> bool { *(*self) != *(*other) }
}
type NmodDoc = {
@ -231,12 +413,24 @@ type NmodDoc = {
};
impl NmodDoc : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &NmodDoc) -> bool {
self.item == (*other).item &&
self.fns == (*other).fns &&
self.index == (*other).index
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &NmodDoc) -> bool {
(*self).item == (*other).item &&
(*self).fns == (*other).fns &&
(*self).index == (*other).index
}
#[cfg(stage0)]
pure fn ne(other: &NmodDoc) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &NmodDoc) -> bool { !(*self).eq(other) }
}
type ConstDoc = SimpleItemDoc;
@ -249,10 +443,20 @@ type EnumDoc = {
};
impl EnumDoc : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &EnumDoc) -> bool {
self.item == (*other).item && self.variants == (*other).variants
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &EnumDoc) -> bool {
(*self).item == (*other).item && (*self).variants == (*other).variants
}
#[cfg(stage0)]
pure fn ne(other: &EnumDoc) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &EnumDoc) -> bool { !(*self).eq(other) }
}
type VariantDoc = {
@ -262,12 +466,24 @@ type VariantDoc = {
};
impl VariantDoc : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &VariantDoc) -> bool {
self.name == (*other).name &&
self.desc == (*other).desc &&
self.sig == (*other).sig
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &VariantDoc) -> bool {
(*self).name == (*other).name &&
(*self).desc == (*other).desc &&
(*self).sig == (*other).sig
}
#[cfg(stage0)]
pure fn ne(other: &VariantDoc) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &VariantDoc) -> bool { !(*self).eq(other) }
}
type TraitDoc = {
@ -276,10 +492,20 @@ type TraitDoc = {
};
impl TraitDoc : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &TraitDoc) -> bool {
self.item == (*other).item && self.methods == (*other).methods
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &TraitDoc) -> bool {
(*self).item == (*other).item && (*self).methods == (*other).methods
}
#[cfg(stage0)]
pure fn ne(other: &TraitDoc) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &TraitDoc) -> bool { !(*self).eq(other) }
}
type MethodDoc = {
@ -292,6 +518,7 @@ type MethodDoc = {
};
impl MethodDoc : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &MethodDoc) -> bool {
self.name == (*other).name &&
self.brief == (*other).brief &&
@ -300,7 +527,21 @@ impl MethodDoc : cmp::Eq {
self.sig == (*other).sig &&
self.implementation == (*other).implementation
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &MethodDoc) -> bool {
(*self).name == (*other).name &&
(*self).brief == (*other).brief &&
(*self).desc == (*other).desc &&
(*self).sections == (*other).sections &&
(*self).sig == (*other).sig &&
(*self).implementation == (*other).implementation
}
#[cfg(stage0)]
pure fn ne(other: &MethodDoc) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &MethodDoc) -> bool { !(*self).eq(other) }
}
type ImplDoc = {
@ -311,13 +552,26 @@ type ImplDoc = {
};
impl ImplDoc : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &ImplDoc) -> bool {
self.item == (*other).item &&
self.trait_types == (*other).trait_types &&
self.self_ty == (*other).self_ty &&
self.methods == (*other).methods
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &ImplDoc) -> bool {
(*self).item == (*other).item &&
(*self).trait_types == (*other).trait_types &&
(*self).self_ty == (*other).self_ty &&
(*self).methods == (*other).methods
}
#[cfg(stage0)]
pure fn ne(other: &ImplDoc) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &ImplDoc) -> bool { !(*self).eq(other) }
}
type TyDoc = SimpleItemDoc;
@ -329,12 +583,24 @@ type StructDoc = {
};
impl StructDoc : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &StructDoc) -> bool {
return self.item == other.item
&& self.fields == other.fields
&& self.sig == other.sig;
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &StructDoc) -> bool {
return (*self).item == other.item
&& (*self).fields == other.fields
&& (*self).sig == other.sig;
}
#[cfg(stage0)]
pure fn ne(other: &StructDoc) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &StructDoc) -> bool { !(*self).eq(other) }
}
type Index = {
@ -342,10 +608,20 @@ type Index = {
};
impl Index : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &Index) -> bool {
self.entries == (*other).entries
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &Index) -> bool {
(*self).entries == (*other).entries
}
#[cfg(stage0)]
pure fn ne(other: &Index) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &Index) -> bool { !(*self).eq(other) }
}
/**
@ -366,13 +642,26 @@ type IndexEntry = {
};
impl IndexEntry : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &IndexEntry) -> bool {
self.kind == (*other).kind &&
self.name == (*other).name &&
self.brief == (*other).brief &&
self.link == (*other).link
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &IndexEntry) -> bool {
(*self).kind == (*other).kind &&
(*self).name == (*other).name &&
(*self).brief == (*other).brief &&
(*self).link == (*other).link
}
#[cfg(stage0)]
pure fn ne(other: &IndexEntry) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &IndexEntry) -> bool { !(*self).eq(other) }
}
impl Doc {

View File

@ -239,6 +239,7 @@ mod tests {
type RecCy = {x: int, y: int, t: Taggy};
impl Taggy : Eq {
#[cfg(stage0)]
pure fn eq(other: &Taggy) -> bool {
match self {
One(a1) => match (*other) {
@ -255,11 +256,34 @@ mod tests {
}
}
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &Taggy) -> bool {
match (*self) {
One(a1) => match (*other) {
One(b1) => return a1 == b1,
_ => return false
},
Two(a1, a2) => match (*other) {
Two(b1, b2) => return a1 == b1 && a2 == b2,
_ => return false
},
Three(a1, a2, a3) => match (*other) {
Three(b1, b2, b3) => return a1 == b1 && a2 == b2 && a3 == b3,
_ => return false
}
}
}
#[cfg(stage0)]
pure fn ne(other: &Taggy) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &Taggy) -> bool { !(*self).eq(other) }
}
impl Taggypar<int> : Eq {
//let eq4: EqFn<Taggypar<int>> = |x,y| taggypareq::<int>(x, y);
#[cfg(stage0)]
pure fn eq(other: &Taggypar<int>) -> bool {
match self {
Onepar::<int>(a1) => match (*other) {
@ -278,15 +302,54 @@ mod tests {
}
}
}
pure fn ne(other: &Taggypar<int>) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &Taggypar<int>) -> bool {
match (*self) {
Onepar::<int>(a1) => match (*other) {
Onepar::<int>(b1) => return a1 == b1,
_ => return false
},
Twopar::<int>(a1, a2) => match (*other) {
Twopar::<int>(b1, b2) => return a1 == b1 && a2 == b2,
_ => return false
},
Threepar::<int>(a1, a2, a3) => match (*other) {
Threepar::<int>(b1, b2, b3) => {
return a1 == b1 && a2 == b2 && a3 == b3
}
_ => return false
}
}
}
#[cfg(stage0)]
pure fn ne(other: &Taggypar<int>) -> bool {
!self.eq(other)
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &Taggypar<int>) -> bool {
!(*self).eq(other)
}
}
impl RecCy : Eq {
#[cfg(stage0)]
pure fn eq(other: &RecCy) -> bool {
return self.x == (*other).x && self.y == (*other).y &&
self.t == (*other).t;
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &RecCy) -> bool {
return (*self).x == (*other).x && (*self).y == (*other).y &&
(*self).t == (*other).t;
}
#[cfg(stage0)]
pure fn ne(other: &RecCy) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &RecCy) -> bool { !(*self).eq(other) }
}
#[test]

View File

@ -88,6 +88,7 @@ fn mkname(nm: &str) -> Name {
}
impl Name : Eq {
#[cfg(stage0)]
pure fn eq(other: &Name) -> bool {
match self {
Long(ref e0a) => {
@ -104,30 +105,84 @@ impl Name : Eq {
}
}
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &Name) -> bool {
match (*self) {
Long(ref e0a) => {
match (*other) {
Long(ref e0b) => e0a == e0b,
_ => false
}
}
Short(e0a) => {
match (*other) {
Short(e0b) => e0a == e0b,
_ => false
}
}
}
}
#[cfg(stage0)]
pure fn ne(other: &Name) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &Name) -> bool { !(*self).eq(other) }
}
impl Occur : Eq {
#[cfg(stage0)]
pure fn eq(other: &Occur) -> bool {
(self as uint) == ((*other) as uint)
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &Occur) -> bool {
((*self) as uint) == ((*other) as uint)
}
#[cfg(stage0)]
pure fn ne(other: &Occur) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &Occur) -> bool { !(*self).eq(other) }
}
impl HasArg : Eq {
#[cfg(stage0)]
pure fn eq(other: &HasArg) -> bool {
(self as uint) == ((*other) as uint)
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &HasArg) -> bool {
((*self) as uint) == ((*other) as uint)
}
#[cfg(stage0)]
pure fn ne(other: &HasArg) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &HasArg) -> bool { !(*self).eq(other) }
}
impl Opt : Eq {
#[cfg(stage0)]
pure fn eq(other: &Opt) -> bool {
self.name == (*other).name &&
self.hasarg == (*other).hasarg &&
self.occur == (*other).occur
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &Opt) -> bool {
(*self).name == (*other).name &&
(*self).hasarg == (*other).hasarg &&
(*self).occur == (*other).occur
}
#[cfg(stage0)]
pure fn ne(other: &Opt) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &Opt) -> bool { !(*self).eq(other) }
}
/// Create an option that is required and takes an argument
@ -172,6 +227,7 @@ enum Optval { Val(~str), Given, }
pub type Matches = {opts: ~[Opt], vals: ~[~[Optval]], free: ~[~str]};
impl Optval : Eq {
#[cfg(stage0)]
pure fn eq(other: &Optval) -> bool {
match self {
Val(ref s) => match *other { Val (ref os) => s == os,
@ -180,16 +236,42 @@ impl Optval : Eq {
Given => true }
}
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &Optval) -> bool {
match (*self) {
Val(ref s) => match *other { Val (ref os) => s == os,
Given => false },
Given => match *other { Val(_) => false,
Given => true }
}
}
#[cfg(stage0)]
pure fn ne(other: &Optval) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &Optval) -> bool { !(*self).eq(other) }
}
impl Matches : Eq {
#[cfg(stage0)]
pure fn eq(other: &Matches) -> bool {
self.opts == (*other).opts &&
self.vals == (*other).vals &&
self.free == (*other).free
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &Matches) -> bool {
(*self).opts == (*other).opts &&
(*self).vals == (*other).vals &&
(*self).free == (*other).free
}
#[cfg(stage0)]
pure fn ne(other: &Matches) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &Matches) -> bool { !(*self).eq(other) }
}
fn is_arg(arg: &str) -> bool {
@ -221,6 +303,7 @@ pub enum Fail_ {
impl Fail_ : Eq {
// this whole thing should be easy to infer...
#[cfg(stage0)]
pure fn eq(other: &Fail_) -> bool {
match self {
ArgumentMissing(ref s) => {
@ -245,7 +328,37 @@ impl Fail_ : Eq {
}
}
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &Fail_) -> bool {
match (*self) {
ArgumentMissing(ref s) => {
match *other { ArgumentMissing(ref so) => s == so,
_ => false }
}
UnrecognizedOption(ref s) => {
match *other { UnrecognizedOption(ref so) => s == so,
_ => false }
}
OptionMissing(ref s) => {
match *other { OptionMissing(ref so) => s == so,
_ => false }
}
OptionDuplicated(ref s) => {
match *other { OptionDuplicated(ref so) => s == so,
_ => false }
}
UnexpectedArgument(ref s) => {
match *other { UnexpectedArgument(ref so) => s == so,
_ => false }
}
}
}
#[cfg(stage0)]
pure fn ne(other: &Fail_) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &Fail_) -> bool { !(*self).eq(other) }
}
/// Convert a `fail_` enum into an error string
@ -514,10 +627,20 @@ enum FailType {
}
impl FailType : Eq {
#[cfg(stage0)]
pure fn eq(other: &FailType) -> bool {
(self as uint) == ((*other) as uint)
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &FailType) -> bool {
((*self) as uint) == ((*other) as uint)
}
#[cfg(stage0)]
pure fn ne(other: &FailType) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &FailType) -> bool { !(*self).eq(other) }
}
/** A module which provides a way to specify descriptions and
@ -538,6 +661,7 @@ pub mod groups {
};
impl OptGroup : Eq {
#[cfg(stage0)]
pure fn eq(other: &OptGroup) -> bool {
self.short_name == (*other).short_name &&
self.long_name == (*other).long_name &&
@ -546,7 +670,21 @@ pub mod groups {
self.hasarg == (*other).hasarg &&
self.occur == (*other).occur
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &OptGroup) -> bool {
(*self).short_name == (*other).short_name &&
(*self).long_name == (*other).long_name &&
(*self).hint == (*other).hint &&
(*self).desc == (*other).desc &&
(*self).hasarg == (*other).hasarg &&
(*self).occur == (*other).occur
}
#[cfg(stage0)]
pure fn ne(other: &OptGroup) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &OptGroup) -> bool { !(*self).eq(other) }
}
/// Create a long option that is required and takes an argument

View File

@ -911,6 +911,7 @@ pub impl Deserializer: serialization::Deserializer {
}
impl Json : Eq {
#[cfg(stage0)]
pure fn eq(other: &Json) -> bool {
// XXX: This is ugly because matching on references is broken, and
// we can't match on dereferenced tuples without a copy.
@ -946,11 +947,53 @@ impl Json : Eq {
}
}
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &Json) -> bool {
// XXX: This is ugly because matching on references is broken, and
// we can't match on dereferenced tuples without a copy.
match (*self) {
Number(f0) =>
match *other { Number(f1) => f0 == f1, _ => false },
String(ref s0) =>
match *other { String(ref s1) => s0 == s1, _ => false },
Boolean(b0) =>
match *other { Boolean(b1) => b0 == b1, _ => false },
Null =>
match *other { Null => true, _ => false },
List(v0) =>
match *other { List(v1) => v0 == v1, _ => false },
Object(ref d0) => {
match *other {
Object(ref d1) => {
if d0.len() == d1.len() {
let mut equal = true;
for d0.each |k, v0| {
match d1.find_ref(k) {
Some(v1) if v0 == v1 => { },
_ => { equal = false; break }
}
};
equal
} else {
false
}
}
_ => false
}
}
}
}
#[cfg(stage0)]
pure fn ne(other: &Json) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &Json) -> bool { !(*self).eq(other) }
}
/// Test if two json values are less than one another
impl Json : Ord {
#[cfg(stage0)]
pure fn lt(other: &Json) -> bool {
match self {
Number(f0) => {
@ -1021,18 +1064,114 @@ impl Json : Ord {
}
}
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn lt(&self, other: &Json) -> bool {
match (*self) {
Number(f0) => {
match *other {
Number(f1) => f0 < f1,
String(_) | Boolean(_) | List(_) | Object(_) |
Null => true
}
}
String(ref s0) => {
match *other {
Number(_) => false,
String(ref s1) => s0 < s1,
Boolean(_) | List(_) | Object(_) | Null => true
}
}
Boolean(b0) => {
match *other {
Number(_) | String(_) => false,
Boolean(b1) => b0 < b1,
List(_) | Object(_) | Null => true
}
}
List(l0) => {
match *other {
Number(_) | String(_) | Boolean(_) => false,
List(l1) => l0 < l1,
Object(_) | Null => true
}
}
Object(ref d0) => {
match *other {
Number(_) | String(_) | Boolean(_) | List(_) => false,
Object(ref d1) => {
unsafe {
let mut d0_flat = ~[];
let mut d1_flat = ~[];
// XXX: this is horribly inefficient...
for d0.each |k, v| {
d0_flat.push((@copy *k, @copy *v));
}
d0_flat.qsort();
for d1.each |k, v| {
d1_flat.push((@copy *k, @copy *v));
}
d1_flat.qsort();
d0_flat < d1_flat
}
}
Null => true
}
}
Null => {
match *other {
Number(_) | String(_) | Boolean(_) | List(_) |
Object(_) =>
false,
Null => true
}
}
}
}
#[cfg(stage0)]
pure fn le(other: &Json) -> bool { !(*other).lt(&self) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn le(&self, other: &Json) -> bool { !(*other).lt(&(*self)) }
#[cfg(stage0)]
pure fn ge(other: &Json) -> bool { !self.lt(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ge(&self, other: &Json) -> bool { !(*self).lt(other) }
#[cfg(stage0)]
pure fn gt(other: &Json) -> bool { (*other).lt(&self) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn gt(&self, other: &Json) -> bool { (*other).lt(&(*self)) }
}
impl Error : Eq {
#[cfg(stage0)]
pure fn eq(other: &Error) -> bool {
self.line == other.line &&
self.col == other.col &&
self.msg == other.msg
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &Error) -> bool {
(*self).line == other.line &&
(*self).col == other.col &&
(*self).msg == other.msg
}
#[cfg(stage0)]
pure fn ne(other: &Error) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &Error) -> bool { !(*self).eq(other) }
}
trait ToJson { fn to_json() -> Json; }

View File

@ -148,6 +148,7 @@ pub fn each<T>(l: @List<T>, f: fn((&T)) -> bool) {
}
impl<T:Eq> List<T> : Eq {
#[cfg(stage0)]
pure fn eq(other: &List<T>) -> bool {
match self {
Cons(ref e0a, e1a) => {
@ -164,7 +165,29 @@ impl<T:Eq> List<T> : Eq {
}
}
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &List<T>) -> bool {
match (*self) {
Cons(ref e0a, e1a) => {
match (*other) {
Cons(ref e0b, e1b) => e0a == e0b && e1a == e1b,
_ => false
}
}
Nil => {
match (*other) {
Nil => true,
_ => false
}
}
}
}
#[cfg(stage0)]
pure fn ne(other: &List<T>) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &List<T>) -> bool { !(*self).eq(other) }
}
#[cfg(test)]

View File

@ -315,10 +315,20 @@ pure fn userinfo_to_str(userinfo: UserInfo) -> ~str {
}
impl UserInfo : Eq {
#[cfg(stage0)]
pure fn eq(other: &UserInfo) -> bool {
self.user == (*other).user && self.pass == (*other).pass
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &UserInfo) -> bool {
(*self).user == (*other).user && (*self).pass == (*other).pass
}
#[cfg(stage0)]
pure fn ne(other: &UserInfo) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &UserInfo) -> bool { !(*self).eq(other) }
}
pure fn query_from_str(rawquery: &str) -> Query {
@ -379,6 +389,7 @@ enum Input {
}
impl Input : Eq {
#[cfg(stage0)]
pure fn eq(other: &Input) -> bool {
match (self, (*other)) {
(Digit, Digit) => true,
@ -389,7 +400,23 @@ impl Input : Eq {
(Unreserved, _) => false
}
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &Input) -> bool {
match ((*self), (*other)) {
(Digit, Digit) => true,
(Hex, Hex) => true,
(Unreserved, Unreserved) => true,
(Digit, _) => false,
(Hex, _) => false,
(Unreserved, _) => false
}
}
#[cfg(stage0)]
pure fn ne(other: &Input) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &Input) -> bool { !(*self).eq(other) }
}
// returns userinfo, host, port, and unparsed part, or an error
@ -722,6 +749,7 @@ impl Url: to_str::ToStr {
}
impl Url : Eq {
#[cfg(stage0)]
pure fn eq(other: &Url) -> bool {
self.scheme == (*other).scheme
&& self.user == (*other).user
@ -731,10 +759,27 @@ impl Url : Eq {
&& self.query == (*other).query
&& self.fragment == (*other).fragment
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &Url) -> bool {
(*self).scheme == (*other).scheme
&& (*self).user == (*other).user
&& (*self).host == (*other).host
&& (*self).port == (*other).port
&& (*self).path == (*other).path
&& (*self).query == (*other).query
&& (*self).fragment == (*other).fragment
}
#[cfg(stage0)]
pure fn ne(other: &Url) -> bool {
!self.eq(other)
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &Url) -> bool {
!(*self).eq(other)
}
}
impl Url: IterBytes {

View File

@ -871,6 +871,7 @@ mod test_tim_sort {
}
impl CVal: Ord {
#[cfg(stage0)]
pure fn lt(other: &CVal) -> bool {
unsafe {
let rng = rand::Rng();
@ -878,9 +879,30 @@ mod test_tim_sort {
}
self.val < other.val
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn lt(&self, other: &CVal) -> bool {
unsafe {
let rng = rand::Rng();
if rng.gen_float() > 0.995 { fail ~"It's happening!!!"; }
}
(*self).val < other.val
}
#[cfg(stage0)]
pure fn le(other: &CVal) -> bool { self.val <= other.val }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn le(&self, other: &CVal) -> bool { (*self).val <= other.val }
#[cfg(stage0)]
pure fn gt(other: &CVal) -> bool { self.val > other.val }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn gt(&self, other: &CVal) -> bool { (*self).val > other.val }
#[cfg(stage0)]
pure fn ge(other: &CVal) -> bool { self.val >= other.val }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ge(&self, other: &CVal) -> bool { (*self).val >= other.val }
}
fn check_sort(v1: &[mut int], v2: &[mut int]) {
@ -934,6 +956,8 @@ mod test_tim_sort {
}
struct DVal { val: ~uint }
#[cfg(stage0)]
impl DVal: Ord {
pure fn lt(_x: &DVal) -> bool { true }
pure fn le(_x: &DVal) -> bool { true }
@ -941,6 +965,15 @@ mod test_tim_sort {
pure fn ge(_x: &DVal) -> bool { true }
}
#[cfg(stage1)]
#[cfg(stage2)]
impl DVal: Ord {
pure fn lt(&self, _x: &DVal) -> bool { true }
pure fn le(&self, _x: &DVal) -> bool { true }
pure fn gt(&self, _x: &DVal) -> bool { true }
pure fn ge(&self, _x: &DVal) -> bool { true }
}
#[test]
fn test_bad_Ord_impl() {
let rng = rand::Rng();
@ -1150,10 +1183,42 @@ mod big_tests {
}
impl LVal: Ord {
pure fn lt(other: &a/LVal/&self) -> bool { self.val < other.val }
pure fn le(other: &a/LVal/&self) -> bool { self.val <= other.val }
pure fn gt(other: &a/LVal/&self) -> bool { self.val > other.val }
pure fn ge(other: &a/LVal/&self) -> bool { self.val >= other.val }
#[cfg(stage0)]
pure fn lt(other: &a/LVal/&self) -> bool {
self.val < other.val
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn lt(&self, other: &a/LVal/&self) -> bool {
(*self).val < other.val
}
#[cfg(stage0)]
pure fn le(other: &a/LVal/&self) -> bool {
self.val <= other.val
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn le(&self, other: &a/LVal/&self) -> bool {
(*self).val <= other.val
}
#[cfg(stage0)]
pure fn gt(other: &a/LVal/&self) -> bool {
self.val > other.val
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn gt(&self, other: &a/LVal/&self) -> bool {
(*self).val > other.val
}
#[cfg(stage0)]
pure fn ge(other: &a/LVal/&self) -> bool {
self.val >= other.val
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ge(&self, other: &a/LVal/&self) -> bool {
(*self).val >= other.val
}
}
}

View File

@ -85,10 +85,20 @@ fn parse_opts(args: &[~str]) -> OptRes {
pub enum TestResult { TrOk, TrFailed, TrIgnored, }
impl TestResult : Eq {
#[cfg(stage0)]
pure fn eq(other: &TestResult) -> bool {
(self as uint) == ((*other) as uint)
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &TestResult) -> bool {
((*self) as uint) == ((*other) as uint)
}
#[cfg(stage0)]
pure fn ne(other: &TestResult) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &TestResult) -> bool { !(*self).eq(other) }
}
type ConsoleTestState =

View File

@ -24,10 +24,20 @@ extern mod rustrt {
pub type Timespec = {sec: i64, nsec: i32};
impl Timespec : Eq {
#[cfg(stage0)]
pure fn eq(other: &Timespec) -> bool {
self.sec == (*other).sec && self.nsec == (*other).nsec
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &Timespec) -> bool {
(*self).sec == (*other).sec && (*self).nsec == (*other).nsec
}
#[cfg(stage0)]
pure fn ne(other: &Timespec) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &Timespec) -> bool { !(*self).eq(other) }
}
/**
@ -81,6 +91,7 @@ type Tm_ = {
};
impl Tm_ : Eq {
#[cfg(stage0)]
pure fn eq(other: &Tm_) -> bool {
self.tm_sec == (*other).tm_sec &&
self.tm_min == (*other).tm_min &&
@ -95,7 +106,27 @@ impl Tm_ : Eq {
self.tm_zone == (*other).tm_zone &&
self.tm_nsec == (*other).tm_nsec
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &Tm_) -> bool {
(*self).tm_sec == (*other).tm_sec &&
(*self).tm_min == (*other).tm_min &&
(*self).tm_hour == (*other).tm_hour &&
(*self).tm_mday == (*other).tm_mday &&
(*self).tm_mon == (*other).tm_mon &&
(*self).tm_year == (*other).tm_year &&
(*self).tm_wday == (*other).tm_wday &&
(*self).tm_yday == (*other).tm_yday &&
(*self).tm_isdst == (*other).tm_isdst &&
(*self).tm_gmtoff == (*other).tm_gmtoff &&
(*self).tm_zone == (*other).tm_zone &&
(*self).tm_nsec == (*other).tm_nsec
}
#[cfg(stage0)]
pure fn ne(other: &Tm_) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &Tm_) -> bool { !(*self).eq(other) }
}
pub enum Tm {
@ -103,8 +134,16 @@ pub enum Tm {
}
impl Tm : Eq {
#[cfg(stage0)]
pure fn eq(other: &Tm) -> bool { *self == *(*other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &Tm) -> bool { *(*self) == *(*other) }
#[cfg(stage0)]
pure fn ne(other: &Tm) -> bool { *self != *(*other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &Tm) -> bool { *(*self) != *(*other) }
}
pub pure fn empty_tm() -> Tm {

View File

@ -50,8 +50,16 @@ impl<D: Deserializer> ident: Deserializable<D> {
}
impl ident: cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &ident) -> bool { self.repr == other.repr }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &ident) -> bool { (*self).repr == other.repr }
#[cfg(stage0)]
pure fn ne(other: &ident) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &ident) -> bool { !(*self).eq(other) }
}
impl ident: to_bytes::IterBytes {
@ -80,10 +88,20 @@ type node_id = int;
type def_id = {crate: crate_num, node: node_id};
impl def_id : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &def_id) -> bool {
self.crate == (*other).crate && self.node == (*other).node
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &def_id) -> bool {
(*self).crate == (*other).crate && (*self).node == (*other).node
}
#[cfg(stage0)]
pure fn ne(other: &def_id) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &def_id) -> bool { !(*self).eq(other) }
}
const local_crate: crate_num = 0;
@ -131,6 +149,7 @@ enum def {
}
impl def : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &def) -> bool {
match self {
def_fn(e0a, e1a) => {
@ -251,7 +270,133 @@ impl def : cmp::Eq {
}
}
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &def) -> bool {
match (*self) {
def_fn(e0a, e1a) => {
match (*other) {
def_fn(e0b, e1b) => e0a == e0b && e1a == e1b,
_ => false
}
}
def_static_method(e0a, e1a, e2a) => {
match (*other) {
def_static_method(e0b, e1b, e2b) =>
e0a == e0b && e1a == e1b && e2a == e2b,
_ => false
}
}
def_self(e0a) => {
match (*other) {
def_self(e0b) => e0a == e0b,
_ => false
}
}
def_mod(e0a) => {
match (*other) {
def_mod(e0b) => e0a == e0b,
_ => false
}
}
def_foreign_mod(e0a) => {
match (*other) {
def_foreign_mod(e0b) => e0a == e0b,
_ => false
}
}
def_const(e0a) => {
match (*other) {
def_const(e0b) => e0a == e0b,
_ => false
}
}
def_arg(e0a, e1a) => {
match (*other) {
def_arg(e0b, e1b) => e0a == e0b && e1a == e1b,
_ => false
}
}
def_local(e0a, e1a) => {
match (*other) {
def_local(e0b, e1b) => e0a == e0b && e1a == e1b,
_ => false
}
}
def_variant(e0a, e1a) => {
match (*other) {
def_variant(e0b, e1b) => e0a == e0b && e1a == e1b,
_ => false
}
}
def_ty(e0a) => {
match (*other) {
def_ty(e0b) => e0a == e0b,
_ => false
}
}
def_prim_ty(e0a) => {
match (*other) {
def_prim_ty(e0b) => e0a == e0b,
_ => false
}
}
def_ty_param(e0a, e1a) => {
match (*other) {
def_ty_param(e0b, e1b) => e0a == e0b && e1a == e1b,
_ => false
}
}
def_binding(e0a, e1a) => {
match (*other) {
def_binding(e0b, e1b) => e0a == e0b && e1a == e1b,
_ => false
}
}
def_use(e0a) => {
match (*other) {
def_use(e0b) => e0a == e0b,
_ => false
}
}
def_upvar(e0a, e1a, e2a, e3a) => {
match (*other) {
def_upvar(e0b, e1b, e2b, e3b) =>
e0a == e0b && e1a == e1b && e2a == e2b && e3a == e3b,
_ => false
}
}
def_class(e0a) => {
match (*other) {
def_class(e0b) => e0a == e0b,
_ => false
}
}
def_typaram_binder(e0a) => {
match (*other) {
def_typaram_binder(e1a) => e0a == e1a,
_ => false
}
}
def_region(e0a) => {
match (*other) {
def_region(e0b) => e0a == e0b,
_ => false
}
}
def_label(e0a) => {
match (*other) {
def_label(e0b) => e0a == e0b,
_ => false
}
}
}
}
#[cfg(stage0)]
pure fn ne(other: &def) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &def) -> bool { !(*self).eq(other) }
}
// The set of meta_items that define the compilation environment of the crate,
@ -334,6 +479,7 @@ impl binding_mode : to_bytes::IterBytes {
}
impl binding_mode : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &binding_mode) -> bool {
match self {
bind_by_value => {
@ -362,7 +508,41 @@ impl binding_mode : cmp::Eq {
}
}
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &binding_mode) -> bool {
match (*self) {
bind_by_value => {
match (*other) {
bind_by_value => true,
_ => false
}
}
bind_by_move => {
match (*other) {
bind_by_move => true,
_ => false
}
}
bind_by_ref(e0a) => {
match (*other) {
bind_by_ref(e0b) => e0a == e0b,
_ => false
}
}
bind_by_implicit_ref => {
match (*other) {
bind_by_implicit_ref => true,
_ => false
}
}
}
}
#[cfg(stage0)]
pure fn ne(other: &binding_mode) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &binding_mode) -> bool { !(*self).eq(other) }
}
#[auto_serialize]
@ -400,10 +580,20 @@ impl mutability : to_bytes::IterBytes {
}
impl mutability : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &mutability) -> bool {
(self as uint) == ((*other) as uint)
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &mutability) -> bool {
((*self) as uint) == ((*other) as uint)
}
#[cfg(stage0)]
pure fn ne(other: &mutability) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &mutability) -> bool { !(*self).eq(other) }
}
#[auto_serialize]
@ -416,10 +606,20 @@ pub enum Proto {
}
impl Proto : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &Proto) -> bool {
(self as uint) == ((*other) as uint)
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &Proto) -> bool {
((*self) as uint) == ((*other) as uint)
}
#[cfg(stage0)]
pure fn ne(other: &Proto) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &Proto) -> bool { !(*self).eq(other) }
}
impl Proto : to_bytes::IterBytes {
@ -479,10 +679,20 @@ enum binop {
}
impl binop : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &binop) -> bool {
(self as uint) == ((*other) as uint)
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &binop) -> bool {
((*self) as uint) == ((*other) as uint)
}
#[cfg(stage0)]
pure fn ne(other: &binop) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &binop) -> bool { !(*self).eq(other) }
}
#[auto_serialize]
@ -496,6 +706,7 @@ enum unop {
}
impl unop : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &unop) -> bool {
match self {
box(e0a) => {
@ -530,9 +741,51 @@ impl unop : cmp::Eq {
}
}
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &unop) -> bool {
match (*self) {
box(e0a) => {
match (*other) {
box(e0b) => e0a == e0b,
_ => false
}
}
uniq(e0a) => {
match (*other) {
uniq(e0b) => e0a == e0b,
_ => false
}
}
deref => {
match (*other) {
deref => true,
_ => false
}
}
not => {
match (*other) {
not => true,
_ => false
}
}
neg => {
match (*other) {
neg => true,
_ => false
}
}
}
}
#[cfg(stage0)]
pure fn ne(other: &unop) -> bool {
!self.eq(other)
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &unop) -> bool {
!(*self).eq(other)
}
}
// Generally, after typeck you can get the inferred value
@ -557,6 +810,7 @@ impl<T: to_bytes::IterBytes> inferable<T> : to_bytes::IterBytes {
}
impl<T:cmp::Eq> inferable<T> : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &inferable<T>) -> bool {
match self {
expl(e0a) => {
@ -573,7 +827,29 @@ impl<T:cmp::Eq> inferable<T> : cmp::Eq {
}
}
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &inferable<T>) -> bool {
match (*self) {
expl(e0a) => {
match (*other) {
expl(e0b) => e0a == e0b,
_ => false
}
}
infer(e0a) => {
match (*other) {
infer(e0b) => e0a == e0b,
_ => false
}
}
}
}
#[cfg(stage0)]
pure fn ne(other: &inferable<T>) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &inferable<T>) -> bool { !(*self).eq(other) }
}
// "resolved" mode: the real modes.
@ -589,10 +865,20 @@ impl rmode : to_bytes::IterBytes {
impl rmode : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &rmode) -> bool {
(self as uint) == ((*other) as uint)
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &rmode) -> bool {
((*self) as uint) == ((*other) as uint)
}
#[cfg(stage0)]
pure fn ne(other: &rmode) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &rmode) -> bool { !(*self).eq(other) }
}
// inferable mode.
@ -642,6 +928,7 @@ type field = spanned<field_>;
enum blk_check_mode { default_blk, unsafe_blk, }
impl blk_check_mode : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &blk_check_mode) -> bool {
match (self, (*other)) {
(default_blk, default_blk) => true,
@ -650,7 +937,21 @@ impl blk_check_mode : cmp::Eq {
(unsafe_blk, _) => false,
}
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &blk_check_mode) -> bool {
match ((*self), (*other)) {
(default_blk, default_blk) => true,
(unsafe_blk, unsafe_blk) => true,
(default_blk, _) => false,
(unsafe_blk, _) => false,
}
}
#[cfg(stage0)]
pure fn ne(other: &blk_check_mode) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &blk_check_mode) -> bool { !(*self).eq(other) }
}
#[auto_serialize]
@ -866,6 +1167,7 @@ enum lit_ {
}
impl ast::lit_: cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &ast::lit_) -> bool {
match (self, *other) {
(lit_str(a), lit_str(b)) => a == b,
@ -892,7 +1194,39 @@ impl ast::lit_: cmp::Eq {
(lit_bool(_), _) => false
}
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &ast::lit_) -> bool {
match ((*self), *other) {
(lit_str(a), lit_str(b)) => a == b,
(lit_int(val_a, ty_a), lit_int(val_b, ty_b)) => {
val_a == val_b && ty_a == ty_b
}
(lit_uint(val_a, ty_a), lit_uint(val_b, ty_b)) => {
val_a == val_b && ty_a == ty_b
}
(lit_int_unsuffixed(a), lit_int_unsuffixed(b)) => a == b,
(lit_float(val_a, ty_a), lit_float(val_b, ty_b)) => {
val_a == val_b && ty_a == ty_b
}
(lit_float_unsuffixed(a), lit_float_unsuffixed(b)) => a == b,
(lit_nil, lit_nil) => true,
(lit_bool(a), lit_bool(b)) => a == b,
(lit_str(_), _) => false,
(lit_int(*), _) => false,
(lit_uint(*), _) => false,
(lit_int_unsuffixed(*), _) => false,
(lit_float(*), _) => false,
(lit_float_unsuffixed(*), _) => false,
(lit_nil, _) => false,
(lit_bool(_), _) => false
}
}
#[cfg(stage0)]
pure fn ne(other: &ast::lit_) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &ast::lit_) -> bool { !(*self).eq(other) }
}
// NB: If you change this, you'll probably want to change the corresponding
@ -934,6 +1268,7 @@ impl int_ty : to_bytes::IterBytes {
}
impl int_ty : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &int_ty) -> bool {
match (self, (*other)) {
(ty_i, ty_i) => true,
@ -950,7 +1285,29 @@ impl int_ty : cmp::Eq {
(ty_i64, _) => false,
}
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &int_ty) -> bool {
match ((*self), (*other)) {
(ty_i, ty_i) => true,
(ty_char, ty_char) => true,
(ty_i8, ty_i8) => true,
(ty_i16, ty_i16) => true,
(ty_i32, ty_i32) => true,
(ty_i64, ty_i64) => true,
(ty_i, _) => false,
(ty_char, _) => false,
(ty_i8, _) => false,
(ty_i16, _) => false,
(ty_i32, _) => false,
(ty_i64, _) => false,
}
}
#[cfg(stage0)]
pure fn ne(other: &int_ty) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &int_ty) -> bool { !(*self).eq(other) }
}
#[auto_serialize]
@ -964,6 +1321,7 @@ impl uint_ty : to_bytes::IterBytes {
}
impl uint_ty : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &uint_ty) -> bool {
match (self, (*other)) {
(ty_u, ty_u) => true,
@ -978,7 +1336,27 @@ impl uint_ty : cmp::Eq {
(ty_u64, _) => false
}
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &uint_ty) -> bool {
match ((*self), (*other)) {
(ty_u, ty_u) => true,
(ty_u8, ty_u8) => true,
(ty_u16, ty_u16) => true,
(ty_u32, ty_u32) => true,
(ty_u64, ty_u64) => true,
(ty_u, _) => false,
(ty_u8, _) => false,
(ty_u16, _) => false,
(ty_u32, _) => false,
(ty_u64, _) => false
}
}
#[cfg(stage0)]
pure fn ne(other: &uint_ty) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &uint_ty) -> bool { !(*self).eq(other) }
}
#[auto_serialize]
@ -991,13 +1369,26 @@ impl float_ty : to_bytes::IterBytes {
}
}
impl float_ty : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &float_ty) -> bool {
match (self, (*other)) {
(ty_f, ty_f) | (ty_f32, ty_f32) | (ty_f64, ty_f64) => true,
(ty_f, _) | (ty_f32, _) | (ty_f64, _) => false
}
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &float_ty) -> bool {
match ((*self), (*other)) {
(ty_f, ty_f) | (ty_f32, ty_f32) | (ty_f64, ty_f64) => true,
(ty_f, _) | (ty_f32, _) | (ty_f64, _) => false
}
}
#[cfg(stage0)]
pure fn ne(other: &float_ty) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &float_ty) -> bool { !(*self).eq(other) }
}
#[auto_serialize]
@ -1016,6 +1407,7 @@ enum prim_ty {
}
impl prim_ty : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &prim_ty) -> bool {
match self {
ty_int(e0a) => {
@ -1050,7 +1442,47 @@ impl prim_ty : cmp::Eq {
}
}
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &prim_ty) -> bool {
match (*self) {
ty_int(e0a) => {
match (*other) {
ty_int(e0b) => e0a == e0b,
_ => false
}
}
ty_uint(e0a) => {
match (*other) {
ty_uint(e0b) => e0a == e0b,
_ => false
}
}
ty_float(e0a) => {
match (*other) {
ty_float(e0b) => e0a == e0b,
_ => false
}
}
ty_str => {
match (*other) {
ty_str => true,
_ => false
}
}
ty_bool => {
match (*other) {
ty_bool => true,
_ => false
}
}
}
}
#[cfg(stage0)]
pure fn ne(other: &prim_ty) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &prim_ty) -> bool { !(*self).eq(other) }
}
#[auto_serialize]
@ -1074,15 +1506,30 @@ enum Onceness {
}
impl Onceness : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &Onceness) -> bool {
match (self, *other) {
(Once, Once) | (Many, Many) => true,
_ => false
}
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &Onceness) -> bool {
match ((*self), *other) {
(Once, Once) | (Many, Many) => true,
_ => false
}
}
#[cfg(stage0)]
pure fn ne(other: &Onceness) -> bool {
!self.eq(other)
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &Onceness) -> bool {
!(*self).eq(other)
}
}
#[auto_serialize]
@ -1121,12 +1568,24 @@ enum ty_ {
// Equality and byte-iter (hashing) can be quite approximate for AST types.
// since we only care about this for normalizing them to "real" types.
impl Ty : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &Ty) -> bool {
ptr::addr_of(&self) == ptr::addr_of(&(*other))
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &Ty) -> bool {
ptr::addr_of(&(*self)) == ptr::addr_of(&(*other))
}
#[cfg(stage0)]
pure fn ne(other: &Ty) -> bool {
ptr::addr_of(&self) != ptr::addr_of(&(*other))
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &Ty) -> bool {
ptr::addr_of(&(*self)) != ptr::addr_of(&(*other))
}
}
impl Ty : to_bytes::IterBytes {
@ -1163,10 +1622,20 @@ impl purity : to_bytes::IterBytes {
}
impl purity : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &purity) -> bool {
(self as uint) == ((*other) as uint)
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &purity) -> bool {
((*self) as uint) == ((*other) as uint)
}
#[cfg(stage0)]
pure fn ne(other: &purity) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &purity) -> bool { !(*self).eq(other) }
}
#[auto_serialize]
@ -1184,6 +1653,7 @@ impl ret_style : to_bytes::IterBytes {
}
impl ret_style : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &ret_style) -> bool {
match (self, (*other)) {
(noreturn, noreturn) => true,
@ -1192,7 +1662,21 @@ impl ret_style : cmp::Eq {
(return_val, _) => false,
}
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &ret_style) -> bool {
match ((*self), (*other)) {
(noreturn, noreturn) => true,
(return_val, return_val) => true,
(noreturn, _) => false,
(return_val, _) => false,
}
}
#[cfg(stage0)]
pure fn ne(other: &ret_style) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &ret_style) -> bool { !(*self).eq(other) }
}
#[auto_serialize]
@ -1207,6 +1691,7 @@ enum self_ty_ {
}
impl self_ty_ : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &self_ty_) -> bool {
match self {
sty_static => {
@ -1247,7 +1732,53 @@ impl self_ty_ : cmp::Eq {
}
}
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &self_ty_) -> bool {
match (*self) {
sty_static => {
match (*other) {
sty_static => true,
_ => false
}
}
sty_by_ref => {
match (*other) {
sty_by_ref => true,
_ => false
}
}
sty_value => {
match (*other) {
sty_value => true,
_ => false
}
}
sty_region(e0a) => {
match (*other) {
sty_region(e0b) => e0a == e0b,
_ => false
}
}
sty_box(e0a) => {
match (*other) {
sty_box(e0b) => e0a == e0b,
_ => false
}
}
sty_uniq(e0a) => {
match (*other) {
sty_uniq(e0b) => e0a == e0b,
_ => false
}
}
}
}
#[cfg(stage0)]
pure fn ne(other: &self_ty_) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &self_ty_) -> bool { !(*self).eq(other) }
}
type self_ty = spanned<self_ty_>;
@ -1278,13 +1809,24 @@ enum foreign_abi {
enum foreign_mod_sort { named, anonymous }
impl foreign_mod_sort : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &foreign_mod_sort) -> bool {
(self as uint) == ((*other) as uint)
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &foreign_mod_sort) -> bool {
((*self) as uint) == ((*other) as uint)
}
#[cfg(stage0)]
pure fn ne(other: &foreign_mod_sort) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &foreign_mod_sort) -> bool { !(*self).eq(other) }
}
impl foreign_abi : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &foreign_abi) -> bool {
match (self, (*other)) {
(foreign_abi_rust_intrinsic, foreign_abi_rust_intrinsic) => true,
@ -1295,7 +1837,23 @@ impl foreign_abi : cmp::Eq {
(foreign_abi_stdcall, _) => false,
}
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &foreign_abi) -> bool {
match ((*self), (*other)) {
(foreign_abi_rust_intrinsic, foreign_abi_rust_intrinsic) => true,
(foreign_abi_cdecl, foreign_abi_cdecl) => true,
(foreign_abi_stdcall, foreign_abi_stdcall) => true,
(foreign_abi_rust_intrinsic, _) => false,
(foreign_abi_cdecl, _) => false,
(foreign_abi_stdcall, _) => false,
}
}
#[cfg(stage0)]
pure fn ne(other: &foreign_abi) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &foreign_abi) -> bool { !(*self).eq(other) }
}
#[auto_serialize]
@ -1343,10 +1901,20 @@ type path_list_ident = spanned<path_list_ident_>;
enum namespace { module_ns, type_value_ns }
impl namespace : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &namespace) -> bool {
(self as uint) == ((*other) as uint)
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &namespace) -> bool {
((*self) as uint) == ((*other) as uint)
}
#[cfg(stage0)]
pure fn ne(other: &namespace) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &namespace) -> bool { !(*self).eq(other) }
}
type view_path = spanned<view_path_>;
@ -1393,10 +1961,20 @@ type attribute = spanned<attribute_>;
enum attr_style { attr_outer, attr_inner, }
impl attr_style : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &attr_style) -> bool {
(self as uint) == ((*other) as uint)
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &attr_style) -> bool {
((*self) as uint) == ((*other) as uint)
}
#[cfg(stage0)]
pure fn ne(other: &attr_style) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &attr_style) -> bool { !(*self).eq(other) }
}
// doc-comments are promoted to attributes that have is_sugared_doc = true
@ -1422,6 +2000,7 @@ type trait_ref = {path: @path, ref_id: node_id, impl_id: node_id};
enum visibility { public, private, inherited }
impl visibility : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &visibility) -> bool {
match (self, (*other)) {
(public, public) => true,
@ -1432,7 +2011,23 @@ impl visibility : cmp::Eq {
(inherited, _) => false,
}
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &visibility) -> bool {
match ((*self), (*other)) {
(public, public) => true,
(private, private) => true,
(inherited, inherited) => true,
(public, _) => false,
(private, _) => false,
(inherited, _) => false,
}
}
#[cfg(stage0)]
pure fn ne(other: &visibility) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &visibility) -> bool { !(*self).eq(other) }
}
#[auto_serialize]
@ -1453,6 +2048,7 @@ enum struct_field_kind {
}
impl struct_field_kind : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &struct_field_kind) -> bool {
match self {
named_field(ident_a, class_mutability_a, visibility_a) => {
@ -1474,7 +2070,38 @@ impl struct_field_kind : cmp::Eq {
}
}
}
pure fn ne(other: &struct_field_kind) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &struct_field_kind) -> bool {
match (*self) {
named_field(ident_a, class_mutability_a, visibility_a) => {
match *other {
named_field(ident_b, class_mutability_b, visibility_b)
=> {
ident_a == ident_b &&
class_mutability_a == class_mutability_b &&
visibility_a == visibility_b
}
unnamed_field => false
}
}
unnamed_field => {
match *other {
named_field(*) => false,
unnamed_field => true
}
}
}
}
#[cfg(stage0)]
pure fn ne(other: &struct_field_kind) -> bool {
!self.eq(other)
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &struct_field_kind) -> bool {
!(*self).eq(other)
}
}
#[auto_serialize]
@ -1530,6 +2157,7 @@ impl class_mutability : to_bytes::IterBytes {
}
impl class_mutability : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &class_mutability) -> bool {
match (self, (*other)) {
(class_mutable, class_mutable) => true,
@ -1538,7 +2166,21 @@ impl class_mutability : cmp::Eq {
(class_immutable, _) => false,
}
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &class_mutability) -> bool {
match ((*self), (*other)) {
(class_mutable, class_mutable) => true,
(class_immutable, class_immutable) => true,
(class_mutable, _) => false,
(class_immutable, _) => false,
}
}
#[cfg(stage0)]
pure fn ne(other: &class_mutability) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &class_mutability) -> bool { !(*self).eq(other) }
}
type class_ctor = spanned<class_ctor_>;

View File

@ -12,6 +12,7 @@ enum path_elt {
}
impl path_elt : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &path_elt) -> bool {
match self {
path_mod(e0a) => {
@ -28,7 +29,29 @@ impl path_elt : cmp::Eq {
}
}
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &path_elt) -> bool {
match (*self) {
path_mod(e0a) => {
match (*other) {
path_mod(e0b) => e0a == e0b,
_ => false
}
}
path_name(e0a) => {
match (*other) {
path_name(e0b) => e0a == e0b,
_ => false
}
}
}
}
#[cfg(stage0)]
pure fn ne(other: &path_elt) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &path_elt) -> bool { !(*self).eq(other) }
}
type path = ~[path_elt];

View File

@ -338,10 +338,20 @@ enum inline_attr {
}
impl inline_attr : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &inline_attr) -> bool {
(self as uint) == ((*other) as uint)
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &inline_attr) -> bool {
((*self) as uint) == ((*other) as uint)
}
#[cfg(stage0)]
pure fn ne(other: &inline_attr) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &inline_attr) -> bool { !(*self).eq(other) }
}
/// True if something like #[inline] is found in the list of attrs.

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

View File

@ -149,10 +149,20 @@ enum level {
}
impl level : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &level) -> bool {
(self as uint) == ((*other) as uint)
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &level) -> bool {
((*self) as uint) == ((*other) as uint)
}
#[cfg(stage0)]
pure fn ne(other: &level) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &level) -> bool { !(*self).eq(other) }
}
fn diagnosticstr(lvl: level) -> ~str {

View File

@ -6,6 +6,7 @@ use ast_builder::{path, append_types};
enum direction { send, recv }
impl direction : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &direction) -> bool {
match (self, (*other)) {
(send, send) => true,
@ -14,7 +15,21 @@ impl direction : cmp::Eq {
(recv, _) => false,
}
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &direction) -> bool {
match ((*self), (*other)) {
(send, send) => true,
(recv, recv) => true,
(send, _) => false,
(recv, _) => false,
}
}
#[cfg(stage0)]
pure fn ne(other: &direction) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &direction) -> bool { !(*self).eq(other) }
}
impl direction: ToStr {

View File

@ -20,12 +20,24 @@ enum cmnt_style {
}
impl cmnt_style : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &cmnt_style) -> bool {
(self as uint) == ((*other) as uint)
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &cmnt_style) -> bool {
((*self) as uint) == ((*other) as uint)
}
#[cfg(stage0)]
pure fn ne(other: &cmnt_style) -> bool {
(self as uint) != ((*other) as uint)
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &cmnt_style) -> bool {
((*self) as uint) != ((*other) as uint)
}
}
type cmnt = {style: cmnt_style, lines: ~[~str], pos: BytePos};

View File

@ -29,12 +29,24 @@ pub enum ObsoleteSyntax {
}
impl ObsoleteSyntax : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &ObsoleteSyntax) -> bool {
self as uint == (*other) as uint
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &ObsoleteSyntax) -> bool {
(*self) as uint == (*other) as uint
}
#[cfg(stage0)]
pure fn ne(other: &ObsoleteSyntax) -> bool {
!self.eq(other)
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &ObsoleteSyntax) -> bool {
!(*self).eq(other)
}
}
impl ObsoleteSyntax: to_bytes::IterBytes {

View File

@ -3743,10 +3743,20 @@ impl Parser {
}
impl restriction : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &restriction) -> bool {
(self as uint) == ((*other) as uint)
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &restriction) -> bool {
((*self) as uint) == ((*other) as uint)
}
#[cfg(stage0)]
pure fn ne(other: &restriction) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &restriction) -> bool { !(*self).eq(other) }
}
//

View File

@ -463,13 +463,24 @@ fn reserved_keyword_table() -> HashMap<~str, ()> {
}
impl binop : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &binop) -> bool {
(self as uint) == ((*other) as uint)
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &binop) -> bool {
((*self) as uint) == ((*other) as uint)
}
#[cfg(stage0)]
pure fn ne(other: &binop) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &binop) -> bool { !(*self).eq(other) }
}
impl Token : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &Token) -> bool {
match self {
EQ => {
@ -738,7 +749,281 @@ impl Token : cmp::Eq {
}
}
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &Token) -> bool {
match (*self) {
EQ => {
match (*other) {
EQ => true,
_ => false
}
}
LT => {
match (*other) {
LT => true,
_ => false
}
}
LE => {
match (*other) {
LE => true,
_ => false
}
}
EQEQ => {
match (*other) {
EQEQ => true,
_ => false
}
}
NE => {
match (*other) {
NE => true,
_ => false
}
}
GE => {
match (*other) {
GE => true,
_ => false
}
}
GT => {
match (*other) {
GT => true,
_ => false
}
}
ANDAND => {
match (*other) {
ANDAND => true,
_ => false
}
}
OROR => {
match (*other) {
OROR => true,
_ => false
}
}
NOT => {
match (*other) {
NOT => true,
_ => false
}
}
TILDE => {
match (*other) {
TILDE => true,
_ => false
}
}
BINOP(e0a) => {
match (*other) {
BINOP(e0b) => e0a == e0b,
_ => false
}
}
BINOPEQ(e0a) => {
match (*other) {
BINOPEQ(e0b) => e0a == e0b,
_ => false
}
}
AT => {
match (*other) {
AT => true,
_ => false
}
}
DOT => {
match (*other) {
DOT => true,
_ => false
}
}
DOTDOT => {
match (*other) {
DOTDOT => true,
_ => false
}
}
ELLIPSIS => {
match (*other) {
ELLIPSIS => true,
_ => false
}
}
COMMA => {
match (*other) {
COMMA => true,
_ => false
}
}
SEMI => {
match (*other) {
SEMI => true,
_ => false
}
}
COLON => {
match (*other) {
COLON => true,
_ => false
}
}
MOD_SEP => {
match (*other) {
MOD_SEP => true,
_ => false
}
}
RARROW => {
match (*other) {
RARROW => true,
_ => false
}
}
LARROW => {
match (*other) {
LARROW => true,
_ => false
}
}
DARROW => {
match (*other) {
DARROW => true,
_ => false
}
}
FAT_ARROW => {
match (*other) {
FAT_ARROW => true,
_ => false
}
}
LPAREN => {
match (*other) {
LPAREN => true,
_ => false
}
}
RPAREN => {
match (*other) {
RPAREN => true,
_ => false
}
}
LBRACKET => {
match (*other) {
LBRACKET => true,
_ => false
}
}
RBRACKET => {
match (*other) {
RBRACKET => true,
_ => false
}
}
LBRACE => {
match (*other) {
LBRACE => true,
_ => false
}
}
RBRACE => {
match (*other) {
RBRACE => true,
_ => false
}
}
POUND => {
match (*other) {
POUND => true,
_ => false
}
}
DOLLAR => {
match (*other) {
DOLLAR => true,
_ => false
}
}
LIT_INT(e0a, e1a) => {
match (*other) {
LIT_INT(e0b, e1b) => e0a == e0b && e1a == e1b,
_ => false
}
}
LIT_UINT(e0a, e1a) => {
match (*other) {
LIT_UINT(e0b, e1b) => e0a == e0b && e1a == e1b,
_ => false
}
}
LIT_INT_UNSUFFIXED(e0a) => {
match (*other) {
LIT_INT_UNSUFFIXED(e0b) => e0a == e0b,
_ => false
}
}
LIT_FLOAT(e0a, e1a) => {
match (*other) {
LIT_FLOAT(e0b, e1b) => e0a == e0b && e1a == e1b,
_ => false
}
}
LIT_FLOAT_UNSUFFIXED(e0a) => {
match (*other) {
LIT_FLOAT_UNSUFFIXED(e0b) => e0a == e0b,
_ => false
}
}
LIT_STR(e0a) => {
match (*other) {
LIT_STR(e0b) => e0a == e0b,
_ => false
}
}
IDENT(e0a, e1a) => {
match (*other) {
IDENT(e0b, e1b) => e0a == e0b && e1a == e1b,
_ => false
}
}
UNDERSCORE => {
match (*other) {
UNDERSCORE => true,
_ => false
}
}
INTERPOLATED(_) => {
match (*other) {
INTERPOLATED(_) => true,
_ => false
}
}
DOC_COMMENT(e0a) => {
match (*other) {
DOC_COMMENT(e0b) => e0a == e0b,
_ => false
}
}
EOF => {
match (*other) {
EOF => true,
_ => false
}
}
}
}
#[cfg(stage0)]
pure fn ne(other: &Token) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &Token) -> bool { !(*self).eq(other) }
}
// Local Variables:

View File

@ -56,6 +56,7 @@ use dvec::DVec;
enum breaks { consistent, inconsistent, }
impl breaks : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &breaks) -> bool {
match (self, (*other)) {
(consistent, consistent) => true,
@ -64,7 +65,21 @@ impl breaks : cmp::Eq {
(inconsistent, _) => false,
}
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &breaks) -> bool {
match ((*self), (*other)) {
(consistent, consistent) => true,
(inconsistent, inconsistent) => true,
(consistent, _) => false,
(inconsistent, _) => false,
}
}
#[cfg(stage0)]
pure fn ne(other: &breaks) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &breaks) -> bool { !(*self).eq(other) }
}
type break_t = {offset: int, blank_space: int};

View File

@ -2,6 +2,5 @@ fn main() {
fn f() { }
fn g() { }
let x = f == g;
//~^ ERROR mismatched types
//~^^ ERROR failed to find an implementation of trait
//~^ ERROR binary operation == cannot be applied
}

View File

@ -1,7 +1,7 @@
enum thing = uint;
impl thing : cmp::Ord { //~ ERROR missing method `gt`
pure fn lt(other: &thing) -> bool { *self < **other }
pure fn le(other: &thing) -> bool { *self < **other }
pure fn ge(other: &thing) -> bool { *self < **other }
pure fn lt(&self, other: &thing) -> bool { **self < **other }
pure fn le(&self, other: &thing) -> bool { **self < **other }
pure fn ge(&self, other: &thing) -> bool { **self < **other }
}
fn main() {}

View File

@ -43,8 +43,8 @@ enum Expr {
}
impl Expr : cmp::Eq {
pure fn eq(other: &Expr) -> bool {
match self {
pure fn eq(&self, other: &Expr) -> bool {
match *self {
Val(e0a) => {
match *other {
Val(e0b) => e0a == e0b,
@ -65,26 +65,26 @@ impl Expr : cmp::Eq {
}
}
}
pure fn ne(other: &Expr) -> bool { !self.eq(other) }
pure fn ne(&self, other: &Expr) -> bool { !(*self).eq(other) }
}
impl AnEnum : cmp::Eq {
pure fn eq(other: &AnEnum) -> bool {
self.v == other.v
pure fn eq(&self, other: &AnEnum) -> bool {
(*self).v == other.v
}
pure fn ne(other: &AnEnum) -> bool { !self.eq(other) }
pure fn ne(&self, other: &AnEnum) -> bool { !(*self).eq(other) }
}
impl Point : cmp::Eq {
pure fn eq(other: &Point) -> bool {
pure fn eq(&self, other: &Point) -> bool {
self.x == other.x && self.y == other.y
}
pure fn ne(other: &Point) -> bool { !self.eq(other) }
pure fn ne(&self, other: &Point) -> bool { !(*self).eq(other) }
}
impl<T:cmp::Eq> Quark<T> : cmp::Eq {
pure fn eq(other: &Quark<T>) -> bool {
match self {
pure fn eq(&self, other: &Quark<T>) -> bool {
match *self {
Top(ref q) => {
match *other {
Top(ref r) => q == r,
@ -99,14 +99,14 @@ impl<T:cmp::Eq> Quark<T> : cmp::Eq {
},
}
}
pure fn ne(other: &Quark<T>) -> bool { !self.eq(other) }
pure fn ne(&self, other: &Quark<T>) -> bool { !(*self).eq(other) }
}
impl CLike : cmp::Eq {
pure fn eq(other: &CLike) -> bool {
self as int == *other as int
pure fn eq(&self, other: &CLike) -> bool {
(*self) as int == *other as int
}
pure fn ne(other: &CLike) -> bool { !self.eq(other) }
pure fn ne(&self, other: &CLike) -> bool { !(*self).eq(other) }
}
#[auto_serialize]
@ -114,10 +114,12 @@ impl CLike : cmp::Eq {
type Spanned<T> = {lo: uint, hi: uint, node: T};
impl<T:cmp::Eq> Spanned<T> : cmp::Eq {
pure fn eq(other: &Spanned<T>) -> bool {
self.lo == other.lo && self.hi == other.hi && self.node == other.node
pure fn eq(&self, other: &Spanned<T>) -> bool {
(*self).lo == other.lo &&
(*self).hi == other.hi &&
(*self).node == other.node
}
pure fn ne(other: &Spanned<T>) -> bool { !self.eq(other) }
pure fn ne(&self, other: &Spanned<T>) -> bool { !(*self).eq(other) }
}
#[auto_serialize]

View File

@ -91,10 +91,10 @@ fn p(x: int, y: int) -> p {
}
impl p : cmp::Eq {
pure fn eq(other: &p) -> bool {
self.x == (*other).x && self.y == (*other).y
pure fn eq(&self, other: &p) -> bool {
(*self).x == (*other).x && (*self).y == (*other).y
}
pure fn ne(other: &p) -> bool { !self.eq(other) }
pure fn ne(&self, other: &p) -> bool { !(*self).eq(other) }
}
fn test_class() {

View File

@ -7,10 +7,10 @@ use std::map::*;
enum cat_type { tuxedo, tabby, tortoiseshell }
impl cat_type : cmp::Eq {
pure fn eq(other: &cat_type) -> bool {
(self as uint) == ((*other) as uint)
pure fn eq(&self, other: &cat_type) -> bool {
((*self) as uint) == ((*other) as uint)
}
pure fn ne(other: &cat_type) -> bool { !self.eq(other) }
pure fn ne(&self, other: &cat_type) -> bool { !(*self).eq(other) }
}
// Very silly -- this just returns the value of the name field

View File

@ -1,7 +1,9 @@
fn main() {
enum x { foo }
impl x : core::cmp::Eq {
pure fn eq(other: &x) -> bool { self as int == (*other) as int }
pure fn ne(other: &x) -> bool { !self.eq(other) }
pure fn eq(&self, other: &x) -> bool {
(*self) as int == (*other) as int
}
pure fn ne(&self, other: &x) -> bool { !(*self).eq(other) }
}
}

View File

@ -2,10 +2,12 @@
struct foo { a: int, b: int, c: int }
impl foo : cmp::Eq {
pure fn eq(other: &foo) -> bool {
self.a == (*other).a && self.b == (*other).b && self.c == (*other).c
pure fn eq(&self, other: &foo) -> bool {
(*self).a == (*other).a &&
(*self).b == (*other).b &&
(*self).c == (*other).c
}
pure fn ne(other: &foo) -> bool { !self.eq(other) }
pure fn ne(&self, other: &foo) -> bool { !(*self).eq(other) }
}
const x : foo = foo { a:1, b:2, c: 3 };

View File

@ -1,10 +1,10 @@
enum chan { chan_t, }
impl chan : cmp::Eq {
pure fn eq(other: &chan) -> bool {
(self as uint) == ((*other) as uint)
pure fn eq(&self, other: &chan) -> bool {
((*self) as uint) == ((*other) as uint)
}
pure fn ne(other: &chan) -> bool { !self.eq(other) }
pure fn ne(&self, other: &chan) -> bool { !(*self).eq(other) }
}
fn wrapper3(i: chan) {

View File

@ -10,10 +10,10 @@ mod foo {
enum t { t1, t2, }
impl t : cmp::Eq {
pure fn eq(other: &t) -> bool {
(self as uint) == ((*other) as uint)
pure fn eq(&self, other: &t) -> bool {
((*self) as uint) == ((*other) as uint)
}
pure fn ne(other: &t) -> bool { !self.eq(other) }
pure fn ne(&self, other: &t) -> bool { !(*self).eq(other) }
}
fn f() -> t { return t1; }

View File

@ -12,10 +12,10 @@ fn test_rec() {
enum mood { happy, sad, }
impl mood : cmp::Eq {
pure fn eq(other: &mood) -> bool {
(self as uint) == ((*other) as uint)
pure fn eq(&self, other: &mood) -> bool {
((*self) as uint) == ((*other) as uint)
}
pure fn ne(other: &mood) -> bool { !self.eq(other) }
pure fn ne(&self, other: &mood) -> bool { !(*self).eq(other) }
}
fn test_tag() {

View File

@ -12,10 +12,10 @@ fn test_rec() {
enum mood { happy, sad, }
impl mood : cmp::Eq {
pure fn eq(other: &mood) -> bool {
(self as uint) == ((*other) as uint)
pure fn eq(&self, other: &mood) -> bool {
((*self) as uint) == ((*other) as uint)
}
pure fn ne(other: &mood) -> bool { !self.eq(other) }
pure fn ne(&self, other: &mood) -> bool { !(*self).eq(other) }
}
fn test_tag() {

View File

@ -11,10 +11,10 @@ mod pipes {
}
impl state : cmp::Eq {
pure fn eq(other: &state) -> bool {
(self as uint) == ((*other) as uint)
pure fn eq(&self, other: &state) -> bool {
((*self) as uint) == ((*other) as uint)
}
pure fn ne(other: &state) -> bool { !self.eq(other) }
pure fn ne(&self, other: &state) -> bool { !(*self).eq(other) }
}
type packet<T: Send> = {

View File

@ -31,10 +31,10 @@ impl Point : ops::Index<bool,int> {
}
impl Point : cmp::Eq {
pure fn eq(other: &Point) -> bool {
self.x == (*other).x && self.y == (*other).y
pure fn eq(&self, other: &Point) -> bool {
(*self).x == (*other).x && (*self).y == (*other).y
}
pure fn ne(other: &Point) -> bool { !self.eq(other) }
pure fn ne(&self, other: &Point) -> bool { !(*self).eq(other) }
}
fn main() {

View File

@ -3,10 +3,10 @@
enum foo { large, small, }
impl foo : cmp::Eq {
pure fn eq(other: &foo) -> bool {
(self as uint) == ((*other) as uint)
pure fn eq(&self, other: &foo) -> bool {
((*self) as uint) == ((*other) as uint)
}
pure fn ne(other: &foo) -> bool { !self.eq(other) }
pure fn ne(&self, other: &foo) -> bool { !(*self).eq(other) }
}
fn main() {

View File

@ -10,10 +10,10 @@ enum color {
}
impl color : cmp::Eq {
pure fn eq(other: &color) -> bool {
(self as uint) == ((*other) as uint)
pure fn eq(&self, other: &color) -> bool {
((*self) as uint) == ((*other) as uint)
}
pure fn ne(other: &color) -> bool { !self.eq(other) }
pure fn ne(&self, other: &color) -> bool { !(*self).eq(other) }
}
fn main() {

View File

@ -5,8 +5,8 @@
enum colour { red(int, int), green, }
impl colour : cmp::Eq {
pure fn eq(other: &colour) -> bool {
match self {
pure fn eq(&self, other: &colour) -> bool {
match *self {
red(a0, b0) => {
match (*other) {
red(a1, b1) => a0 == a1 && b0 == b1,
@ -21,7 +21,7 @@ impl colour : cmp::Eq {
}
}
}
pure fn ne(other: &colour) -> bool { !self.eq(other) }
pure fn ne(&self, other: &colour) -> bool { !(*self).eq(other) }
}
fn f() { let x = red(1, 2); let y = green; assert (x != y); }

View File

@ -48,8 +48,8 @@ enum t {
}
impl t : cmp::Eq {
pure fn eq(other: &t) -> bool {
match self {
pure fn eq(&self, other: &t) -> bool {
match *self {
tag1 => {
match (*other) {
tag1 => true,
@ -71,7 +71,7 @@ impl t : cmp::Eq {
}
}
}
pure fn ne(other: &t) -> bool { !self.eq(other) }
pure fn ne(&self, other: &t) -> bool { !(*self).eq(other) }
}
fn test_tag() {

View File

@ -2,8 +2,8 @@
enum t { a, b(~str), }
impl t : cmp::Eq {
pure fn eq(other: &t) -> bool {
match self {
pure fn eq(&self, other: &t) -> bool {
match *self {
a => {
match (*other) {
a => true,
@ -18,7 +18,7 @@ impl t : cmp::Eq {
}
}
}
pure fn ne(other: &t) -> bool { !self.eq(other) }
pure fn ne(&self, other: &t) -> bool { !(*self).eq(other) }
}
fn make(i: int) -> t {