]> git.lizzy.rs Git - rust.git/commitdiff
rustc: De-mode all overloaded operators
authorPatrick Walton <pcwalton@mimiga.net>
Thu, 20 Sep 2012 01:00:26 +0000 (18:00 -0700)
committerPatrick Walton <pcwalton@mimiga.net>
Thu, 20 Sep 2012 16:48:05 +0000 (09:48 -0700)
100 files changed:
src/cargo/cargo.rs
src/compiletest/common.rs
src/fuzzer/fuzzer.rs
src/libcore/at_vec.rs
src/libcore/bool.rs
src/libcore/box.rs
src/libcore/char.rs
src/libcore/cmp.rs
src/libcore/either.rs
src/libcore/extfmt.rs
src/libcore/float.rs
src/libcore/int-template.rs
src/libcore/io.rs
src/libcore/ops.rs
src/libcore/option.rs
src/libcore/path.rs
src/libcore/pipes.rs
src/libcore/ptr.rs
src/libcore/repr.rs
src/libcore/result.rs
src/libcore/str.rs
src/libcore/task.rs
src/libcore/task/local_data_priv.rs
src/libcore/tuple.rs
src/libcore/uint-template.rs
src/libcore/uniq.rs
src/libcore/unit.rs
src/libcore/util.rs
src/libcore/vec.rs
src/libstd/deque.rs
src/libstd/getopts.rs
src/libstd/json.rs
src/libstd/list.rs
src/libstd/net_url.rs
src/libstd/test.rs
src/libstd/time.rs
src/libsyntax/ast.rs
src/libsyntax/ast_map.rs
src/libsyntax/attr.rs
src/libsyntax/codemap.rs
src/libsyntax/diagnostic.rs
src/libsyntax/ext/pipes/proto.rs
src/libsyntax/parse/comments.rs
src/libsyntax/parse/obsolete.rs
src/libsyntax/parse/parser.rs
src/libsyntax/parse/token.rs
src/libsyntax/print/pp.rs
src/rustc/back/link.rs
src/rustc/driver/driver.rs
src/rustc/driver/rustc.rs
src/rustc/driver/session.rs
src/rustc/lib/llvm.rs
src/rustc/metadata/decoder.rs
src/rustc/middle/borrowck.rs
src/rustc/middle/borrowck/check_loans.rs
src/rustc/middle/check_alt.rs
src/rustc/middle/const_eval.rs
src/rustc/middle/lint.rs
src/rustc/middle/liveness.rs
src/rustc/middle/mem_categorization.rs
src/rustc/middle/region.rs
src/rustc/middle/resolve.rs
src/rustc/middle/trans/alt.rs
src/rustc/middle/trans/callee.rs
src/rustc/middle/trans/common.rs
src/rustc/middle/trans/datum.rs
src/rustc/middle/trans/expr.rs
src/rustc/middle/trans/foreign.rs
src/rustc/middle/trans/meth.rs
src/rustc/middle/trans/reflect.rs
src/rustc/middle/trans/shape.rs
src/rustc/middle/ty.rs
src/rustc/middle/typeck/check.rs
src/rustc/middle/typeck/infer/region_var_bindings.rs
src/rustdoc/config.rs
src/rustdoc/doc.rs
src/test/bench/shootout-mandelbrot.rs
src/test/compile-fail/borrowck-loan-in-overloaded-op.rs
src/test/compile-fail/borrowck-loan-rcvr-overloaded-op.rs
src/test/compile-fail/issue-2587-2.rs
src/test/compile-fail/issue-3344.rs
src/test/run-pass/auto_serialize.rs
src/test/run-pass/binops.rs
src/test/run-pass/class-impl-very-parameterized-trait.rs
src/test/run-pass/coherence-impl-in-fn.rs
src/test/run-pass/const-struct.rs
src/test/run-pass/empty-tag.rs
src/test/run-pass/estr-internal.rs [deleted file]
src/test/run-pass/evec-internal.rs
src/test/run-pass/export-unexported-dep.rs
src/test/run-pass/expr-alt-struct.rs
src/test/run-pass/expr-if-struct.rs
src/test/run-pass/issue-2718.rs
src/test/run-pass/operator-overloading.rs
src/test/run-pass/structured-compare.rs
src/test/run-pass/tag-variant-disr-val.rs
src/test/run-pass/tag.rs
src/test/run-pass/task-comm-16.rs
src/test/run-pass/traits.rs
src/test/run-pass/while-prelude-drop.rs

index 11ba5257f8d41579871b2aa59a64e4ab13a3360e..e648e6120ce74a54b08048d2b96293e937146576 100644 (file)
@@ -26,6 +26,7 @@
     versions: ~[(~str, ~str)]
 };
 
+#[cfg(stage0)]
 impl package : cmp::Ord {
     pure fn lt(&&other: package) -> bool {
         if self.name.lt(other.name) { return true; }
@@ -47,6 +48,29 @@ impl package : cmp::Ord {
     pure fn ge(&&other: package) -> bool { !self.lt(other) }
     pure fn gt(&&other: package) -> bool { other.lt(self)  }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl package : cmp::Ord {
+    pure fn lt(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;
+    }
+    pure fn le(other: &package) -> bool { !(*other).lt(&self) }
+    pure fn ge(other: &package) -> bool { !self.lt(other)     }
+    pure fn gt(other: &package) -> bool { (*other).lt(&self)  }
+}
 
 type local_package = {
     name: ~str,
@@ -97,12 +121,21 @@ impl package : cmp::Ord {
 
 enum mode { system_mode, user_mode, local_mode }
 
+#[cfg(stage0)]
 impl mode : cmp::Eq {
     pure fn eq(&&other: mode) -> bool {
         (self as uint) == (other as uint)
     }
     pure fn ne(&&other: mode) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl mode : cmp::Eq {
+    pure fn eq(other: &mode) -> bool {
+        (self as uint) == ((*other) as uint)
+    }
+    pure fn ne(other: &mode) -> bool { !self.eq(other) }
+}
 
 fn opts() -> ~[getopts::Opt] {
     ~[optflag(~"g"), optflag(~"G"), optflag(~"test"),
index a9f50492f2be3607173f6c75974f7279ce8784db..01b657c9c2d791ba022283ff0c7de5915e8fe588 100644 (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(other: &mode) -> bool {
+        (*other) as int == self as int
+    }
+    pure fn ne(other: &mode) -> bool { !self.eq(other) }
+}
 
 type config = {
     // The library paths required for running the compiler
index 700acb5434d367588176bb2fcc5b3564db02d25b..cb7e16df6dc446898666d4f7d38c61d911e3d39a 100644 (file)
@@ -8,12 +8,21 @@
 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)
     }
     pure fn ne(&&other: test_mode) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl test_mode : cmp::Eq {
+    pure fn eq(other: &test_mode) -> bool {
+        (self as uint) == ((*other) as uint)
+    }
+    pure fn ne(other: &test_mode) -> bool { !self.eq(other) }
+}
 
 fn write_file(filename: &Path, content: ~str) {
     result::get(
index 2303f0c80ff66cf7c19fe9752244b4f932886e4b..19003568354b1a31f8465981bde75a10038af5f4 100644 (file)
@@ -8,6 +8,7 @@
 export map;
 export from_fn, from_elem;
 export raw;
+export traits;
 
 /// Code for dealing with @-vectors. This is pretty incomplete, and
 /// contains a bunch of duplication from the code for ~-vectors.
@@ -133,13 +134,26 @@ fn vec_reserve_shared_actual(++t: *sys::TypeDesc,
 }
 
 #[cfg(notest)]
-impl<T: Copy> @[T]: Add<&[const T],@[T]> {
-    #[inline(always)]
-    pure fn add(rhs: &[const T]) -> @[T] {
-        append(self, rhs)
+mod traits {
+    #[cfg(stage0)]
+    impl<T: Copy> @[T]: Add<&[const T],@[T]> {
+        #[inline(always)]
+        pure fn add(rhs: &[const T]) -> @[T] {
+            append(self, rhs)
+        }
+    }
+    #[cfg(stage1)]
+    #[cfg(stage2)]
+    impl<T: Copy> @[T] : Add<&[const T],@[T]> {
+        #[inline(always)]
+        pure fn add(rhs: & &[const T]) -> @[T] {
+            append(self, (*rhs))
+        }
     }
 }
 
+#[cfg(test)]
+mod traits {}
 
 mod raw {
     type VecRepr = vec::raw::VecRepr;
index 7deb5b30eef8da9203f7cc8f87029b3b2e34a9c4..a80519e82ee5a5237d933153566dce882c14d9e5 100644 (file)
@@ -69,10 +69,17 @@ fn all_values(blk: fn(v: bool)) {
 /// converts truth value to an 8 bit byte
 pure fn to_bit(v: bool) -> u8 { if v { 1u8 } else { 0u8 } }
 
+#[cfg(stage0)]
 impl bool : cmp::Eq {
     pure fn eq(&&other: bool) -> bool { self == other }
     pure fn ne(&&other: bool) -> bool { self != other }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl bool : cmp::Eq {
+    pure fn eq(other: &bool) -> bool { self == (*other) }
+    pure fn ne(other: &bool) -> bool { self != (*other) }
+}
 
 #[test]
 fn test_bool_from_str() {
index bb64080834e348068f2884515ffe5ce36d00c644..294b307f0d6d52a1cdf0457ee255ee7d13488e10 100644 (file)
@@ -30,17 +30,33 @@ struct BoxRepr {
     unsafe { ptr::addr_of(*a) == ptr::addr_of(*b) }
 }
 
+#[cfg(stage0)]
 impl<T:Eq> @const T : Eq {
     pure fn eq(&&other: @const T) -> bool { *self == *other }
     pure fn ne(&&other: @const T) -> bool { *self != *other }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl<T:Eq> @const T : Eq {
+    pure fn eq(other: &@const T) -> bool { *self == *(*other) }
+    pure fn ne(other: &@const T) -> bool { *self != *(*other) }
+}
 
+#[cfg(stage0)]
 impl<T:Ord> @const T : Ord {
     pure fn lt(&&other: @const T) -> bool { *self < *other }
     pure fn le(&&other: @const T) -> bool { *self <= *other }
     pure fn ge(&&other: @const T) -> bool { *self >= *other }
     pure fn gt(&&other: @const T) -> bool { *self > *other }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl<T:Ord> @const T : Ord {
+    pure fn lt(other: &@const T) -> bool { *self < *(*other) }
+    pure fn le(other: &@const T) -> bool { *self <= *(*other) }
+    pure fn ge(other: &@const T) -> bool { *self >= *(*other) }
+    pure fn gt(other: &@const T) -> bool { *self > *(*other) }
+}
 
 #[test]
 fn test() {
index 69392d8648f7adeafb61280cccb8d6ab0bec1165..6732e157cb82ae797375eff6f730cd63aab5a0cc 100644 (file)
@@ -189,10 +189,17 @@ fn escape_default(c: char) -> ~str {
     else { 0 }
 }
 
+#[cfg(stage0)]
 impl char: Eq {
     pure fn eq(&&other: char) -> bool { self == other }
     pure fn ne(&&other: char) -> bool { self != other }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl char : Eq {
+    pure fn eq(other: &char) -> bool { self == (*other) }
+    pure fn ne(other: &char) -> bool { self != (*other) }
+}
 
 #[test]
 fn test_is_lowercase() {
index 420d272a2c33a0b35a934f2a5405fae89e7ca887..35c3dcc71abbaafc57d9cf25226d0e3c239851d0 100644 (file)
 #[forbid(deprecated_mode)];
 #[forbid(deprecated_pattern)];
 
+use nounittest::*;
+use unittest::*;
+export Ord;
+export Eq;
+
 /// Interfaces used for comparison.
 
 // Awful hack to work around duplicate lang items in core test.
-
-/**
- * Trait for values that can be compared for a sort-order.
- *
- * Eventually this may be simplified to only require
- * an `le` method, with the others generated from
- * default implementations.
- */
 #[cfg(notest)]
-#[lang="ord"]
-trait Ord {
-    pure fn lt(&&other: self) -> bool;
-    pure fn le(&&other: self) -> bool;
-    pure fn ge(&&other: self) -> bool;
-    pure fn gt(&&other: self) -> bool;
+mod nounittest {
+    /**
+     * Trait for values that can be compared for a sort-order.
+     *
+     * Eventually this may be simplified to only require
+     * an `le` method, with the others generated from
+     * default implementations.
+     */
+    #[cfg(stage0)]
+    #[lang="ord"]
+    trait Ord {
+        pure fn lt(&&other: self) -> bool;
+        pure fn le(&&other: self) -> bool;
+        pure fn ge(&&other: self) -> bool;
+        pure fn gt(&&other: self) -> bool;
+    }
+
+    #[cfg(stage1)]
+    #[cfg(stage2)]
+    #[lang="ord"]
+    trait Ord {
+        pure fn lt(other: &self) -> bool;
+        pure fn le(other: &self) -> bool;
+        pure fn ge(other: &self) -> bool;
+        pure fn gt(other: &self) -> bool;
+    }
+
+    #[cfg(stage0)]
+    #[lang="eq"]
+    /**
+     * Trait for values that can be compared for equality
+     * and inequality.
+     *
+     * Eventually this may be simplified to only require
+     * an `eq` method, with the other generated from
+     * a default implementation.
+     */
+    trait Eq {
+        pure fn eq(&&other: self) -> bool;
+        pure fn ne(&&other: self) -> bool;
+    }
+
+    #[cfg(stage1)]
+    #[cfg(stage2)]
+    #[lang="eq"]
+    trait Eq {
+        pure fn eq(other: &self) -> bool;
+        pure fn ne(other: &self) -> bool;
+    }
 }
 
 #[cfg(test)]
-trait Ord {
-    pure fn lt(&&other: self) -> bool;
-    pure fn le(&&other: self) -> bool;
-    pure fn ge(&&other: self) -> bool;
-    pure fn gt(&&other: self) -> bool;
-}
-
-/**
- * Trait for values that can be compared for equality
- * and inequality.
- *
- * Eventually this may be simplified to only require
- * an `eq` method, with the other generated from
- * a default implementation.
- */
-#[cfg(notest)]
-#[lang="eq"]
-trait Eq {
-    pure fn eq(&&other: self) -> bool;
-    pure fn ne(&&other: self) -> bool;
-}
+mod nounittest {}
 
 #[cfg(test)]
-trait Eq {
-    pure fn eq(&&other: self) -> bool;
-    pure fn ne(&&other: self) -> bool;
+mod unittest {
+    #[cfg(stage0)]
+    trait Ord {
+        pure fn lt(&&other: self) -> bool;
+        pure fn le(&&other: self) -> bool;
+        pure fn ge(&&other: self) -> bool;
+        pure fn gt(&&other: self) -> bool;
+    }
+
+    #[cfg(stage1)]
+    #[cfg(stage2)]
+    trait Ord {
+        pure fn lt(other: &self) -> bool;
+        pure fn le(other: &self) -> bool;
+        pure fn ge(other: &self) -> bool;
+        pure fn gt(other: &self) -> bool;
+    }
+
+    #[cfg(stage0)]
+    trait Eq {
+        pure fn eq(&&other: self) -> bool;
+        pure fn ne(&&other: self) -> bool;
+    }
+
+    #[cfg(stage1)]
+    #[cfg(stage2)]
+    trait Eq {
+        pure fn eq(other: &self) -> bool;
+        pure fn ne(other: &self) -> bool;
+    }
 }
 
+#[cfg(notest)]
+mod unittest {}
+
+#[cfg(stage0)]
 pure fn lt<T: Ord>(v1: &T, v2: &T) -> bool {
     v1.lt(v2)
 }
 
+#[cfg(stage0)]
 pure fn le<T: Ord Eq>(v1: &T, v2: &T) -> bool {
     v1.lt(v2) || v1.eq(v2)
 }
 
+#[cfg(stage0)]
 pure fn eq<T: Eq>(v1: &T, v2: &T) -> bool {
     v1.eq(v2)
 }
 
+#[cfg(stage0)]
 pure fn ne<T: Eq>(v1: &T, v2: &T) -> bool {
     v1.ne(v2)
 }
 
+#[cfg(stage0)]
 pure fn ge<T: Ord>(v1: &T, v2: &T) -> bool {
     v1.ge(v2)
 }
 
+#[cfg(stage0)]
 pure fn gt<T: Ord>(v1: &T, v2: &T) -> bool {
     v1.gt(v2)
 }
 
+#[cfg(stage1)]
+#[cfg(stage2)]
+pure fn lt<T: Ord>(v1: &T, v2: &T) -> bool {
+    (*v1).lt(v2)
+}
+
+#[cfg(stage1)]
+#[cfg(stage2)]
+pure fn le<T: Ord Eq>(v1: &T, v2: &T) -> bool {
+    (*v1).lt(v2) || (*v1).eq(v2)
+}
+
+#[cfg(stage1)]
+#[cfg(stage2)]
+pure fn eq<T: Eq>(v1: &T, v2: &T) -> bool {
+    (*v1).eq(v2)
+}
+
+#[cfg(stage1)]
+#[cfg(stage2)]
+pure fn ne<T: Eq>(v1: &T, v2: &T) -> bool {
+    (*v1).ne(v2)
+}
+
+#[cfg(stage1)]
+#[cfg(stage2)]
+pure fn ge<T: Ord>(v1: &T, v2: &T) -> bool {
+    (*v1).ge(v2)
+}
+
+#[cfg(stage1)]
+#[cfg(stage2)]
+pure fn gt<T: Ord>(v1: &T, v2: &T) -> bool {
+    (*v1).gt(v2)
+}
+
index 9f58f46f1a021e1d0a20690707aaaffeb5229657..d566cd7e6dcf410b21be3c5fefda17a0bccdd336 100644 (file)
@@ -126,6 +126,7 @@ fn partition<T: Copy, U: Copy>(eithers: &[Either<T, U>])
     }
 }
 
+#[cfg(stage0)]
 impl<T:Eq,U:Eq> Either<T,U> : Eq {
     pure fn eq(&&other: Either<T,U>) -> bool {
         match self {
@@ -145,6 +146,27 @@ impl<T:Eq,U:Eq> Either<T,U> : Eq {
     }
     pure fn ne(&&other: Either<T,U>) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl<T:Eq,U:Eq> Either<T,U> : Eq {
+    pure fn eq(other: &Either<T,U>) -> bool {
+        match self {
+            Left(a) => {
+                match (*other) {
+                    Left(ref b) => a.eq(b),
+                    Right(_) => false
+                }
+            }
+            Right(a) => {
+                match (*other) {
+                    Left(_) => false,
+                    Right(ref b) => a.eq(b)
+                }
+            }
+        }
+    }
+    pure fn ne(other: &Either<T,U>) -> bool { !self.eq(other) }
+}
 
 #[test]
 fn test_either_left() {
index 74d651472e12d6d4267082fe1bae853040d58927..f9059c59d7d40fc25462a8b737d56147601c36ba 100644 (file)
@@ -386,6 +386,7 @@ enum Ty { TyDefault, TyBits, TyHexUpper, TyHexLower, TyOctal, }
 
     enum PadMode { PadSigned, PadUnsigned, PadNozero, PadFloat }
 
+#[cfg(stage0)]
     impl PadMode: Eq {
         pure fn eq(&&other: PadMode) -> bool {
             match (self, other) {
@@ -401,6 +402,23 @@ impl PadMode: Eq {
         }
         pure fn ne(&&other: PadMode) -> bool { !self.eq(other) }
     }
+    #[cfg(stage1)]
+    #[cfg(stage2)]
+    impl PadMode : Eq {
+        pure fn eq(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
+            }
+        }
+        pure fn ne(other: &PadMode) -> bool { !self.eq(other) }
+    }
 
     fn pad(cv: Conv, &s: ~str, mode: PadMode) -> ~str {
         let uwidth : uint = match cv.width {
@@ -574,6 +592,7 @@ enum Ty { TyDefault, TyBits, TyHexUpper, TyHexLower, TyOctal, }
 
     enum PadMode { PadSigned, PadUnsigned, PadNozero, PadFloat }
 
+#[cfg(stage0)]
     impl PadMode: Eq {
         pure fn eq(&&other: PadMode) -> bool {
             match (self, other) {
@@ -589,6 +608,23 @@ impl PadMode: Eq {
         }
         pure fn ne(&&other: PadMode) -> bool { !self.eq(other) }
     }
+    #[cfg(stage1)]
+    #[cfg(stage2)]
+    impl PadMode : Eq {
+        pure fn eq(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
+            }
+        }
+        pure fn ne(other: &PadMode) -> bool { !self.eq(other) }
+    }
 
     fn pad(cv: Conv, &s: ~str, mode: PadMode) -> ~str {
         let uwidth : uint = match cv.width {
index b570f1a14957d0bfa895972a2b4d68b26d44d654..4877e12204a05663b353131d111d0d30bca76a5e 100644 (file)
@@ -414,17 +414,33 @@ fn pow_with_uint(base: uint, pow: uint) -> float {
 pure fn cos(x: float) -> float { f64::cos(x as f64) as float }
 pure fn tan(x: float) -> float { f64::tan(x as f64) as float }
 
+#[cfg(stage0)]
 impl float: Eq {
     pure fn eq(&&other: float) -> bool { self == other }
     pure fn ne(&&other: float) -> bool { self != other }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl float : Eq {
+    pure fn eq(other: &float) -> bool { self == (*other) }
+    pure fn ne(other: &float) -> bool { self != (*other) }
+}
 
+#[cfg(stage0)]
 impl float: Ord {
     pure fn lt(&&other: float) -> bool { self < other }
     pure fn le(&&other: float) -> bool { self <= other }
     pure fn ge(&&other: float) -> bool { self >= other }
     pure fn gt(&&other: float) -> bool { self > other }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl float : Ord {
+    pure fn lt(other: &float) -> bool { self < (*other) }
+    pure fn le(other: &float) -> bool { self <= (*other) }
+    pure fn ge(other: &float) -> bool { self >= (*other) }
+    pure fn gt(other: &float) -> bool { self > (*other) }
+}
 
 impl float: num::Num {
     pure fn add(&&other: float)    -> float { return self + other; }
index 664f2940ec7869185b52d82fd832a12ab393f918..c9dd21252a3ac53b4b2eb73b1ab5b1176b3be89a 100644 (file)
@@ -68,17 +68,33 @@ fn range(lo: T, hi: T, it: fn(T) -> bool) {
     if is_negative(i) { -i } else { i }
 }
 
+#[cfg(stage0)]
 impl T: Ord {
     pure fn lt(&&other: T) -> bool { return self < other; }
     pure fn le(&&other: T) -> bool { return self <= other; }
     pure fn ge(&&other: T) -> bool { return self >= other; }
     pure fn gt(&&other: T) -> bool { return self > other; }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl T : Ord {
+    pure fn lt(other: &T) -> bool { return self < (*other); }
+    pure fn le(other: &T) -> bool { return self <= (*other); }
+    pure fn ge(other: &T) -> bool { return self >= (*other); }
+    pure fn gt(other: &T) -> bool { return self > (*other); }
+}
 
+#[cfg(stage0)]
 impl T: Eq {
     pure fn eq(&&other: T) -> bool { return self == other; }
     pure fn ne(&&other: T) -> bool { return self != other; }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl T : Eq {
+    pure fn eq(other: &T) -> bool { return self == (*other); }
+    pure fn ne(other: &T) -> bool { return self != (*other); }
+}
 
 impl T: num::Num {
     pure fn add(&&other: T)    -> T { return self + other; }
index 96ef5c5f0014459b9953330d3dfe5ce7ac0c233b..e5a20909b7f78962d2b108feb0b6a9eaba78c0b5 100644 (file)
@@ -329,6 +329,7 @@ enum FileFlag { Append, Create, Truncate, NoFlag, }
 // What type of writer are we?
 enum WriterType { Screen, File }
 
+#[cfg(stage0)]
 impl WriterType: Eq {
     pure fn eq(&&other: WriterType) -> bool {
         match (self, other) {
@@ -338,6 +339,17 @@ impl WriterType: Eq {
     }
     pure fn ne(&&other: WriterType) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl WriterType : Eq {
+    pure fn eq(other: &WriterType) -> bool {
+        match (self, (*other)) {
+            (Screen, Screen) | (File, File) => true,
+            (Screen, _) | (File, _) => false
+        }
+    }
+    pure fn ne(other: &WriterType) -> bool { !self.eq(other) }
+}
 
 // FIXME (#2004): Seekable really should be orthogonal.
 // FIXME (#2004): eventually u64
index 4e8b36a43fb5a18210d901cbefe4e54d99d10853..bf67fe04ea021d6589bf05047c4a19447ba3b516 100644 (file)
 // Core operators and kinds.
 
-#[cfg(notest)]
 #[lang="const"]
 trait Const {
     // Empty.
 }
 
-#[cfg(notest)]
 #[lang="copy"]
 trait Copy {
     // Empty.
 }
 
-#[cfg(notest)]
 #[lang="send"]
 trait Send {
     // Empty.
 }
 
-#[cfg(notest)]
 #[lang="owned"]
 trait Owned {
     // Empty.
 }
 
-#[cfg(notest)]
+#[cfg(stage0)]
 #[lang="add"]
 trait Add<RHS,Result> {
     pure fn add(rhs: RHS) -> Result;
 }
 
-#[cfg(notest)]
+#[cfg(stage1)]
+#[cfg(stage2)]
+#[lang="add"]
+trait Add<RHS,Result> {
+    pure fn add(rhs: &RHS) -> Result;
+}
+
+#[cfg(stage0)]
 #[lang="sub"]
 trait Sub<RHS,Result> {
     pure fn sub(rhs: RHS) -> Result;
 }
 
-#[cfg(notest)]
+#[cfg(stage1)]
+#[cfg(stage2)]
+#[lang="sub"]
+trait Sub<RHS,Result> {
+    pure fn sub(rhs: &RHS) -> Result;
+}
+
+#[cfg(stage0)]
 #[lang="mul"]
 trait Mul<RHS,Result> {
     pure fn mul(rhs: RHS) -> Result;
 }
 
-#[cfg(notest)]
+#[cfg(stage1)]
+#[cfg(stage2)]
+#[lang="mul"]
+trait Mul<RHS,Result> {
+    pure fn mul(rhs: &RHS) -> Result;
+}
+
+#[cfg(stage0)]
 #[lang="div"]
 trait Div<RHS,Result> {
     pure fn div(rhs: RHS) -> Result;
 }
 
-#[cfg(notest)]
+#[cfg(stage1)]
+#[cfg(stage2)]
+#[lang="div"]
+trait Div<RHS,Result> {
+    pure fn div(rhs: &RHS) -> Result;
+}
+
+#[cfg(stage0)]
 #[lang="modulo"]
 trait Modulo<RHS,Result> {
     pure fn modulo(rhs: RHS) -> Result;
 }
 
-#[cfg(notest)]
+#[cfg(stage1)]
+#[cfg(stage2)]
+#[lang="modulo"]
+trait Modulo<RHS,Result> {
+    pure fn modulo(rhs: &RHS) -> Result;
+}
+
 #[lang="neg"]
 trait Neg<Result> {
     pure fn neg() -> Result;
 }
 
-#[cfg(notest)]
+#[cfg(stage0)]
 #[lang="bitand"]
 trait BitAnd<RHS,Result> {
     pure fn bitand(rhs: RHS) -> Result;
 }
 
-#[cfg(notest)]
+#[cfg(stage1)]
+#[cfg(stage2)]
+#[lang="bitand"]
+trait BitAnd<RHS,Result> {
+    pure fn bitand(rhs: &RHS) -> Result;
+}
+
+#[cfg(stage0)]
 #[lang="bitor"]
 trait BitOr<RHS,Result> {
     pure fn bitor(rhs: RHS) -> Result;
 }
 
-#[cfg(notest)]
+#[cfg(stage1)]
+#[cfg(stage2)]
+#[lang="bitor"]
+trait BitOr<RHS,Result> {
+    pure fn bitor(rhs: &RHS) -> Result;
+}
+
+#[cfg(stage0)]
 #[lang="bitxor"]
 trait BitXor<RHS,Result> {
     pure fn bitxor(rhs: RHS) -> Result;
 }
 
-#[cfg(notest)]
+#[cfg(stage1)]
+#[cfg(stage2)]
+#[lang="bitxor"]
+trait BitXor<RHS,Result> {
+    pure fn bitxor(rhs: &RHS) -> Result;
+}
+
+#[cfg(stage0)]
 #[lang="shl"]
 trait Shl<RHS,Result> {
     pure fn shl(rhs: RHS) -> Result;
 }
 
-#[cfg(notest)]
+#[cfg(stage1)]
+#[cfg(stage2)]
+#[lang="shl"]
+trait Shl<RHS,Result> {
+    pure fn shl(rhs: &RHS) -> Result;
+}
+
+#[cfg(stage0)]
 #[lang="shr"]
 trait Shr<RHS,Result> {
     pure fn shr(rhs: RHS) -> Result;
 }
 
-#[cfg(notest)]
+#[cfg(stage1)]
+#[cfg(stage2)]
+#[lang="shr"]
+trait Shr<RHS,Result> {
+    pure fn shr(rhs: &RHS) -> Result;
+}
+
 #[lang="index"]
 trait Index<Index,Result> {
     pure fn index(index: Index) -> Result;
index f8f1c9df4e47e05f225ff2a5ffa2d464be4d9508..0844332672a6eb9dc633b511d8a8628a5d3a67db 100644 (file)
@@ -251,6 +251,7 @@ impl<T: Copy> Option<T> {
     pure fn while_some(blk: fn(+T) -> Option<T>) { while_some(self, blk) }
 }
 
+#[cfg(stage0)]
 impl<T: Eq> Option<T> : Eq {
     pure fn eq(&&other: Option<T>) -> bool {
         match self {
@@ -270,6 +271,28 @@ impl<T: Eq> Option<T> : Eq {
     }
     pure fn ne(&&other: Option<T>) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl<T: Eq> Option<T> : Eq {
+    pure fn eq(other: &Option<T>) -> bool {
+        match self {
+            None => {
+                match (*other) {
+                    None => true,
+                    Some(_) => false
+                }
+            }
+            Some(self_contents) => {
+                match (*other) {
+                    None => false,
+                    Some(ref other_contents) =>
+                        self_contents.eq(other_contents)
+                }
+            }
+        }
+    }
+    pure fn ne(other: &Option<T>) -> bool { !self.eq(other) }
+}
 
 #[test]
 fn test_unwrap_ptr() {
index 88d2526f31024e7cc4f9be147e7ad76a1c696fda..331ff57116a262b6aba4415dcebb998dfa30e5f2 100644 (file)
@@ -70,6 +70,7 @@ fn to_str() -> ~str {
     }
 }
 
+#[cfg(stage0)]
 impl PosixPath : Eq {
     pure fn eq(&&other: PosixPath) -> bool {
         return self.is_absolute == other.is_absolute &&
@@ -77,7 +78,17 @@ impl PosixPath : Eq {
     }
     pure fn ne(&&other: PosixPath) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl PosixPath : Eq {
+    pure fn eq(other: &PosixPath) -> bool {
+        return self.is_absolute == (*other).is_absolute &&
+            self.components == (*other).components;
+    }
+    pure fn ne(other: &PosixPath) -> bool { !self.eq(other) }
+}
 
+#[cfg(stage0)]
 impl WindowsPath : Eq {
     pure fn eq(&&other: WindowsPath) -> bool {
         return self.host == other.host &&
@@ -87,6 +98,17 @@ impl WindowsPath : Eq {
     }
     pure fn ne(&&other: WindowsPath) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl WindowsPath : Eq {
+    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;
+    }
+    pure fn ne(other: &WindowsPath) -> bool { !self.eq(other) }
+}
 
 // FIXME (#3227): when default methods in traits are working, de-duplicate
 // PosixPath and WindowsPath, most of their methods are common.
index 3adb77873c2fbb2d3021df39395187cdd4560671..3d40358dcc13fd7f6ff4023a345a6806d5e5cb56 100644 (file)
@@ -116,12 +116,21 @@ enum State {
     Terminated
 }
 
+#[cfg(stage0)]
 impl State: Eq {
     pure fn eq(&&other: State) -> bool {
         (self as uint) == (other as uint)
     }
     pure fn ne(&&other: State) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl State : Eq {
+    pure fn eq(other: &State) -> bool {
+        (self as uint) == ((*other) as uint)
+    }
+    pure fn ne(other: &State) -> bool { !self.eq(other) }
+}
 
 struct BufferHeader {
     // Tracks whether this buffer needs to be freed. We can probably
index 31c52f0b407a4e61490b1597bd5ba5a4c1cb7bc8..65cf61ab2bdc6a4d3e7c79efad08c2ab478003b3 100644 (file)
@@ -203,6 +203,7 @@ impl<T> *T: Ptr {
 }
 
 // Equality for pointers
+#[cfg(stage0)]
 impl<T> *const T : Eq {
     pure fn eq(&&other: *const T) -> bool unsafe {
         let a: uint = cast::reinterpret_cast(&self);
@@ -211,8 +212,19 @@ impl<T> *const T : Eq {
     }
     pure fn ne(&&other: *const T) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl<T> *const T : Eq {
+    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;
+    }
+    pure fn ne(other: &*const T) -> bool { !self.eq(other) }
+}
 
 // Comparison for pointers
+#[cfg(stage0)]
 impl<T> *const T : Ord {
     pure fn lt(&&other: *const T) -> bool unsafe {
         let a: uint = cast::reinterpret_cast(&self);
@@ -235,20 +247,60 @@ impl<T> *const T : Ord {
         return a > b;
     }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl<T> *const T : Ord {
+    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;
+    }
+    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;
+    }
+    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;
+    }
+    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;
+    }
+}
 
 // Equality for region pointers
+#[cfg(stage0)]
 impl<T:Eq> &const T : Eq {
     pure fn eq(&&other: &const T) -> bool { return *self == *other; }
     pure fn ne(&&other: &const T) -> bool { return *self != *other; }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl<T:Eq> &const T : Eq {
+    pure fn eq(other: & &const T) -> bool { return *self == *(*other); }
+    pure fn ne(other: & &const T) -> bool { return *self != *(*other); }
+}
 
 // Comparison for region pointers
+#[cfg(stage0)]
 impl<T:Ord> &const T : Ord {
     pure fn lt(&&other: &const T) -> bool { *self < *other }
     pure fn le(&&other: &const T) -> bool { *self <= *other }
     pure fn ge(&&other: &const T) -> bool { *self >= *other }
     pure fn gt(&&other: &const T) -> bool { *self > *other }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl<T:Ord> &const T : Ord {
+    pure fn lt(other: & &const T) -> bool { *self < *(*other) }
+    pure fn le(other: & &const T) -> bool { *self <= *(*other) }
+    pure fn ge(other: & &const T) -> bool { *self >= *(*other) }
+    pure fn gt(other: & &const T) -> bool { *self > *(*other) }
+}
 
 #[test]
 fn test() {
index f779078ed86fbe4b99e541e52ee44ee54164d699..38825c4cb0f8b2ed97fb06b510db2b063bce5d2d 100644 (file)
@@ -510,12 +510,21 @@ enum EnumVisitState {
     Degenerate      // This is a degenerate enum (exactly 1 variant)
 }
 
+#[cfg(stage0)]
 impl EnumVisitState : cmp::Eq {
     pure fn eq(&&other: EnumVisitState) -> bool {
         (self as uint) == (other as uint)
     }
     pure fn ne(&&other: EnumVisitState) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl EnumVisitState : cmp::Eq {
+    pure fn eq(other: &EnumVisitState) -> bool {
+        (self as uint) == ((*other) as uint)
+    }
+    pure fn ne(other: &EnumVisitState) -> bool { !self.eq(other) }
+}
 
 struct EnumState {
     end_ptr: *c_void,
index ea1a91d7a84f8b1b1f6a18babc83b3f60adaad85..1b41c37273ebc14e671da06b9ab6a7069b00cc2b 100644 (file)
@@ -356,6 +356,7 @@ fn unwrap_err<T, U>(+res: Result<T, U>) -> U {
     }
 }
 
+#[cfg(stage0)]
 impl<T:Eq,U:Eq> Result<T,U> : Eq {
     pure fn eq(&&other: Result<T,U>) -> bool {
         match self {
@@ -375,6 +376,27 @@ impl<T:Eq,U:Eq> Result<T,U> : Eq {
     }
     pure fn ne(&&other: Result<T,U>) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl<T:Eq,U:Eq> Result<T,U> : Eq {
+    pure fn eq(other: &Result<T,U>) -> bool {
+        match self {
+            Ok(e0a) => {
+                match (*other) {
+                    Ok(e0b) => e0a == e0b,
+                    _ => false
+                }
+            }
+            Err(e0a) => {
+                match (*other) {
+                    Err(e0b) => e0a == e0b,
+                    _ => false
+                }
+            }
+        }
+    }
+    pure fn ne(other: &Result<T,U>) -> bool { !self.eq(other) }
+}
 
 #[cfg(test)]
 #[allow(non_implicitly_copyable_typarams)]
index 4c01656ba2ecfce30ef5af596fead8b63b5caeea..6890ef74a6cfaa1eb0cf7a44e6de1d7d5e18301a 100644 (file)
    raw,
    extensions,
    StrSlice,
-   UniqueStr;
+   UniqueStr,
+   traits;
 
 /*
 Section: Creating a string
@@ -793,6 +794,7 @@ fn view_shift_char(s: &a/str) -> (char, &a/str) {
     !le(a, b)
 }
 
+#[cfg(stage0)]
 impl &str: Eq {
     #[inline(always)]
     pure fn eq(&&other: &str) -> bool {
@@ -801,7 +803,18 @@ impl &str: Eq {
     #[inline(always)]
     pure fn ne(&&other: &str) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl &str : Eq {
+    #[inline(always)]
+    pure fn eq(other: & &str) -> bool {
+        eq_slice(self, (*other))
+    }
+    #[inline(always)]
+    pure fn ne(other: & &str) -> bool { !self.eq(other) }
+}
 
+#[cfg(stage0)]
 impl ~str: Eq {
     #[inline(always)]
     pure fn eq(&&other: ~str) -> bool {
@@ -810,7 +823,18 @@ impl ~str: Eq {
     #[inline(always)]
     pure fn ne(&&other: ~str) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl ~str : Eq {
+    #[inline(always)]
+    pure fn eq(other: &~str) -> bool {
+        eq_slice(self, (*other))
+    }
+    #[inline(always)]
+    pure fn ne(other: &~str) -> bool { !self.eq(other) }
+}
 
+#[cfg(stage0)]
 impl @str: Eq {
     #[inline(always)]
     pure fn eq(&&other: @str) -> bool {
@@ -819,7 +843,18 @@ impl @str: Eq {
     #[inline(always)]
     pure fn ne(&&other: @str) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl @str : Eq {
+    #[inline(always)]
+    pure fn eq(other: &@str) -> bool {
+        eq_slice(self, (*other))
+    }
+    #[inline(always)]
+    pure fn ne(other: &@str) -> bool { !self.eq(other) }
+}
 
+#[cfg(stage0)]
 impl ~str : Ord {
     #[inline(always)]
     pure fn lt(&&other: ~str) -> bool { lt(self, other) }
@@ -830,7 +865,20 @@ impl ~str : Ord {
     #[inline(always)]
     pure fn gt(&&other: ~str) -> bool { gt(self, other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl ~str : Ord {
+    #[inline(always)]
+    pure fn lt(other: &~str) -> bool { lt(self, (*other)) }
+    #[inline(always)]
+    pure fn le(other: &~str) -> bool { le(self, (*other)) }
+    #[inline(always)]
+    pure fn ge(other: &~str) -> bool { ge(self, (*other)) }
+    #[inline(always)]
+    pure fn gt(other: &~str) -> bool { gt(self, (*other)) }
+}
 
+#[cfg(stage0)]
 impl &str : Ord {
     #[inline(always)]
     pure fn lt(&&other: &str) -> bool { lt(self, other) }
@@ -841,7 +889,20 @@ impl &str : Ord {
     #[inline(always)]
     pure fn gt(&&other: &str) -> bool { gt(self, other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl &str : Ord {
+    #[inline(always)]
+    pure fn lt(other: & &str) -> bool { lt(self, (*other)) }
+    #[inline(always)]
+    pure fn le(other: & &str) -> bool { le(self, (*other)) }
+    #[inline(always)]
+    pure fn ge(other: & &str) -> bool { ge(self, (*other)) }
+    #[inline(always)]
+    pure fn gt(other: & &str) -> bool { gt(self, (*other)) }
+}
 
+#[cfg(stage0)]
 impl @str : Ord {
     #[inline(always)]
     pure fn lt(&&other: @str) -> bool { lt(self, other) }
@@ -852,6 +913,18 @@ impl @str : Ord {
     #[inline(always)]
     pure fn gt(&&other: @str) -> bool { gt(self, other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl @str : Ord {
+    #[inline(always)]
+    pure fn lt(other: &@str) -> bool { lt(self, (*other)) }
+    #[inline(always)]
+    pure fn le(other: &@str) -> bool { le(self, (*other)) }
+    #[inline(always)]
+    pure fn ge(other: &@str) -> bool { ge(self, (*other)) }
+    #[inline(always)]
+    pure fn gt(other: &@str) -> bool { gt(self, (*other)) }
+}
 
 /*
 Section: Iterating through strings
@@ -2159,13 +2232,27 @@ fn trim_right() -> ~str { trim_right(self) }
 }
 
 #[cfg(notest)]
-impl ~str: Add<&str,~str> {
-    #[inline(always)]
-    pure fn add(rhs: &str) -> ~str {
-        append(copy self, rhs)
+mod traits {
+    #[cfg(stage0)]
+    impl ~str: Add<&str,~str> {
+        #[inline(always)]
+        pure fn add(rhs: &str) -> ~str {
+            append(copy self, rhs)
+        }
+    }
+    #[cfg(stage1)]
+    #[cfg(stage2)]
+    impl ~str : Add<&str,~str> {
+        #[inline(always)]
+        pure fn add(rhs: & &str) -> ~str {
+            append(copy self, (*rhs))
+        }
     }
 }
 
+#[cfg(test)]
+mod traits {}
+
 trait StrSlice {
     fn all(it: fn(char) -> bool) -> bool;
     fn any(it: fn(char) -> bool) -> bool;
index 2da779577e501226f47d60fd793e3017c27f8214..52775456d10b22a2e92904a666ff9c62de2729d3 100644 (file)
@@ -83,10 +83,17 @@ enum Task {
     TaskHandle(task_id)
 }
 
+#[cfg(stage0)]
 impl Task : cmp::Eq {
     pure fn eq(&&other: Task) -> bool { *self == *other }
     pure fn ne(&&other: Task) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl Task : cmp::Eq {
+    pure fn eq(other: &Task) -> bool { *self == *(*other) }
+    pure fn ne(other: &Task) -> bool { !self.eq(other) }
+}
 
 /**
  * Indicates the manner in which a task exited.
@@ -104,6 +111,7 @@ enum TaskResult {
     Failure,
 }
 
+#[cfg(stage0)]
 impl TaskResult: Eq {
     pure fn eq(&&other: TaskResult) -> bool {
         match (self, other) {
@@ -113,6 +121,17 @@ impl TaskResult: Eq {
     }
     pure fn ne(&&other: TaskResult) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl TaskResult : Eq {
+    pure fn eq(other: &TaskResult) -> bool {
+        match (self, (*other)) {
+            (Success, Success) | (Failure, Failure) => true,
+            (Success, _) | (Failure, _) => false
+        }
+    }
+    pure fn ne(other: &TaskResult) -> bool { !self.eq(other) }
+}
 
 /// A message type for notifying of task lifecycle events
 enum Notification {
@@ -120,6 +139,7 @@ enum Notification {
     Exit(Task, TaskResult)
 }
 
+#[cfg(stage0)]
 impl Notification : cmp::Eq {
     pure fn eq(&&other: Notification) -> bool {
         match self {
@@ -132,6 +152,20 @@ impl Notification : cmp::Eq {
     }
     pure fn ne(&&other: Notification) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl Notification : cmp::Eq {
+    pure fn eq(other: &Notification) -> bool {
+        match self {
+            Exit(e0a, e1a) => {
+                match (*other) {
+                    Exit(e0b, e1b) => e0a == e0b && e1a == e1b
+                }
+            }
+        }
+    }
+    pure fn ne(other: &Notification) -> bool { !self.eq(other) }
+}
 
 /// Scheduler modes
 enum SchedMode {
@@ -152,6 +186,7 @@ enum SchedMode {
     PlatformThread
 }
 
+#[cfg(stage0)]
 impl SchedMode : cmp::Eq {
     pure fn eq(&&other: SchedMode) -> bool {
         match self {
@@ -191,6 +226,47 @@ impl SchedMode : cmp::Eq {
         !self.eq(other)
     }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl SchedMode : cmp::Eq {
+    pure fn eq(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
+                }
+            }
+        }
+    }
+    pure fn ne(other: &SchedMode) -> bool {
+        !self.eq(other)
+    }
+}
 
 /**
  * Scheduler configuration options
index ee02e2ca6e7f8dc906be644ba00057922d437817..b4a9301ca0b0488fde9fe98d161c6f9e1edc1fab 100644 (file)
@@ -6,6 +6,7 @@
 trait LocalData { }
 impl<T: Owned> @T: LocalData { }
 
+#[cfg(stage0)]
 impl LocalData: Eq {
     pure fn eq(&&other: LocalData) -> bool unsafe {
         let ptr_a: (uint, uint) = cast::reinterpret_cast(&self);
@@ -14,6 +15,16 @@ impl LocalData: Eq {
     }
     pure fn ne(&&other: LocalData) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl LocalData: Eq {
+    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;
+    }
+    pure fn ne(other: &@LocalData) -> bool { !self.eq(other) }
+}
 
 // We use dvec because it's the best data structure in core. If TLS is used
 // heavily in future, this could be made more efficient with a proper map.
index 2672c5057799f296a209e5cf9f868117073c3f24..0159a0fd615b13761cb3c5fa54ea955d8e0469d8 100644 (file)
@@ -67,6 +67,7 @@ fn map<C>(f: fn(A, B) -> C) -> ~[C] {
     }
 }
 
+#[cfg(stage0)]
 impl<A: Eq, B: Eq> (A, B): Eq {
     pure fn eq(&&other: (A, B)) -> bool {
         // XXX: This would be a lot less wordy with ref bindings, but I don't
@@ -83,7 +84,26 @@ impl<A: Eq, B: Eq> (A, B): Eq {
     }
     pure fn ne(&&other: (A, B)) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl<A: Eq, B: Eq> (A, B) : Eq {
+    pure fn eq(other: &(A, B)) -> bool {
+        // XXX: This would be a lot less wordy with ref bindings, but I don't
+        // trust that they work yet.
+        match self {
+            (self_a, self_b) => {
+                match (*other) {
+                    (ref other_a, ref other_b) => {
+                        self_a.eq(other_a) && self_b.eq(other_b)
+                    }
+                }
+            }
+        }
+    }
+    pure fn ne(other: &(A, B)) -> bool { !self.eq(other) }
+}
 
+#[cfg(stage0)]
 impl<A: Ord, B: Ord> (A, B): Ord {
     pure fn lt(&&other: (A, B)) -> bool {
         match self {
@@ -103,7 +123,29 @@ impl<A: Ord, B: Ord> (A, B): Ord {
     pure fn ge(&&other: (A, B)) -> bool { !self.lt(other) }
     pure fn gt(&&other: (A, B)) -> bool { other.lt(self)  }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl<A: Ord, B: Ord> (A, B) : Ord {
+    pure fn lt(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;
+                    }
+                }
+            }
+        }
+    }
+    pure fn le(other: &(A, B)) -> bool { !(*other).lt(&self) }
+    pure fn ge(other: &(A, B)) -> bool { !self.lt(other) }
+    pure fn gt(other: &(A, B)) -> bool { (*other).lt(&self)  }
+}
 
+#[cfg(stage0)]
 impl<A: Eq, B: Eq, C: Eq> (A, B, C): Eq {
     pure fn eq(&&other: (A, B, C)) -> bool {
         // XXX: This would be a lot less wordy with ref bindings, but I don't
@@ -122,7 +164,28 @@ impl<A: Eq, B: Eq, C: Eq> (A, B, C): Eq {
     }
     pure fn ne(&&other: (A, B, C)) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl<A: Eq, B: Eq, C: Eq> (A, B, C) : Eq {
+    pure fn eq(other: &(A, B, C)) -> bool {
+        // XXX: This would be a lot less wordy with ref bindings, but I don't
+        // trust that they work yet.
+        match self {
+            (self_a, self_b, 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)
+                    }
+                }
+            }
+        }
+    }
+    pure fn ne(other: &(A, B, C)) -> bool { !self.eq(other) }
+}
 
+#[cfg(stage0)]
 impl<A: Ord, B: Ord, C: Ord> (A, B, C): Ord {
     pure fn lt(&&other: (A, B, C)) -> bool {
         match self {
@@ -144,6 +207,29 @@ impl<A: Ord, B: Ord, C: Ord> (A, B, C): Ord {
     pure fn ge(&&other: (A, B, C)) -> bool { !self.lt(other) }
     pure fn gt(&&other: (A, B, C)) -> bool { other.lt(self)  }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl<A: Ord, B: Ord, C: Ord> (A, B, C) : Ord {
+    pure fn lt(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;
+                    }
+                }
+            }
+        }
+    }
+    pure fn le(other: &(A, B, C)) -> bool { !(*other).lt(&self) }
+    pure fn ge(other: &(A, B, C)) -> bool { !self.lt(other) }
+    pure fn gt(other: &(A, B, C)) -> bool { (*other).lt(&self)  }
+}
 
 #[test]
 #[allow(non_implicitly_copyable_typarams)]
index 02faf9255efaeba904b5a194448335defe2e4e20..a0fd5f58a19fdc3e81d18eb45a7b7a44bfeff3d5 100644 (file)
     max_value ^ i
 }
 
+#[cfg(stage0)]
 impl T: Ord {
     pure fn lt(&&other: T) -> bool { self < other }
     pure fn le(&&other: T) -> bool { self <= other }
     pure fn ge(&&other: T) -> bool { self >= other }
     pure fn gt(&&other: T) -> bool { self > other }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl T : Ord {
+    pure fn lt(other: &T) -> bool { self < (*other) }
+    pure fn le(other: &T) -> bool { self <= (*other) }
+    pure fn ge(other: &T) -> bool { self >= (*other) }
+    pure fn gt(other: &T) -> bool { self > (*other) }
+}
 
+#[cfg(stage0)]
 impl T: Eq {
     pure fn eq(&&other: T) -> bool { return self == other; }
     pure fn ne(&&other: T) -> bool { return self != other; }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl T : Eq {
+    pure fn eq(other: &T) -> bool { return self == (*other); }
+    pure fn ne(other: &T) -> bool { return self != (*other); }
+}
 
 impl T: num::Num {
     pure fn add(&&other: T)    -> T { return self + other; }
index 7a9aa71d1991e8cb8de7661f16a960333e45ffd4..f1842686ae15e3a177c9264e872d3fc53cde3da3 100644 (file)
@@ -2,15 +2,31 @@
 
 use cmp::{Eq, Ord};
 
+#[cfg(stage0)]
 impl<T:Eq> ~const T : Eq {
     pure fn eq(&&other: ~const T) -> bool { *self == *other }
     pure fn ne(&&other: ~const T) -> bool { *self != *other }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl<T:Eq> ~const T : Eq {
+    pure fn eq(other: &~const T) -> bool { *self == *(*other) }
+    pure fn ne(other: &~const T) -> bool { *self != *(*other) }
+}
 
+#[cfg(stage0)]
 impl<T:Ord> ~const T : Ord {
     pure fn lt(&&other: ~const T) -> bool { *self < *other }
     pure fn le(&&other: ~const T) -> bool { *self <= *other }
     pure fn ge(&&other: ~const T) -> bool { *self >= *other }
     pure fn gt(&&other: ~const T) -> bool { *self > *other }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl<T:Ord> ~const T : Ord {
+    pure fn lt(other: &~const T) -> bool { *self < *(*other) }
+    pure fn le(other: &~const T) -> bool { *self <= *(*other) }
+    pure fn ge(other: &~const T) -> bool { *self >= *(*other) }
+    pure fn gt(other: &~const T) -> bool { *self > *(*other) }
+}
 
index 23b9a4f3be57ff7125fad29824e30c091e051250..30f1f5ab99c22e5db16d4fa4e76198dcc800d1fc 100644 (file)
@@ -6,15 +6,31 @@
 
 use cmp::{Eq, Ord};
 
+#[cfg(stage0)]
 impl () : Eq {
     pure fn eq(&&_other: ()) -> bool { true }
     pure fn ne(&&_other: ()) -> bool { false }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl () : Eq {
+    pure fn eq(_other: &()) -> bool { true }
+    pure fn ne(_other: &()) -> bool { false }
+}
 
+#[cfg(stage0)]
 impl () : Ord {
     pure fn lt(&&_other: ()) -> bool { false }
     pure fn le(&&_other: ()) -> bool { true }
     pure fn ge(&&_other: ()) -> bool { true }
     pure fn gt(&&_other: ()) -> bool { false }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl () : Ord {
+    pure fn lt(_other: &()) -> bool { false }
+    pure fn le(_other: &()) -> bool { true }
+    pure fn ge(_other: &()) -> bool { true }
+    pure fn gt(_other: &()) -> bool { false }
+}
 
index e27a3cdb18d387e217ee69ebf9f532a2ef0baf42..679ed13d1db75cc589a9e8d9c7628817b5c79800 100644 (file)
@@ -71,7 +71,7 @@ fn identity_crisis() {
         let x = ~[(5, false)];
         //FIXME #3387 assert x.eq(id(copy x));
         let y = copy x;
-        assert x.eq(id(y));
+        assert x.eq(&id(y));
     }
     #[test]
     fn test_swap() {
index 2fac80aa2e7c991bf824bf907c57a8457e5048ae..c9f69e6b21f9dccf6df03badfd32f91b4a844978 100644 (file)
@@ -93,6 +93,7 @@
 export ImmutableCopyableVector;
 export IterTraitExtensions;
 export vec_concat;
+export traits;
 
 #[abi = "cdecl"]
 extern mod rustrt {
@@ -1391,26 +1392,53 @@ fn iter2<U, T>(v1: &[U], v2: &[T], f: fn(U, T)) {
     return true;
 }
 
+#[cfg(stage0)]
 impl<T: Eq> &[T]: Eq {
     #[inline(always)]
     pure fn eq(&&other: &[T]) -> bool { eq(self, other) }
     #[inline(always)]
     pure fn ne(&&other: &[T]) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl<T: Eq> &[T] : Eq {
+    #[inline(always)]
+    pure fn eq(other: & &[T]) -> bool { eq(self, (*other)) }
+    #[inline(always)]
+    pure fn ne(other: & &[T]) -> bool { !self.eq(other) }
+}
 
+#[cfg(stage0)]
 impl<T: Eq> ~[T]: Eq {
     #[inline(always)]
     pure fn eq(&&other: ~[T]) -> bool { eq(self, other) }
     #[inline(always)]
     pure fn ne(&&other: ~[T]) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl<T: Eq> ~[T] : Eq {
+    #[inline(always)]
+    pure fn eq(other: &~[T]) -> bool { eq(self, (*other)) }
+    #[inline(always)]
+    pure fn ne(other: &~[T]) -> bool { !self.eq(other) }
+}
 
+#[cfg(stage0)]
 impl<T: Eq> @[T]: Eq {
     #[inline(always)]
     pure fn eq(&&other: @[T]) -> bool { eq(self, other) }
     #[inline(always)]
     pure fn ne(&&other: @[T]) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl<T: Eq> @[T] : Eq {
+    #[inline(always)]
+    pure fn eq(other: &@[T]) -> bool { eq(self, (*other)) }
+    #[inline(always)]
+    pure fn ne(other: &@[T]) -> bool { !self.eq(other) }
+}
 
 // Lexicographical comparison
 
@@ -1433,6 +1461,7 @@ impl<T: Eq> @[T]: Eq {
 pure fn ge<T: Ord>(a: &[T], b: &[T]) -> bool { !lt(a, b) }
 pure fn gt<T: Ord>(a: &[T], b: &[T]) -> bool { lt(b, a)  }
 
+#[cfg(stage0)]
 impl<T: Ord> &[T]: Ord {
     #[inline(always)]
     pure fn lt(&&other: &[T]) -> bool { lt(self, other) }
@@ -1443,7 +1472,20 @@ impl<T: Ord> &[T]: Ord {
     #[inline(always)]
     pure fn gt(&&other: &[T]) -> bool { gt(self, other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl<T: Ord> &[T] : Ord {
+    #[inline(always)]
+    pure fn lt(other: & &[T]) -> bool { lt(self, (*other)) }
+    #[inline(always)]
+    pure fn le(other: & &[T]) -> bool { le(self, (*other)) }
+    #[inline(always)]
+    pure fn ge(other: & &[T]) -> bool { ge(self, (*other)) }
+    #[inline(always)]
+    pure fn gt(other: & &[T]) -> bool { gt(self, (*other)) }
+}
 
+#[cfg(stage0)]
 impl<T: Ord> ~[T]: Ord {
     #[inline(always)]
     pure fn lt(&&other: ~[T]) -> bool { lt(self, other) }
@@ -1454,7 +1496,20 @@ impl<T: Ord> ~[T]: Ord {
     #[inline(always)]
     pure fn gt(&&other: ~[T]) -> bool { gt(self, other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl<T: Ord> ~[T] : Ord {
+    #[inline(always)]
+    pure fn lt(other: &~[T]) -> bool { lt(self, (*other)) }
+    #[inline(always)]
+    pure fn le(other: &~[T]) -> bool { le(self, (*other)) }
+    #[inline(always)]
+    pure fn ge(other: &~[T]) -> bool { ge(self, (*other)) }
+    #[inline(always)]
+    pure fn gt(other: &~[T]) -> bool { gt(self, (*other)) }
+}
 
+#[cfg(stage0)]
 impl<T: Ord> @[T]: Ord {
     #[inline(always)]
     pure fn lt(&&other: @[T]) -> bool { lt(self, other) }
@@ -1465,22 +1520,58 @@ impl<T: Ord> @[T]: Ord {
     #[inline(always)]
     pure fn gt(&&other: @[T]) -> bool { gt(self, other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl<T: Ord> @[T] : Ord {
+    #[inline(always)]
+    pure fn lt(other: &@[T]) -> bool { lt(self, (*other)) }
+    #[inline(always)]
+    pure fn le(other: &@[T]) -> bool { le(self, (*other)) }
+    #[inline(always)]
+    pure fn ge(other: &@[T]) -> bool { ge(self, (*other)) }
+    #[inline(always)]
+    pure fn gt(other: &@[T]) -> bool { gt(self, (*other)) }
+}
 
 #[cfg(notest)]
-impl<T: Copy> ~[T]: Add<&[const T],~[T]> {
-    #[inline(always)]
-    pure fn add(rhs: &[const T]) -> ~[T] {
-        append(copy self, rhs)
+mod traits {
+    #[cfg(stage0)]
+    impl<T: Copy> ~[T]: Add<&[const T],~[T]> {
+        #[inline(always)]
+        pure fn add(rhs: &[const T]) -> ~[T] {
+            append(copy self, rhs)
+        }
     }
-}
 
-impl<T: Copy> ~[mut T]: Add<&[const T],~[mut T]> {
-    #[inline(always)]
-    pure fn add(rhs: &[const T]) -> ~[mut T] {
-        append_mut(self, rhs)
+    #[cfg(stage1)]
+    #[cfg(stage2)]
+    impl<T: Copy> ~[T] : Add<&[const T],~[T]> {
+        #[inline(always)]
+        pure fn add(rhs: & &[const T]) -> ~[T] {
+            append(copy self, (*rhs))
+        }
+    }
+
+    #[cfg(stage0)]
+    impl<T: Copy> ~[mut T]: Add<&[const T],~[mut T]> {
+        #[inline(always)]
+        pure fn add(rhs: &[const T]) -> ~[mut T] {
+            append_mut(self, rhs)
+        }
+    }
+    #[cfg(stage1)]
+    #[cfg(stage2)]
+    impl<T: Copy> ~[mut T] : Add<&[const T],~[mut T]> {
+        #[inline(always)]
+        pure fn add(rhs: & &[const T]) -> ~[mut T] {
+            append_mut(self, (*rhs))
+        }
     }
 }
 
+#[cfg(test)]
+mod traits {}
+
 trait ConstVector {
     pure fn is_empty() -> bool;
     pure fn is_not_empty() -> bool;
index 4c4dcdeabe9e0673110ae5b6854927667c05dd8e..35b147e1940117fc9d97807f1879ea3edc8d4d55 100644 (file)
@@ -239,6 +239,7 @@ enum Taggypar<T> {
 
     type RecCy = {x: int, y: int, t: Taggy};
 
+#[cfg(stage0)]
     impl Taggy : Eq {
         pure fn eq(other: Taggy) -> bool {
             match self {
@@ -258,7 +259,29 @@ impl Taggy : Eq {
         }
         pure fn ne(other: Taggy) -> bool { !self.eq(other) }
     }
+    #[cfg(stage1)]
+    #[cfg(stage2)]
+    impl Taggy : Eq {
+        pure fn eq(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
+              }
+            }
+        }
+        pure fn ne(other: &Taggy) -> bool { !self.eq(other) }
+    }
 
+#[cfg(stage0)]
     impl Taggypar<int> : Eq {
         //let eq4: EqFn<Taggypar<int>> = |x,y| taggypareq::<int>(x, y);
         pure fn eq(other: Taggypar<int>) -> bool {
@@ -281,13 +304,47 @@ impl Taggypar<int> : Eq {
         }
         pure fn ne(other: Taggypar<int>) -> bool { !self.eq(other) }
     }
+    #[cfg(stage1)]
+    #[cfg(stage2)]
+    impl Taggypar<int> : Eq {
+        //let eq4: EqFn<Taggypar<int>> = |x,y| taggypareq::<int>(x, y);
+        pure fn eq(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
+                    }
+                  }
+        }
+        pure fn ne(other: &Taggypar<int>) -> bool { !self.eq(other) }
+    }
 
+#[cfg(stage0)]
     impl RecCy : Eq {
         pure fn eq(other: RecCy) -> bool {
           return self.x == other.x && self.y == other.y && self.t == other.t;
         }
         pure fn ne(other: RecCy) -> bool { !self.eq(other) }
     }
+    #[cfg(stage1)]
+    #[cfg(stage2)]
+    impl RecCy : Eq {
+        pure fn eq(other: &RecCy) -> bool {
+          return self.x == (*other).x && self.y == (*other).y &&
+                 self.t == (*other).t;
+        }
+        pure fn ne(other: &RecCy) -> bool { !self.eq(other) }
+    }
 
     #[test]
     fn test_param_int() {
index 67d3619b0e21cf97ca4db2a46e3732441fffdbd6..4a071dea8798854078a95f0b1c4d38c9eb55a5a1 100644 (file)
@@ -107,6 +107,7 @@ fn mkname(nm: &str) -> Name {
         } else { Long(unm) };
 }
 
+#[cfg(stage0)]
 impl Name : Eq {
     pure fn eq(&&other: Name) -> bool {
         match self {
@@ -126,13 +127,43 @@ impl Name : Eq {
     }
     pure fn ne(&&other: Name) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl Name : Eq {
+    pure fn eq(other: &Name) -> bool {
+        match self {
+            Long(e0a) => {
+                match (*other) {
+                    Long(e0b) => e0a == e0b,
+                    _ => false
+                }
+            }
+            Short(e0a) => {
+                match (*other) {
+                    Short(e0b) => e0a == e0b,
+                    _ => false
+                }
+            }
+        }
+    }
+    pure fn ne(other: &Name) -> bool { !self.eq(other) }
+}
 
+#[cfg(stage0)]
 impl Occur : Eq {
     pure fn eq(&&other: Occur) -> bool {
         (self as uint) == (other as uint)
     }
     pure fn ne(&&other: Occur) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl Occur : Eq {
+    pure fn eq(other: &Occur) -> bool {
+        (self as uint) == ((*other) as uint)
+    }
+    pure fn ne(other: &Occur) -> bool { !self.eq(other) }
+}
 
 /// Create an option that is required and takes an argument
 fn reqopt(name: &str) -> Opt {
@@ -447,12 +478,21 @@ enum FailType {
     UnexpectedArgument_,
 }
 
+#[cfg(stage0)]
 impl FailType : Eq {
     pure fn eq(&&other: FailType) -> bool {
         (self as uint) == (other as uint)
     }
     pure fn ne(&&other: FailType) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl FailType : Eq {
+    pure fn eq(other: &FailType) -> bool {
+        (self as uint) == ((*other) as uint)
+    }
+    pure fn ne(other: &FailType) -> bool { !self.eq(other) }
+}
 
 #[cfg(test)]
 mod tests {
index b66d69d442f75293ff1141362e4074fd327e5902..79fee39a702598f9de2ba2834a2d21a556bc3e7b 100644 (file)
@@ -676,6 +676,7 @@ fn from_str(s: &str) -> Result<Json, Error> {
     }
 }
 
+#[cfg(stage0)]
 impl Error : Eq {
     pure fn eq(&&other: Error) -> bool {
         self.line == other.line &&
@@ -684,18 +685,44 @@ impl Error : Eq {
     }
     pure fn ne(&&other: Error) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl Error : Eq {
+    pure fn eq(other: &Error) -> bool {
+        self.line == (*other).line &&
+        self.col == (*other).col &&
+        self.msg == (*other).msg
+    }
+    pure fn ne(other: &Error) -> bool { !self.eq(other) }
+}
 
+#[cfg(stage0)]
 impl Json : Eq {
     pure fn eq(&&other: Json) -> bool { eq(self, other) }
     pure fn ne(&&other: Json) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl Json : Eq {
+    pure fn eq(other: &Json) -> bool { eq(self, (*other)) }
+    pure fn ne(other: &Json) -> bool { !self.eq(other) }
+}
 
+#[cfg(stage0)]
 impl Json : Ord {
     pure fn lt(&&other: Json) -> bool { lt(self, other) }
     pure fn le(&&other: Json) -> bool { !other.lt(self) }
     pure fn ge(&&other: Json) -> bool { !self.lt(other) }
     pure fn gt(&&other: Json) -> bool { other.lt(self)  }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl Json : Ord {
+    pure fn lt(other: &Json) -> bool { lt(self, (*other))  }
+    pure fn le(other: &Json) -> bool { !(*other).lt(&self) }
+    pure fn ge(other: &Json) -> bool { !self.lt(other)     }
+    pure fn gt(other: &Json) -> bool { (*other).lt(&self)  }
+}
 
 trait ToJson { fn to_json() -> Json; }
 
index 96d4e32d02befa368f6869683840938c966a7e27..a9c5e1b0e771e6f31fcfdaab8f82078d44921f4a 100644 (file)
@@ -148,6 +148,7 @@ fn each<T>(l: @List<T>, f: fn(T) -> bool) {
     }
 }
 
+#[cfg(stage0)]
 impl<T:Eq> List<T> : Eq {
     pure fn eq(&&other: List<T>) -> bool {
         match self {
@@ -167,6 +168,27 @@ impl<T:Eq> List<T> : Eq {
     }
     pure fn ne(&&other: List<T>) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl<T:Eq> List<T> : Eq {
+    pure fn eq(other: &List<T>) -> bool {
+        match self {
+            Cons(e0a, e1a) => {
+                match (*other) {
+                    Cons(e0b, e1b) => e0a == e0b && e1a == e1b,
+                    _ => false
+                }
+            }
+            Nil => {
+                match (*other) {
+                    Nil => true,
+                    _ => false
+                }
+            }
+        }
+    }
+    pure fn ne(other: &List<T>) -> bool { !self.eq(other) }
+}
 
 #[cfg(test)]
 mod tests {
index 493e0cc762c8ab66c085a968a9cb6085ad8632af..b56d8471fbf695d1bdfa5b93d9bc9424bf7297db 100644 (file)
@@ -317,12 +317,21 @@ fn userinfo_to_str(+userinfo: UserInfo) -> ~str {
     }
 }
 
+#[cfg(stage0)]
 impl UserInfo : Eq {
     pure fn eq(&&other: UserInfo) -> bool {
         self.user == other.user && self.pass == other.pass
     }
     pure fn ne(&&other: UserInfo) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl UserInfo : Eq {
+    pure fn eq(other: &UserInfo) -> bool {
+        self.user == (*other).user && self.pass == (*other).pass
+    }
+    pure fn ne(other: &UserInfo) -> bool { !self.eq(other) }
+}
 
 fn query_from_str(rawquery: &str) -> Query {
     let mut query: Query = ~[];
@@ -377,6 +386,7 @@ enum Input {
     Unreserved // all other legal characters
 }
 
+#[cfg(stage0)]
 impl Input: Eq {
     pure fn eq(&&other: Input) -> bool {
         match (self, other) {
@@ -390,6 +400,21 @@ impl Input: Eq {
     }
     pure fn ne(&&other: Input) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl Input : Eq {
+    pure fn eq(other: &Input) -> bool {
+        match (self, (*other)) {
+            (Digit, Digit) => true,
+            (Hex, Hex) => true,
+            (Unreserved, Unreserved) => true,
+            (Digit, _) => false,
+            (Hex, _) => false,
+            (Unreserved, _) => false
+        }
+    }
+    pure fn ne(other: &Input) -> bool { !self.eq(other) }
+}
 
 // returns userinfo, host, port, and unparsed part, or an error
 fn get_authority(rawurl: &str) ->
@@ -719,6 +744,7 @@ fn to_str() -> ~str {
     }
 }
 
+#[cfg(stage0)]
 impl Url: Eq {
     pure fn eq(&&other: Url) -> bool {
         self.scheme == other.scheme
@@ -734,6 +760,23 @@ impl Url: Eq {
         !self.eq(other)
     }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl Url : Eq {
+    pure fn eq(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
+    }
+
+    pure fn ne(other: &Url) -> bool {
+        !self.eq(other)
+    }
+}
 
 impl Url: IterBytes {
     pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) {
index 268799dbaea8e51a987e33da4a05e34d1111f9da..29d97a8918dee01876aa631676547f12e3aa36a0 100644 (file)
@@ -95,12 +95,21 @@ fn parse_opts(args: &[~str]) -> OptRes {
 
 enum TestResult { TrOk, TrFailed, TrIgnored, }
 
+#[cfg(stage0)]
 impl TestResult : Eq {
     pure fn eq(&&other: TestResult) -> bool {
         (self as uint) == (other as uint)
     }
     pure fn ne(&&other: TestResult) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl TestResult : Eq {
+    pure fn eq(other: &TestResult) -> bool {
+        (self as uint) == ((*other) as uint)
+    }
+    pure fn ne(other: &TestResult) -> bool { !self.eq(other) }
+}
 
 type ConsoleTestState =
     @{out: io::Writer,
index 45ea25c385827dfeac7a3d189fd0e5eda67421c2..f984f1b733f1466631b7bb99bae88d5ada30c021 100644 (file)
 /// A record specifying a time value in seconds and nanoseconds.
 type Timespec = {sec: i64, nsec: i32};
 
+#[cfg(stage0)]
 impl Timespec : Eq {
     pure fn eq(&&other: Timespec) -> bool {
         self.sec == other.sec && self.nsec == other.nsec
     }
     pure fn ne(&&other: Timespec) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl Timespec : Eq {
+    pure fn eq(other: &Timespec) -> bool {
+        self.sec == (*other).sec && self.nsec == (*other).nsec
+    }
+    pure fn ne(other: &Timespec) -> bool { !self.eq(other) }
+}
 
 /**
  * Returns the current time as a `timespec` containing the seconds and
@@ -91,6 +100,7 @@ fn tzset() {
     tm_nsec: i32, // nanoseconds
 };
 
+#[cfg(stage0)]
 impl Tm_ : Eq {
     pure fn eq(&&other: Tm_) -> bool {
         self.tm_sec == other.tm_sec &&
@@ -108,15 +118,41 @@ impl Tm_ : Eq {
     }
     pure fn ne(&&other: Tm_) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl Tm_ : Eq {
+    pure fn eq(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
+    }
+    pure fn ne(other: &Tm_) -> bool { !self.eq(other) }
+}
 
 enum Tm {
     Tm_(Tm_)
 }
 
+#[cfg(stage0)]
 impl Tm : Eq {
     pure fn eq(&&other: Tm) -> bool { *self == *other }
     pure fn ne(&&other: Tm) -> bool { *self != *other }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl Tm : Eq {
+    pure fn eq(other: &Tm) -> bool { *self == *(*other) }
+    pure fn ne(other: &Tm) -> bool { *self != *(*other) }
+}
 
 fn empty_tm() -> Tm {
     Tm_({
index f7aa0f7555ee2367c305f8a1470f9495a9fbaf25..3f41c03b927d1cb025d269f69fa07f95f1b54ab2 100644 (file)
@@ -81,12 +81,21 @@ fn deserialize_ident<D: Deserializer>(d: D) -> ident  {
 #[auto_serialize]
 type def_id = {crate: crate_num, node: node_id};
 
+#[cfg(stage0)]
 impl def_id: cmp::Eq {
     pure fn eq(&&other: def_id) -> bool {
         self.crate == other.crate && self.node == other.node
     }
     pure fn ne(&&other: def_id) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl def_id : cmp::Eq {
+    pure fn eq(other: &def_id) -> bool {
+        self.crate == (*other).crate && self.node == (*other).node
+    }
+    pure fn ne(other: &def_id) -> bool { !self.eq(other) }
+}
 
 const local_crate: crate_num = 0;
 const crate_node_id: node_id = 0;
@@ -129,6 +138,7 @@ enum def {
     def_label(node_id)
 }
 
+#[cfg(stage0)]
 impl def : cmp::Eq {
     pure fn eq(&&other: def) -> bool {
         match self {
@@ -251,6 +261,130 @@ impl def : cmp::Eq {
     }
     pure fn ne(&&other: def) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl def : cmp::Eq {
+    pure fn eq(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) => {
+                match (*other) {
+                    def_static_method(e0b, e1b) => e0a == e0b && e1a == e1b,
+                    _ => 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, e1a) => {
+                match (*other) {
+                    def_class(e0b, e1b) => e0a == e0b && e1a == e1b,
+                    _ => 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
+                }
+            }
+        }
+    }
+    pure fn ne(other: &def) -> bool { !self.eq(other) }
+}
 
 // The set of meta_items that define the compilation environment of the crate,
 // used to drive conditional compilation
@@ -330,6 +464,7 @@ impl binding_mode : to_bytes::IterBytes {
     }
 }
 
+#[cfg(stage0)]
 impl binding_mode : cmp::Eq {
     pure fn eq(&&other: binding_mode) -> bool {
         match self {
@@ -361,6 +496,39 @@ impl binding_mode : cmp::Eq {
     }
     pure fn ne(&&other: binding_mode) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl binding_mode : cmp::Eq {
+    pure fn eq(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
+                }
+            }
+        }
+    }
+    pure fn ne(other: &binding_mode) -> bool { !self.eq(other) }
+}
 
 #[auto_serialize]
 enum pat_ {
@@ -394,12 +562,21 @@ impl mutability : to_bytes::IterBytes {
     }
 }
 
+#[cfg(stage0)]
 impl mutability: cmp::Eq {
     pure fn eq(&&other: mutability) -> bool {
         (self as uint) == (other as uint)
     }
     pure fn ne(&&other: mutability) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl mutability : cmp::Eq {
+    pure fn eq(other: &mutability) -> bool {
+        (self as uint) == ((*other) as uint)
+    }
+    pure fn ne(other: &mutability) -> bool { !self.eq(other) }
+}
 
 #[auto_serialize]
 enum proto {
@@ -409,12 +586,21 @@ enum proto {
     proto_block,   // fn&
 }
 
+#[cfg(stage0)]
 impl proto : cmp::Eq {
     pure fn eq(&&other: proto) -> bool {
         (self as uint) == (other as uint)
     }
     pure fn ne(&&other: proto) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl proto : cmp::Eq {
+    pure fn eq(other: &proto) -> bool {
+        (self as uint) == ((*other) as uint)
+    }
+    pure fn ne(other: &proto) -> bool { !self.eq(other) }
+}
 
 #[auto_serialize]
 enum vstore {
@@ -463,12 +649,21 @@ enum binop {
     gt,
 }
 
+#[cfg(stage0)]
 impl binop : cmp::Eq {
     pure fn eq(&&other: binop) -> bool {
         (self as uint) == (other as uint)
     }
     pure fn ne(&&other: binop) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl binop : cmp::Eq {
+    pure fn eq(other: &binop) -> bool {
+        (self as uint) == ((*other) as uint)
+    }
+    pure fn ne(other: &binop) -> bool { !self.eq(other) }
+}
 
 #[auto_serialize]
 enum unop {
@@ -479,6 +674,7 @@ enum unop {
     neg
 }
 
+#[cfg(stage0)]
 impl unop : cmp::Eq {
     pure fn eq(&&other: unop) -> bool {
         match self {
@@ -518,6 +714,47 @@ impl unop : cmp::Eq {
         !self.eq(other)
     }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl unop : cmp::Eq {
+    pure fn eq(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
+                }
+            }
+        }
+    }
+    pure fn ne(other: &unop) -> bool {
+        !self.eq(other)
+    }
+}
 
 // Generally, after typeck you can get the inferred value
 // using ty::resolved_T(...).
@@ -539,6 +776,7 @@ impl<T: to_bytes::IterBytes> inferable<T> : to_bytes::IterBytes {
     }
 }
 
+#[cfg(stage0)]
 impl<T:cmp::Eq> inferable<T> : cmp::Eq {
     pure fn eq(&&other: inferable<T>) -> bool {
         match self {
@@ -558,6 +796,27 @@ impl<T:cmp::Eq> inferable<T> : cmp::Eq {
     }
     pure fn ne(&&other: inferable<T>) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl<T:cmp::Eq> inferable<T> : cmp::Eq {
+    pure fn eq(other: &inferable<T>) -> bool {
+        match self {
+            expl(e0a) => {
+                match (*other) {
+                    expl(e0b) => e0a == e0b,
+                    _ => false
+                }
+            }
+            infer(e0a) => {
+                match (*other) {
+                    infer(e0b) => e0a == e0b,
+                    _ => false
+                }
+            }
+        }
+    }
+    pure fn ne(other: &inferable<T>) -> bool { !self.eq(other) }
+}
 
 // "resolved" mode: the real modes.
 #[auto_serialize]
@@ -570,12 +829,21 @@ impl rmode : to_bytes::IterBytes {
 }
 
 
+#[cfg(stage0)]
 impl rmode : cmp::Eq {
     pure fn eq(&&other: rmode) -> bool {
         (self as uint) == (other as uint)
     }
     pure fn ne(&&other: rmode) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl rmode : cmp::Eq {
+    pure fn eq(other: &rmode) -> bool {
+        (self as uint) == ((*other) as uint)
+    }
+    pure fn ne(other: &rmode) -> bool { !self.eq(other) }
+}
 
 // inferable mode.
 #[auto_serialize]
@@ -598,6 +866,7 @@ enum stmt_ {
 #[auto_serialize]
 enum init_op { init_assign, init_move, }
 
+#[cfg(stage0)]
 impl init_op : cmp::Eq {
     pure fn eq(&&other: init_op) -> bool {
         match self {
@@ -617,6 +886,27 @@ impl init_op : cmp::Eq {
     }
     pure fn ne(&&other: init_op) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl init_op : cmp::Eq {
+    pure fn eq(other: &init_op) -> bool {
+        match self {
+            init_assign => {
+                match (*other) {
+                    init_assign => true,
+                    _ => false
+                }
+            }
+            init_move => {
+                match (*other) {
+                    init_move => true,
+                    _ => false
+                }
+            }
+        }
+    }
+    pure fn ne(other: &init_op) -> bool { !self.eq(other) }
+}
 
 #[auto_serialize]
 type initializer = {op: init_op, expr: @expr};
@@ -648,6 +938,7 @@ enum decl_ { decl_local(~[@local]), decl_item(@item), }
 #[auto_serialize]
 enum blk_check_mode { default_blk, unsafe_blk, }
 
+#[cfg(stage0)]
 impl blk_check_mode : cmp::Eq {
     pure fn eq(&&other: blk_check_mode) -> bool {
         match (self, other) {
@@ -659,6 +950,19 @@ impl blk_check_mode : cmp::Eq {
     }
     pure fn ne(&&other: blk_check_mode) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl blk_check_mode : cmp::Eq {
+    pure fn eq(other: &blk_check_mode) -> bool {
+        match (self, (*other)) {
+            (default_blk, default_blk) => true,
+            (unsafe_blk, unsafe_blk) => true,
+            (default_blk, _) => false,
+            (unsafe_blk, _) => false,
+        }
+    }
+    pure fn ne(other: &blk_check_mode) -> bool { !self.eq(other) }
+}
 
 #[auto_serialize]
 type expr = {id: node_id, callee_id: node_id, node: expr_, span: span};
@@ -867,6 +1171,7 @@ enum lit_ {
     lit_bool(bool),
 }
 
+#[cfg(stage0)]
 impl ast::lit_: cmp::Eq {
     pure fn eq(&&other: ast::lit_) -> bool {
         match (self, other) {
@@ -894,6 +1199,35 @@ impl ast::lit_: cmp::Eq {
     }
     pure fn ne(&&other: ast::lit_) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl ast::lit_: cmp::Eq {
+    pure fn eq(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_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_nil, _) => false,
+            (lit_bool(_), _) => false
+        }
+    }
+    pure fn ne(other: &ast::lit_) -> bool { !self.eq(other) }
+}
 
 // NB: If you change this, you'll probably want to change the corresponding
 // type structure in middle/ty.rs as well.
@@ -929,6 +1263,7 @@ impl int_ty : to_bytes::IterBytes {
     }
 }
 
+#[cfg(stage0)]
 impl int_ty: cmp::Eq {
     pure fn eq(&&other: int_ty) -> bool {
         match (self, other) {
@@ -948,6 +1283,27 @@ impl int_ty: cmp::Eq {
     }
     pure fn ne(&&other: int_ty) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl int_ty : cmp::Eq {
+    pure fn eq(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,
+        }
+    }
+    pure fn ne(other: &int_ty) -> bool { !self.eq(other) }
+}
 
 #[auto_serialize]
 enum uint_ty { ty_u, ty_u8, ty_u16, ty_u32, ty_u64, }
@@ -958,6 +1314,7 @@ impl uint_ty : to_bytes::IterBytes {
     }
 }
 
+#[cfg(stage0)]
 impl uint_ty: cmp::Eq {
     pure fn eq(&&other: uint_ty) -> bool {
         match (self, other) {
@@ -975,6 +1332,25 @@ impl uint_ty: cmp::Eq {
     }
     pure fn ne(&&other: uint_ty) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl uint_ty : cmp::Eq {
+    pure fn eq(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
+        }
+    }
+    pure fn ne(other: &uint_ty) -> bool { !self.eq(other) }
+}
 
 #[auto_serialize]
 enum float_ty { ty_f, ty_f32, ty_f64, }
@@ -984,6 +1360,7 @@ impl float_ty : to_bytes::IterBytes {
         (self as u8).iter_bytes(lsb0, f)
     }
 }
+#[cfg(stage0)]
 impl float_ty: cmp::Eq {
     pure fn eq(&&other: float_ty) -> bool {
         match (self, other) {
@@ -993,6 +1370,17 @@ impl float_ty: cmp::Eq {
     }
     pure fn ne(&&other: float_ty) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl float_ty : cmp::Eq {
+    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
+        }
+    }
+    pure fn ne(other: &float_ty) -> bool { !self.eq(other) }
+}
 
 #[auto_serialize]
 type ty = {id: node_id, node: ty_, span: span};
@@ -1007,6 +1395,7 @@ enum prim_ty {
     ty_bool,
 }
 
+#[cfg(stage0)]
 impl prim_ty : cmp::Eq {
     pure fn eq(&&other: prim_ty) -> bool {
         match self {
@@ -1044,6 +1433,45 @@ impl prim_ty : cmp::Eq {
     }
     pure fn ne(&&other: prim_ty) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl prim_ty : cmp::Eq {
+    pure fn eq(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
+                }
+            }
+        }
+    }
+    pure fn ne(other: &prim_ty) -> bool { !self.eq(other) }
+}
 
 #[auto_serialize]
 type region = {id: node_id, node: region_};
@@ -1079,6 +1507,7 @@ 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.
+#[cfg(stage0)]
 impl ty : cmp::Eq {
     pure fn eq(&&other: ty) -> bool {
         ptr::addr_of(self) == ptr::addr_of(other)
@@ -1087,6 +1516,16 @@ impl ty : cmp::Eq {
         ptr::addr_of(self) != ptr::addr_of(other)
     }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl ty : cmp::Eq {
+    pure fn eq(other: &ty) -> bool {
+        ptr::addr_of(self) == ptr::addr_of((*other))
+    }
+    pure fn ne(other: &ty) -> bool {
+        ptr::addr_of(self) != ptr::addr_of((*other))
+    }
+}
 
 impl ty : to_bytes::IterBytes {
     pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) {
@@ -1118,12 +1557,21 @@ impl purity : to_bytes::IterBytes {
     }
 }
 
+#[cfg(stage0)]
 impl purity : cmp::Eq {
     pure fn eq(&&other: purity) -> bool {
         (self as uint) == (other as uint)
     }
     pure fn ne(&&other: purity) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl purity : cmp::Eq {
+    pure fn eq(other: &purity) -> bool {
+        (self as uint) == ((*other) as uint)
+    }
+    pure fn ne(other: &purity) -> bool { !self.eq(other) }
+}
 
 #[auto_serialize]
 enum ret_style {
@@ -1138,6 +1586,7 @@ impl ret_style : to_bytes::IterBytes {
     }
 }
 
+#[cfg(stage0)]
 impl ret_style : cmp::Eq {
     pure fn eq(&&other: ret_style) -> bool {
         match (self, other) {
@@ -1149,6 +1598,19 @@ impl ret_style : cmp::Eq {
     }
     pure fn ne(&&other: ret_style) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl ret_style : cmp::Eq {
+    pure fn eq(other: &ret_style) -> bool {
+        match (self, (*other)) {
+            (noreturn, noreturn) => true,
+            (return_val, return_val) => true,
+            (noreturn, _) => false,
+            (return_val, _) => false,
+        }
+    }
+    pure fn ne(other: &ret_style) -> bool { !self.eq(other) }
+}
 
 #[auto_serialize]
 enum self_ty_ {
@@ -1160,6 +1622,7 @@ enum self_ty_ {
     sty_uniq(mutability)                // by-unique-pointer self: `~self`
 }
 
+#[cfg(stage0)]
 impl self_ty_ : cmp::Eq {
     pure fn eq(&&other: self_ty_) -> bool {
         match self {
@@ -1203,6 +1666,51 @@ impl self_ty_ : cmp::Eq {
     }
     pure fn ne(&&other: self_ty_) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl self_ty_ : cmp::Eq {
+    pure fn eq(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
+                }
+            }
+        }
+    }
+    pure fn ne(other: &self_ty_) -> bool { !self.eq(other) }
+}
 
 #[auto_serialize]
 type self_ty = spanned<self_ty_>;
@@ -1228,13 +1736,23 @@ enum foreign_abi {
 #[auto_serialize]
 enum foreign_mod_sort { named, anonymous }
 
+#[cfg(stage0)]
 impl foreign_mod_sort : cmp::Eq {
     pure fn eq(&&other: foreign_mod_sort) -> bool {
         (self as uint) == (other as uint)
     }
     pure fn ne(&&other: foreign_mod_sort) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl foreign_mod_sort : cmp::Eq {
+    pure fn eq(other: &foreign_mod_sort) -> bool {
+        (self as uint) == ((*other) as uint)
+    }
+    pure fn ne(other: &foreign_mod_sort) -> bool { !self.eq(other) }
+}
 
+#[cfg(stage0)]
 impl foreign_abi : cmp::Eq {
     pure fn eq(&&other: foreign_abi) -> bool {
         match (self, other) {
@@ -1248,6 +1766,21 @@ impl foreign_abi : cmp::Eq {
     }
     pure fn ne(&&other: foreign_abi) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl foreign_abi : cmp::Eq {
+    pure fn eq(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,
+        }
+    }
+    pure fn ne(other: &foreign_abi) -> bool { !self.eq(other) }
+}
 
 #[auto_serialize]
 type foreign_mod =
@@ -1284,12 +1817,21 @@ enum variant_kind {
 #[auto_serialize]
 enum namespace { module_ns, type_value_ns }
 
+#[cfg(stage0)]
 impl namespace : cmp::Eq {
     pure fn eq(&&other: namespace) -> bool {
         (self as uint) == (other as uint)
     }
     pure fn ne(&&other: namespace) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl namespace : cmp::Eq {
+    pure fn eq(other: &namespace) -> bool {
+        (self as uint) == ((*other) as uint)
+    }
+    pure fn ne(other: &namespace) -> bool { !self.eq(other) }
+}
 
 #[auto_serialize]
 type view_path = spanned<view_path_>;
@@ -1332,12 +1874,21 @@ enum view_item_ {
 #[auto_serialize]
 enum attr_style { attr_outer, attr_inner, }
 
+#[cfg(stage0)]
 impl attr_style : cmp::Eq {
     pure fn eq(&&other: attr_style) -> bool {
         (self as uint) == (other as uint)
     }
     pure fn ne(&&other: attr_style) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl attr_style : cmp::Eq {
+    pure fn eq(other: &attr_style) -> bool {
+        (self as uint) == ((*other) as uint)
+    }
+    pure fn ne(other: &attr_style) -> bool { !self.eq(other) }
+}
 
 // doc-comments are promoted to attributes that have is_sugared_doc = true
 #[auto_serialize]
@@ -1358,6 +1909,7 @@ impl attr_style : cmp::Eq {
 #[auto_serialize]
 enum visibility { public, private, inherited }
 
+#[cfg(stage0)]
 impl visibility : cmp::Eq {
     pure fn eq(&&other: visibility) -> bool {
         match (self, other) {
@@ -1371,6 +1923,21 @@ impl visibility : cmp::Eq {
     }
     pure fn ne(&&other: visibility) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl visibility : cmp::Eq {
+    pure fn eq(other: &visibility) -> bool {
+        match (self, (*other)) {
+            (public, public) => true,
+            (private, private) => true,
+            (inherited, inherited) => true,
+            (public, _) => false,
+            (private, _) => false,
+            (inherited, _) => false,
+        }
+    }
+    pure fn ne(other: &visibility) -> bool { !self.eq(other) }
+}
 
 #[auto_serialize]
 type struct_field_ = {
@@ -1435,6 +2002,7 @@ impl class_mutability : to_bytes::IterBytes {
     }
 }
 
+#[cfg(stage0)]
 impl class_mutability : cmp::Eq {
     pure fn eq(&&other: class_mutability) -> bool {
         match (self, other) {
@@ -1446,6 +2014,19 @@ impl class_mutability : cmp::Eq {
     }
     pure fn ne(&&other: class_mutability) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl class_mutability : cmp::Eq {
+    pure fn eq(other: &class_mutability) -> bool {
+        match (self, (*other)) {
+            (class_mutable, class_mutable) => true,
+            (class_immutable, class_immutable) => true,
+            (class_mutable, _) => false,
+            (class_immutable, _) => false,
+        }
+    }
+    pure fn ne(other: &class_mutability) -> bool { !self.eq(other) }
+}
 
 #[auto_serialize]
 type class_ctor = spanned<class_ctor_>;
index d813c7e4b0873633c41add21c4b50ca564bdff27..3257e54626bdae31d76c5fd0e0e401d771da050c 100644 (file)
@@ -11,6 +11,7 @@ enum path_elt {
     path_name(ident)
 }
 
+#[cfg(stage0)]
 impl path_elt : cmp::Eq {
     pure fn eq(&&other: path_elt) -> bool {
         match self {
@@ -30,6 +31,27 @@ impl path_elt : cmp::Eq {
     }
     pure fn ne(&&other: path_elt) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl path_elt : cmp::Eq {
+    pure fn eq(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
+                }
+            }
+        }
+    }
+    pure fn ne(other: &path_elt) -> bool { !self.eq(other) }
+}
 
 type path = ~[path_elt];
 
index fdcd1087935e95bb61fabc6106fd8f1ad9382ed1..1a8096484c2afa74e366b2c6120a372f0e1f8e6e 100644 (file)
@@ -337,12 +337,21 @@ enum inline_attr {
     ia_never,
 }
 
+#[cfg(stage0)]
 impl inline_attr : cmp::Eq {
     pure fn eq(&&other: inline_attr) -> bool {
         (self as uint) == (other as uint)
     }
     pure fn ne(&&other: inline_attr) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl inline_attr : cmp::Eq {
+    pure fn eq(other: &inline_attr) -> bool {
+        (self as uint) == ((*other) as uint)
+    }
+    pure fn ne(other: &inline_attr) -> bool { !self.eq(other) }
+}
 
 /// True if something like #[inline] is found in the list of attrs.
 fn find_inline_attr(attrs: ~[ast::attribute]) -> inline_attr {
index ab34ed8368c249f8106ef802675214ee8fa296c6..6340e10429dfb04d52befd86c903fbca426bc36b 100644 (file)
 
 type file_pos = {ch: uint, byte: uint};
 
+#[cfg(stage0)]
 impl file_pos: cmp::Eq {
     pure fn eq(&&other: file_pos) -> bool {
         self.ch == other.ch && self.byte == other.byte
     }
     pure fn ne(&&other: file_pos) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl file_pos : cmp::Eq {
+    pure fn eq(other: &file_pos) -> bool {
+        self.ch == (*other).ch && self.byte == (*other).byte
+    }
+    pure fn ne(other: &file_pos) -> bool { !self.eq(other) }
+}
 
 /* A codemap is a thing that maps uints to file/line/column positions
  * in a crate. This to make it possible to represent the positions
@@ -171,12 +180,21 @@ enum expn_info_ {
 
 type span = {lo: uint, hi: uint, expn_info: expn_info};
 
+#[cfg(stage0)]
 impl span : cmp::Eq {
     pure fn eq(&&other: span) -> bool {
         return self.lo == other.lo && self.hi == other.hi;
     }
     pure fn ne(&&other: span) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl span : cmp::Eq {
+    pure fn eq(other: &span) -> bool {
+        return self.lo == (*other).lo && self.hi == (*other).hi;
+    }
+    pure fn ne(other: &span) -> bool { !self.eq(other) }
+}
 
 fn span_to_str_no_adj(sp: span, cm: codemap) -> ~str {
     let lo = lookup_char_pos(cm, sp.lo);
index 217b8c9cf4b17cecbad4ae0e966feec4ac60d25a..cbe9097bd7dbb261993827a0c955cc29dadd92f6 100644 (file)
@@ -146,12 +146,21 @@ enum level {
     note,
 }
 
+#[cfg(stage0)]
 impl level : cmp::Eq {
     pure fn eq(&&other: level) -> bool {
         (self as uint) == (other as uint)
     }
     pure fn ne(&&other: level) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl level : cmp::Eq {
+    pure fn eq(other: &level) -> bool {
+        (self as uint) == ((*other) as uint)
+    }
+    pure fn ne(other: &level) -> bool { !self.eq(other) }
+}
 
 fn diagnosticstr(lvl: level) -> ~str {
     match lvl {
index fec8339cf1a63b1f3e12d28f6e05043974443f45..9656a63cb0b3d14d62f3fb0bc9d1ff35edf3b669 100644 (file)
@@ -5,6 +5,7 @@
 
 enum direction { send, recv }
 
+#[cfg(stage0)]
 impl direction : cmp::Eq {
     pure fn eq(&&other: direction) -> bool {
         match (self, other) {
@@ -16,6 +17,19 @@ impl direction : cmp::Eq {
     }
     pure fn ne(&&other: direction) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl direction : cmp::Eq {
+    pure fn eq(other: &direction) -> bool {
+        match (self, (*other)) {
+            (send, send) => true,
+            (recv, recv) => true,
+            (send, _) => false,
+            (recv, _) => false,
+        }
+    }
+    pure fn ne(other: &direction) -> bool { !self.eq(other) }
+}
 
 impl direction: ToStr {
     fn to_str() -> ~str {
index 7fcf7a032dc0189ec7593c4564df76acc80ff8cf..214b9e3fbbd60c8a7fe836a888a1f85c01ec6084 100644 (file)
@@ -17,6 +17,7 @@ enum cmnt_style {
     blank_line, // Just a manual blank line "\n\n", for layout
 }
 
+#[cfg(stage0)]
 impl cmnt_style : cmp::Eq {
     pure fn eq(&&other: cmnt_style) -> bool {
         (self as uint) == (other as uint)
@@ -25,6 +26,16 @@ impl cmnt_style : cmp::Eq {
         (self as uint) != (other as uint)
     }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl cmnt_style : cmp::Eq {
+    pure fn eq(other: &cmnt_style) -> bool {
+        (self as uint) == ((*other) as uint)
+    }
+    pure fn ne(other: &cmnt_style) -> bool {
+        (self as uint) != ((*other) as uint)
+    }
+}
 
 type cmnt = {style: cmnt_style, lines: ~[~str], pos: uint};
 
index 5b0fd67ae5032de904d1b13724fde37620625f24..3891e7b6d177b7af74c3cd4bc8d389ec9f491a10 100644 (file)
@@ -24,6 +24,7 @@ pub enum ObsoleteSyntax {
     ObsoletePrivSection
 }
 
+#[cfg(stage0)]
 impl ObsoleteSyntax : cmp::Eq {
     pure fn eq(&&other: ObsoleteSyntax) -> bool {
         self as uint == other as uint
@@ -32,6 +33,16 @@ impl ObsoleteSyntax : cmp::Eq {
         !self.eq(other)
     }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl ObsoleteSyntax : cmp::Eq {
+    pure fn eq(other: &ObsoleteSyntax) -> bool {
+        self as uint == (*other) as uint
+    }
+    pure fn ne(other: &ObsoleteSyntax) -> bool {
+        !self.eq(other)
+    }
+}
 
 impl ObsoleteSyntax: to_bytes::IterBytes {
     #[inline(always)]
index a1c1208d21c5fc37dc0657e68e65d50f50c68b50..a6ad5b354843df422cb17da594d446829f2bcdf5 100644 (file)
@@ -3647,12 +3647,21 @@ fn parse_crate_directives(term: token::token,
     }
 }
 
+#[cfg(stage0)]
 impl restriction : cmp::Eq {
     pure fn eq(&&other: restriction) -> bool {
         (self as uint) == (other as uint)
     }
     pure fn ne(&&other: restriction) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl restriction : cmp::Eq {
+    pure fn eq(other: &restriction) -> bool {
+        (self as uint) == ((*other) as uint)
+    }
+    pure fn ne(other: &restriction) -> bool { !self.eq(other) }
+}
 
 //
 // Local Variables:
index 5629907ff1446fee058f9d1381b7447e3116aad0..d04a65fd2db76b014fe3ec74aba2d3ac36d1564b 100644 (file)
@@ -435,13 +435,23 @@ fn reserved_keyword_table() -> HashMap<~str, ()> {
     words
 }
 
+#[cfg(stage0)]
 impl binop : cmp::Eq {
     pure fn eq(&&other: binop) -> bool {
         (self as uint) == (other as uint)
     }
     pure fn ne(&&other: binop) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl binop : cmp::Eq {
+    pure fn eq(other: &binop) -> bool {
+        (self as uint) == ((*other) as uint)
+    }
+    pure fn ne(other: &binop) -> bool { !self.eq(other) }
+}
 
+#[cfg(stage0)]
 impl token : cmp::Eq {
     pure fn eq(&&other: token) -> bool {
         match self {
@@ -707,6 +717,273 @@ impl token : cmp::Eq {
     }
     pure fn ne(&&other: token) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl token : cmp::Eq {
+    pure fn eq(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_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
+                }
+            }
+        }
+    }
+    pure fn ne(other: &token) -> bool { !self.eq(other) }
+}
 
 // Local Variables:
 // fill-column: 78;
index 6ab936f1448ed636c3c99cd424a8735abac8be09..c69739e4cf6d41abccf114243ed3810ebfe4cf93 100644 (file)
@@ -55,6 +55,7 @@
  */
 enum breaks { consistent, inconsistent, }
 
+#[cfg(stage0)]
 impl breaks : cmp::Eq {
     pure fn eq(&&other: breaks) -> bool {
         match (self, other) {
@@ -66,6 +67,19 @@ impl breaks : cmp::Eq {
     }
     pure fn ne(&&other: breaks) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl breaks : cmp::Eq {
+    pure fn eq(other: &breaks) -> bool {
+        match (self, (*other)) {
+            (consistent, consistent) => true,
+            (inconsistent, inconsistent) => true,
+            (consistent, _) => false,
+            (inconsistent, _) => false,
+        }
+    }
+    pure fn ne(other: &breaks) -> bool { !self.eq(other) }
+}
 
 type break_t = {offset: int, blank_space: int};
 
index 3d3789368f3649d545acae1cb7c50f28957cdac1..c52b2c661abfc4b245cd88f49e7a218b8011644e 100644 (file)
@@ -26,12 +26,21 @@ enum output_type {
     output_type_exe,
 }
 
+#[cfg(stage0)]
 impl output_type : cmp::Eq {
     pure fn eq(&&other: output_type) -> bool {
         (self as uint) == (other as uint)
     }
     pure fn ne(&&other: output_type) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl output_type : cmp::Eq {
+    pure fn eq(other: &output_type) -> bool {
+        (self as uint) == ((*other) as uint)
+    }
+    pure fn ne(other: &output_type) -> bool { !self.eq(other) }
+}
 
 fn llvm_err(sess: session, msg: ~str) -> ! unsafe {
     let cstr = llvm::LLVMRustGetLastError();
index 7ccad3b717d854899d754eff4fbf88df0d2d4677..a2e65656cc09079cccfec58a29e296398f7ba7e2 100644 (file)
@@ -138,12 +138,21 @@ enum compile_upto {
     cu_everything,
 }
 
+#[cfg(stage0)]
 impl compile_upto : cmp::Eq {
     pure fn eq(&&other: compile_upto) -> bool {
         (self as uint) == (other as uint)
     }
     pure fn ne(&&other: compile_upto) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl compile_upto : cmp::Eq {
+    pure fn eq(other: &compile_upto) -> bool {
+        (self as uint) == ((*other) as uint)
+    }
+    pure fn ne(other: &compile_upto) -> bool { !self.eq(other) }
+}
 
 fn compile_upto(sess: session, cfg: ast::crate_cfg,
                 input: input, upto: compile_upto,
index d34d92b153412c5807e6626561ddaa20388ad06b..dff272ee9be553a17531ec1978bc5ef72c42adf8 100644 (file)
@@ -207,12 +207,21 @@ enum monitor_msg {
     done,
 }
 
+#[cfg(stage0)]
 impl monitor_msg : cmp::Eq {
     pure fn eq(&&other: monitor_msg) -> bool {
         (self as uint) == (other as uint)
     }
     pure fn ne(&&other: monitor_msg) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl monitor_msg : cmp::Eq {
+    pure fn eq(other: &monitor_msg) -> bool {
+        (self as uint) == ((*other) as uint)
+    }
+    pure fn ne(other: &monitor_msg) -> bool { !self.eq(other) }
+}
 
 /*
 This is a sanity check that any failure of the compiler is performed
index 70e717aa6d9ea5881ca76c714b30fe7dc806f99c..01dcd6930b369b604d6e381d109cbaf90ec0daa3 100644 (file)
 
 enum os { os_win32, os_macos, os_linux, os_freebsd, }
 
+#[cfg(stage0)]
 impl os : cmp::Eq {
     pure fn eq(&&other: os) -> bool {
         (self as uint) == (other as uint)
     }
     pure fn ne(&&other: os) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl os : cmp::Eq {
+    pure fn eq(other: &os) -> bool {
+        (self as uint) == ((*other) as uint)
+    }
+    pure fn ne(other: &os) -> bool { !self.eq(other) }
+}
 
 enum arch { arch_x86, arch_x86_64, arch_arm, }
 
+#[cfg(stage0)]
 impl arch: cmp::Eq {
     pure fn eq(&&other: arch) -> bool {
         (self as uint) == (other as uint)
     }
     pure fn ne(&&other: arch) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl arch : cmp::Eq {
+    pure fn eq(other: &arch) -> bool {
+        (self as uint) == ((*other) as uint)
+    }
+    pure fn ne(other: &arch) -> bool { !self.eq(other) }
+}
 
 enum crate_type { bin_crate, lib_crate, unknown_crate, }
 
@@ -94,12 +112,21 @@ enum OptLevel {
     Aggressive // -O3
 }
 
+#[cfg(stage0)]
 impl OptLevel : cmp::Eq {
     pure fn eq(&&other: OptLevel) -> bool {
         (self as uint) == (other as uint)
     }
     pure fn ne(&&other: OptLevel) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl OptLevel : cmp::Eq {
+    pure fn eq(other: &OptLevel) -> bool {
+        (self as uint) == ((*other) as uint)
+    }
+    pure fn ne(other: &OptLevel) -> bool { !self.eq(other) }
+}
 
 type options =
     // The crate config requested for the session, which may be combined
index b6ee29b8a1b7b0f4476c5323b23b3fed8aed5986..10866a213fee9631144ed5d9313e0afa22e38364 100644 (file)
@@ -128,6 +128,7 @@ enum TypeKind {
     X86_MMX   = 15
 }
 
+#[cfg(stage0)]
 impl TypeKind : cmp::Eq {
     pure fn eq(&&other: TypeKind) -> bool {
         match (self, other) {
@@ -167,6 +168,47 @@ impl TypeKind : cmp::Eq {
     }
     pure fn ne(&&other: TypeKind) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl TypeKind : cmp::Eq {
+    pure fn eq(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,
+        }
+    }
+    pure fn ne(other: &TypeKind) -> bool { !self.eq(other) }
+}
 
 enum AtomicBinOp {
     Xchg = 0,
index 61cf9646762a0a364947318a1398d01733a1dacb..d817993f771e1d47fe6ae74ccc98c93eec18764e 100644 (file)
@@ -129,12 +129,21 @@ enum Family {
     InheritedField         // N
 }
 
+#[cfg(stage0)]
 impl Family : cmp::Eq {
     pure fn eq(&&other: Family) -> bool {
         (self as uint) == (other as uint)
     }
     pure fn ne(&&other: Family) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl Family : cmp::Eq {
+    pure fn eq(other: &Family) -> bool {
+        (self as uint) == ((*other) as uint)
+    }
+    pure fn ne(other: &Family) -> bool { !self.eq(other) }
+}
 
 fn item_family(item: ebml::Doc) -> Family {
     let fam = ebml::get_doc(item, tag_items_data_item_family);
index d2327bd3ce5c0f8d0a052248575795c66a90fdd3..67f3c8405a845128feaa1565c8b17779adc9f680 100644 (file)
@@ -323,6 +323,7 @@ enum bckerr_code {
     err_out_of_scope(ty::region, ty::region) // superscope, subscope
 }
 
+#[cfg(stage0)]
 impl bckerr_code : cmp::Eq {
     pure fn eq(&&other: bckerr_code) -> bool {
         match self {
@@ -367,17 +368,72 @@ impl bckerr_code : cmp::Eq {
     }
     pure fn ne(&&other: bckerr_code) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl bckerr_code : cmp::Eq {
+    pure fn eq(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
+                }
+            }
+        }
+    }
+    pure fn ne(other: &bckerr_code) -> bool { !self.eq(other) }
+}
 
 // Combination of an error code and the categorization of the expression
 // that caused it
 type bckerr = {cmt: cmt, code: bckerr_code};
 
+#[cfg(stage0)]
 impl bckerr : cmp::Eq {
     pure fn eq(&&other: bckerr) -> bool {
         self.cmt == other.cmt && self.code == other.code
     }
     pure fn ne(&&other: bckerr) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl bckerr : cmp::Eq {
+    pure fn eq(other: &bckerr) -> bool {
+        self.cmt == (*other).cmt && self.code == (*other).code
+    }
+    pure fn ne(other: &bckerr) -> bool { !self.eq(other) }
+}
 
 // shorthand for something that fails with `bckerr` or succeeds with `T`
 type bckres<T> = Result<T, bckerr>;
@@ -405,6 +461,7 @@ fn save_and_restore<T:Copy,U>(&save_and_restore_t: T, f: fn() -> U) -> U {
 
 /// Creates and returns a new root_map
 
+#[cfg(stage0)]
 impl root_map_key : cmp::Eq {
     pure fn eq(&&other: root_map_key) -> bool {
         self.id == other.id && self.derefs == other.derefs
@@ -413,6 +470,16 @@ impl root_map_key : cmp::Eq {
         ! (self == other)
     }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl root_map_key : cmp::Eq {
+    pure fn eq(other: &root_map_key) -> bool {
+        self.id == (*other).id && self.derefs == (*other).derefs
+    }
+    pure fn ne(other: &root_map_key) -> bool {
+        ! (self == (*other))
+    }
+}
 
 impl root_map_key : to_bytes::IterBytes {
     pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) {
index d0c722cab10865011a18ba0d0c83cc0d632f76b1..86fbce8cadae0cd776f5fa61ad2104d3ff504c06 100644 (file)
@@ -36,6 +36,7 @@ enum purity_cause {
     pc_cmt(bckerr)
 }
 
+#[cfg(stage0)]
 impl purity_cause : cmp::Eq {
     pure fn eq(&&other: purity_cause) -> bool {
         match self {
@@ -55,6 +56,27 @@ impl purity_cause : cmp::Eq {
     }
     pure fn ne(&&other: purity_cause) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl purity_cause : cmp::Eq {
+    pure fn eq(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
+                }
+            }
+        }
+    }
+    pure fn ne(other: &purity_cause) -> bool { !self.eq(other) }
+}
 
 fn check_loans(bccx: borrowck_ctxt,
                req_maps: req_maps,
@@ -78,12 +100,21 @@ enum assignment_type {
     at_swap
 }
 
+#[cfg(stage0)]
 impl assignment_type : cmp::Eq {
     pure fn eq(&&other: assignment_type) -> bool {
         (self as uint) == (other as uint)
     }
     pure fn ne(&&other: assignment_type) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl assignment_type : cmp::Eq {
+    pure fn eq(other: &assignment_type) -> bool {
+        (self as uint) == ((*other) as uint)
+    }
+    pure fn ne(other: &assignment_type) -> bool { !self.eq(other) }
+}
 
 impl assignment_type {
     fn checked_by_liveness() -> bool {
index 9e1c8886353ee20ff7900b8197125f817c34bbab..a8551319da2feafd9dc41f5d1f6ad74e17e06098 100644 (file)
@@ -124,6 +124,7 @@ enum ctor {
     range(const_val, const_val),
 }
 
+#[cfg(stage0)]
 impl ctor: cmp::Eq {
     pure fn eq(&&other: ctor) -> bool {
         match (self, other) {
@@ -140,6 +141,24 @@ impl ctor: cmp::Eq {
     }
     pure fn ne(&&other: ctor) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl ctor : cmp::Eq {
+    pure fn eq(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
+            }
+        }
+    }
+    pure fn ne(other: &ctor) -> bool { !self.eq(other) }
+}
 
 // Algorithm from http://moscova.inria.fr/~maranget/papers/warn/index.html
 //
index 6c9617d33109cd2517faf92f55a104498fa91056..86b7bd8ab8d52f7ab0661e3300f2adab99f3b650 100644 (file)
@@ -189,6 +189,7 @@ enum const_val {
     const_bool(bool)
 }
 
+#[cfg(stage0)]
 impl const_val: cmp::Eq {
     pure fn eq(&&other: const_val) -> bool {
         match (self, other) {
@@ -203,6 +204,22 @@ impl const_val: cmp::Eq {
     }
     pure fn ne(&&other: const_val) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl const_val : cmp::Eq {
+    pure fn eq(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
+        }
+    }
+    pure fn ne(other: &const_val) -> bool { !self.eq(other) }
+}
 
 // FIXME: issue #1417
 fn eval_const_expr(tcx: middle::ty::ctxt, e: @expr) -> const_val {
index 7ffc0fcf090c58bcae329cf666003971d6e245aa..10079338f03424ae0673af5f924c52075c8a00ff 100644 (file)
@@ -66,12 +66,21 @@ enum lint {
     // dead_assignment
 }
 
+#[cfg(stage0)]
 impl lint : cmp::Eq {
     pure fn eq(&&other: lint) -> bool {
         (self as uint) == (other as uint)
     }
     pure fn ne(&&other: lint) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl lint : cmp::Eq {
+    pure fn eq(other: &lint) -> bool {
+        (self as uint) == ((*other) as uint)
+    }
+    pure fn ne(other: &lint) -> bool { !self.eq(other) }
+}
 
 fn level_to_str(lv: level) -> ~str {
     match lv {
@@ -86,12 +95,21 @@ enum level {
     allow, warn, deny, forbid
 }
 
+#[cfg(stage0)]
 impl level : cmp::Eq {
     pure fn eq(&&other: level) -> bool {
         (self as uint) == (other as uint)
     }
     pure fn ne(&&other: level) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl level : cmp::Eq {
+    pure fn eq(other: &level) -> bool {
+        (self as uint) == ((*other) as uint)
+    }
+    pure fn ne(other: &level) -> bool { !self.eq(other) }
+}
 
 type lint_spec = @{lint: lint,
                    desc: ~str,
index 18480ee483fe228570b573c808e88d62520a9f30..d34c38b9f27633159b21e60b393a2e04d7db42b0 100644 (file)
 enum Variable = uint;
 enum LiveNode = uint;
 
+#[cfg(stage0)]
 impl Variable : cmp::Eq {
     pure fn eq(&&other: Variable) -> bool { *self == *other }
     pure fn ne(&&other: Variable) -> bool { *self != *other }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl Variable : cmp::Eq {
+    pure fn eq(other: &Variable) -> bool { *self == *(*other) }
+    pure fn ne(other: &Variable) -> bool { *self != *(*other) }
+}
 
+#[cfg(stage0)]
 impl LiveNode : cmp::Eq {
     pure fn eq(&&other: LiveNode) -> bool { *self == *other }
     pure fn ne(&&other: LiveNode) -> bool { *self != *other }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl LiveNode : cmp::Eq {
+    pure fn eq(other: &LiveNode) -> bool { *self == *(*other) }
+    pure fn ne(other: &LiveNode) -> bool { *self != *(*other) }
+}
 
 enum LiveNodeKind {
     FreeVarNode(span),
@@ -144,6 +158,7 @@ enum LiveNodeKind {
     ExitNode
 }
 
+#[cfg(stage0)]
 impl LiveNodeKind : cmp::Eq {
     pure fn eq(&&other: LiveNodeKind) -> bool {
         match self {
@@ -175,6 +190,39 @@ impl LiveNodeKind : cmp::Eq {
     }
     pure fn ne(&&other: LiveNodeKind) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl LiveNodeKind : cmp::Eq {
+    pure fn eq(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
+                }
+            }
+        }
+    }
+    pure fn ne(other: &LiveNodeKind) -> bool { !self.eq(other) }
+}
 
 fn check_crate(tcx: ty::ctxt,
                method_map: typeck::method_map,
index c4b0e0ffd00ed361a50294886443e2a329f30380..077db7f0260ffc460ab5a01b7927bfee3507b625 100644 (file)
@@ -55,6 +55,7 @@ enum categorization {
     cat_discr(cmt, ast::node_id),   // match discriminant (see preserve())
 }
 
+#[cfg(stage0)]
 impl categorization : cmp::Eq {
     pure fn eq(&&other: categorization) -> bool {
         match self {
@@ -117,6 +118,70 @@ impl categorization : cmp::Eq {
     }
     pure fn ne(&&other: categorization) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl categorization : cmp::Eq {
+    pure fn eq(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
+                }
+            }
+        }
+    }
+    pure fn ne(other: &categorization) -> bool { !self.eq(other) }
+}
 
 // different kinds of pointers:
 enum ptr_kind {
@@ -126,6 +191,7 @@ enum ptr_kind {
     unsafe_ptr
 }
 
+#[cfg(stage0)]
 impl ptr_kind : cmp::Eq {
     pure fn eq(&&other: ptr_kind) -> bool {
         match self {
@@ -157,6 +223,39 @@ impl ptr_kind : cmp::Eq {
     }
     pure fn ne(&&other: ptr_kind) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl ptr_kind : cmp::Eq {
+    pure fn eq(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
+                }
+            }
+        }
+    }
+    pure fn ne(other: &ptr_kind) -> bool { !self.eq(other) }
+}
 
 // I am coining the term "components" to mean "pieces of a data
 // structure accessible without a dereference":
@@ -169,6 +268,7 @@ enum comp_kind {
                ast::mutability)  // mutability of vec content
 }
 
+#[cfg(stage0)]
 impl comp_kind : cmp::Eq {
     pure fn eq(&&other: comp_kind) -> bool {
         match self {
@@ -200,6 +300,39 @@ impl comp_kind : cmp::Eq {
     }
     pure fn ne(&&other: comp_kind) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl comp_kind : cmp::Eq {
+    pure fn eq(other: &comp_kind) -> bool {
+        match self {
+            comp_tuple => {
+                match (*other) {
+                    comp_tuple => 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
+                }
+            }
+        }
+    }
+    pure fn ne(other: &comp_kind) -> bool { !self.eq(other) }
+}
 
 // different kinds of expressions we might evaluate
 enum special_kind {
@@ -209,12 +342,21 @@ enum special_kind {
     sk_heap_upvar
 }
 
+#[cfg(stage0)]
 impl special_kind : cmp::Eq {
     pure fn eq(&&other: special_kind) -> bool {
         (self as uint) == (other as uint)
     }
     pure fn ne(&&other: special_kind) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl special_kind : cmp::Eq {
+    pure fn eq(other: &special_kind) -> bool {
+        (self as uint) == ((*other) as uint)
+    }
+    pure fn ne(other: &special_kind) -> bool { !self.eq(other) }
+}
 
 // a complete categorization of a value indicating where it originated
 // and how it is located, as well as the mutability of the memory in
@@ -228,6 +370,7 @@ impl special_kind : cmp::Eq {
 
 type cmt = @cmt_;
 
+#[cfg(stage0)]
 impl cmt_ : cmp::Eq {
     pure fn eq(&&other: cmt_) -> bool {
         self.id == other.id &&
@@ -239,6 +382,19 @@ impl cmt_ : cmp::Eq {
     }
     pure fn ne(&&other: cmt_) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl cmt_ : cmp::Eq {
+    pure fn eq(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
+    }
+    pure fn ne(other: &cmt_) -> bool { !self.eq(other) }
+}
 
 // a loan path is like a category, but it exists only when the data is
 // interior to the stack frame.  loan paths are used as the key to a
@@ -250,6 +406,7 @@ enum loan_path {
     lp_comp(@loan_path, comp_kind)
 }
 
+#[cfg(stage0)]
 impl loan_path : cmp::Eq {
     pure fn eq(&&other: loan_path) -> bool {
         match self {
@@ -281,6 +438,39 @@ impl loan_path : cmp::Eq {
     }
     pure fn ne(&&other: loan_path) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl loan_path : cmp::Eq {
+    pure fn eq(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
+                }
+            }
+        }
+    }
+    pure fn ne(other: &loan_path) -> bool { !self.eq(other) }
+}
 
 // We pun on *T to mean both actual deref of a ptr as well
 // as accessing of components:
index b0916af376c3565c73025a2d820e5d90957d6902..ab218a4d49f11127b03ef0d662f5c83dbdbc6fda 100644 (file)
@@ -373,12 +373,22 @@ fn resolve_crate(sess: session, def_map: resolve::DefMap,
 type region_dep = {ambient_variance: region_variance, id: ast::node_id};
 type dep_map = HashMap<ast::node_id, @DVec<region_dep>>;
 
+#[cfg(stage0)]
 impl region_dep: cmp::Eq {
     pure fn eq(&&other: region_dep) -> bool {
         self.ambient_variance == other.ambient_variance && self.id == other.id
     }
     pure fn ne(&&other: region_dep) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl region_dep : cmp::Eq {
+    pure fn eq(other: &region_dep) -> bool {
+        self.ambient_variance == (*other).ambient_variance &&
+        self.id == (*other).id
+    }
+    pure fn ne(other: &region_dep) -> bool { !self.eq(other) }
+}
 
 type determine_rp_ctxt_ = {
     sess: session,
index 24806197baf89bfd984bea7c578a415746135604..ab143cca18bdf75f4da4783ef521589949be8950 100644 (file)
@@ -110,12 +110,21 @@ enum PatternBindingMode {
     IrrefutableMode
 }
 
+#[cfg(stage0)]
 impl PatternBindingMode : cmp::Eq {
     pure fn eq(&&other: PatternBindingMode) -> bool {
         (self as uint) == (other as uint)
     }
     pure fn ne(&&other: PatternBindingMode) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl PatternBindingMode : cmp::Eq {
+    pure fn eq(other: &PatternBindingMode) -> bool {
+        (self as uint) == ((*other) as uint)
+    }
+    pure fn ne(other: &PatternBindingMode) -> bool { !self.eq(other) }
+}
 
 
 enum Namespace {
@@ -151,12 +160,21 @@ enum Mutability {
     Immutable
 }
 
+#[cfg(stage0)]
 impl Mutability : cmp::Eq {
     pure fn eq(&&other: Mutability) -> bool {
         (self as uint) == (other as uint)
     }
     pure fn ne(&&other: Mutability) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl Mutability : cmp::Eq {
+    pure fn eq(other: &Mutability) -> bool {
+        (self as uint) == ((*other) as uint)
+    }
+    pure fn ne(other: &Mutability) -> bool { !self.eq(other) }
+}
 
 enum SelfBinding {
     NoSelfBinding,
@@ -186,12 +204,21 @@ enum ImportDirectiveNS {
     AnyNS
 }
 
+#[cfg(stage0)]
 impl ImportDirectiveNS : cmp::Eq {
     pure fn eq(&&other: ImportDirectiveNS) -> bool {
         (self as uint) == (other as uint)
     }
     pure fn ne(&&other: ImportDirectiveNS) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl ImportDirectiveNS : cmp::Eq {
+    pure fn eq(other: &ImportDirectiveNS) -> bool {
+        (self as uint) == ((*other) as uint)
+    }
+    pure fn ne(other: &ImportDirectiveNS) -> bool { !self.eq(other) }
+}
 
 /// Contains data for specific types of import directives.
 enum ImportDirectiveSubclass {
@@ -282,24 +309,42 @@ enum XrayFlag {
     Xray        //< Private items can be accessed.
 }
 
+#[cfg(stage0)]
 impl XrayFlag : cmp::Eq {
     pure fn eq(&&other: XrayFlag) -> bool {
         (self as uint) == (other as uint)
     }
     pure fn ne(&&other: XrayFlag) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl XrayFlag : cmp::Eq {
+    pure fn eq(other: &XrayFlag) -> bool {
+        (self as uint) == ((*other) as uint)
+    }
+    pure fn ne(other: &XrayFlag) -> bool { !self.eq(other) }
+}
 
 enum AllowCapturingSelfFlag {
     AllowCapturingSelf,         //< The "self" definition can be captured.
     DontAllowCapturingSelf,     //< The "self" definition cannot be captured.
 }
 
+#[cfg(stage0)]
 impl AllowCapturingSelfFlag : cmp::Eq {
     pure fn eq(&&other: AllowCapturingSelfFlag) -> bool {
         (self as uint) == (other as uint)
     }
     pure fn ne(&&other: AllowCapturingSelfFlag) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl AllowCapturingSelfFlag : cmp::Eq {
+    pure fn eq(other: &AllowCapturingSelfFlag) -> bool {
+        (self as uint) == ((*other) as uint)
+    }
+    pure fn ne(other: &AllowCapturingSelfFlag) -> bool { !self.eq(other) }
+}
 
 enum EnumVariantOrConstResolution {
     FoundEnumVariant(def),
@@ -497,12 +542,21 @@ enum Privacy {
     Public
 }
 
+#[cfg(stage0)]
 impl Privacy : cmp::Eq {
     pure fn eq(&&other: Privacy) -> bool {
         (self as uint) == (other as uint)
     }
     pure fn ne(&&other: Privacy) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl Privacy : cmp::Eq {
+    pure fn eq(other: &Privacy) -> bool {
+        (self as uint) == ((*other) as uint)
+    }
+    pure fn ne(other: &Privacy) -> bool { !self.eq(other) }
+}
 
 // Records a possibly-private definition.
 struct Definition {
index 67f20f124094b12fdc65bd8bf7dbd85f235f9c3b..dc667d3ae50ca32a91bae4012634f92981385fa9 100644 (file)
@@ -649,12 +649,21 @@ fn score(p: @ast::pat) -> uint {
 
 enum branch_kind { no_branch, single, switch, compare, }
 
+#[cfg(stage0)]
 impl branch_kind : cmp::Eq {
     pure fn eq(&&other: branch_kind) -> bool {
         (self as uint) == (other as uint)
     }
     pure fn ne(&&other: branch_kind) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl branch_kind : cmp::Eq {
+    pure fn eq(other: &branch_kind) -> bool {
+        (self as uint) == ((*other) as uint)
+    }
+    pure fn ne(other: &branch_kind) -> bool { !self.eq(other) }
+}
 
 // Compiles a comparison between two things.
 fn compare_values(cx: block, lhs: ValueRef, rhs: ValueRef, rhs_t: ty::t) ->
index ea00d5aa46787bfa4dd82fe9ad267af94f814c4b..b4865044961d7ed9568f89c038532e9b10d48e64 100644 (file)
@@ -266,7 +266,7 @@ fn trans_call(in_cx: block,
     let _icx = in_cx.insn_ctxt("trans_call");
     trans_call_inner(
         in_cx, call_ex.info(), expr_ty(in_cx, f), node_id_type(in_cx, id),
-        |cx| trans(cx, f), args, dest)
+        |cx| trans(cx, f), args, dest, DontAutorefArg)
 }
 
 fn trans_rtcall(bcx: block, name: ~str, args: ~[ValueRef], dest: expr::Dest)
@@ -287,7 +287,7 @@ fn trans_rtcall_or_lang_call(bcx: block, did: ast::def_id, args: ~[ValueRef],
     return callee::trans_call_inner(
         bcx, None, fty, rty,
         |bcx| trans_fn_ref_with_vtables_to_callee(bcx, did, 0, ~[], None),
-        ArgVals(args), dest);
+        ArgVals(args), dest, DontAutorefArg);
 }
 
 fn body_contains_ret(body: ast::blk) -> bool {
@@ -315,7 +315,8 @@ fn trans_call_inner(
     ret_ty: ty::t,
     get_callee: fn(block) -> Callee,
     args: CallArgs,
-    dest: expr::Dest) -> block
+    dest: expr::Dest,
+    autoref_arg: AutorefArg) -> block
 {
     do base::with_scope(in_cx, call_info, ~"call") |cx| {
         let ret_in_loop = match args {
@@ -363,7 +364,7 @@ fn trans_call_inner(
         };
 
         let args_res = trans_args(bcx, llenv, args, fn_expr_ty,
-                                  dest, ret_flag);
+                                  dest, ret_flag, autoref_arg);
         bcx = args_res.bcx;
         let mut llargs = args_res.args;
 
@@ -414,7 +415,8 @@ enum CallArgs {
 }
 
 fn trans_args(cx: block, llenv: ValueRef, args: CallArgs, fn_ty: ty::t,
-              dest: expr::Dest, ret_flag: Option<ValueRef>)
+              dest: expr::Dest, ret_flag: Option<ValueRef>,
+              +autoref_arg: AutorefArg)
     -> {bcx: block, args: ~[ValueRef], retslot: ValueRef}
 {
     let _icx = cx.insn_ctxt("trans_args");
@@ -453,7 +455,8 @@ fn trans_args(cx: block, llenv: ValueRef, args: CallArgs, fn_ty: ty::t,
         for vec::eachi(arg_exprs) |i, arg_expr| {
             let arg_val = unpack_result!(bcx, {
                 trans_arg_expr(bcx, arg_tys[i], arg_expr, &mut temp_cleanups,
-                               if i == last { ret_flag } else { None })
+                               if i == last { ret_flag } else { None },
+                               autoref_arg)
             });
             vec::push(llargs, arg_val);
         }
@@ -473,13 +476,19 @@ fn trans_args(cx: block, llenv: ValueRef, args: CallArgs, fn_ty: ty::t,
     return {bcx: bcx, args: llargs, retslot: llretslot};
 }
 
+enum AutorefArg {
+    DontAutorefArg,
+    DoAutorefArg
+}
+
 // temp_cleanups: cleanups that should run only if failure occurs before the
 // call takes place:
 fn trans_arg_expr(bcx: block,
                   formal_ty: ty::arg,
                   arg_expr: @ast::expr,
                   temp_cleanups: &mut ~[ValueRef],
-                  ret_flag: Option<ValueRef>)
+                  ret_flag: Option<ValueRef>,
+                  +autoref_arg: AutorefArg)
     -> Result
 {
     let _icx = bcx.insn_ctxt("trans_arg_expr");
@@ -539,38 +548,45 @@ fn trans_arg_expr(bcx: block,
         let llformal_ty = type_of::type_of(ccx, formal_ty.ty);
         val = llvm::LLVMGetUndef(llformal_ty);
     } else {
-        match arg_mode {
-            ast::by_ref | ast::by_mutbl_ref => {
-                val = arg_datum.to_ref_llval(bcx);
-            }
-
-            ast::by_val => {
-                // NB: avoid running the take glue.
-                val = arg_datum.to_value_llval(bcx);
-            }
-
-            ast::by_copy | ast::by_move => {
-                let scratch = scratch_datum(bcx, arg_datum.ty, false);
-
-                if arg_mode == ast::by_move {
-                    // NDM---Doesn't seem like this should be necessary
-                    if !arg_datum.store_will_move() {
-                        bcx.sess().span_bug(
-                            arg_expr.span,
-                            fmt!("move mode but datum will not store: %s",
-                                 arg_datum.to_str(bcx.ccx())));
+        match autoref_arg {
+            DoAutorefArg => { val = arg_datum.to_ref_llval(bcx); }
+            DontAutorefArg => {
+                match arg_mode {
+                    ast::by_ref | ast::by_mutbl_ref => {
+                        val = arg_datum.to_ref_llval(bcx);
                     }
-                }
 
-                arg_datum.store_to_datum(bcx, INIT, scratch);
+                    ast::by_val => {
+                        // NB: avoid running the take glue.
+                        val = arg_datum.to_value_llval(bcx);
+                    }
 
-                // Technically, ownership of val passes to the callee.
-                // However, we must cleanup should we fail before the
-                // callee is actually invoked.
-                scratch.add_clean(bcx);
-                vec::push(*temp_cleanups, scratch.val);
-                val = scratch.val;
-          }
+                    ast::by_copy | ast::by_move => {
+                        let scratch = scratch_datum(bcx, arg_datum.ty, false);
+
+                        if arg_mode == ast::by_move {
+                            // NDM---Doesn't seem like this should be
+                            // necessary
+                            if !arg_datum.store_will_move() {
+                                bcx.sess().span_bug(
+                                    arg_expr.span,
+                                    fmt!("move mode but datum will not \
+                                          store: %s",
+                                          arg_datum.to_str(bcx.ccx())));
+                            }
+                        }
+
+                        arg_datum.store_to_datum(bcx, INIT, scratch);
+
+                        // Technically, ownership of val passes to the callee.
+                        // However, we must cleanup should we fail before the
+                        // callee is actually invoked.
+                        scratch.add_clean(bcx);
+                        vec::push(*temp_cleanups, scratch.val);
+                        val = scratch.val;
+                  }
+                }
+            }
         }
 
         if formal_ty.ty != arg_datum.ty {
index 70e02a5aaf9e01bbc5f053c1b5e9bf8bfcd338dd..fbf6c7804c4d7dec367320f6135254e4b79808a4 100644 (file)
@@ -282,6 +282,7 @@ enum cleanup {
     clean_temp(ValueRef, fn@(block) -> block, cleantype),
 }
 
+#[cfg(stage0)]
 impl cleantype : cmp::Eq {
     pure fn eq(&&other: cleantype) -> bool {
         match self {
@@ -301,6 +302,27 @@ impl cleantype : cmp::Eq {
     }
     pure fn ne(&&other: cleantype) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl cleantype : cmp::Eq {
+    pure fn eq(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
+                }
+            }
+        }
+    }
+    pure fn ne(other: &cleantype) -> bool { !self.eq(other) }
+}
 
 // Used to remember and reuse existing cleanup paths
 // target: none means the path ends in an resume instruction
@@ -1111,6 +1133,7 @@ enum mono_param_id {
 
 type mono_id = @mono_id_;
 
+#[cfg(stage0)]
 impl mono_param_id: cmp::Eq {
     pure fn eq(&&other: mono_param_id) -> bool {
         match (self, other) {
@@ -1128,13 +1151,41 @@ impl mono_param_id: cmp::Eq {
     }
     pure fn ne(&&other: mono_param_id) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl mono_param_id : cmp::Eq {
+    pure fn eq(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), mono_repr(size_b, align_b)) => {
+                size_a == size_b && align_a == align_b
+            }
+            (mono_precise(*), _) => false,
+            (mono_any, _) => false,
+            (mono_repr(*), _) => false
+        }
+    }
+    pure fn ne(other: &mono_param_id) -> bool { !self.eq(other) }
+}
 
+#[cfg(stage0)]
 impl mono_id_: cmp::Eq {
     pure fn eq(&&other: mono_id_) -> bool {
         return self.def == other.def && self.params == other.params;
     }
     pure fn ne(&&other: mono_id_) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl mono_id_ : cmp::Eq {
+    pure fn eq(other: &mono_id_) -> bool {
+        return self.def == (*other).def && self.params == (*other).params;
+    }
+    pure fn ne(other: &mono_id_) -> bool { !self.eq(other) }
+}
 
 impl mono_param_id : to_bytes::IterBytes {
     pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) {
index 791cebad641e13c5aefecb58c5f4e4bcdddc2245..a95fed84bafe7fecbe7e2d8627f7a6deab4300bd 100644 (file)
@@ -747,6 +747,7 @@ fn to_str() -> ~str {
     }
 }
 
+#[cfg(stage0)]
 impl CopyAction : cmp::Eq {
     pure fn eq(&&other: CopyAction) -> bool {
         match (self, other) {
@@ -758,3 +759,16 @@ impl CopyAction : cmp::Eq {
     }
     pure fn ne(&&other: CopyAction) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl CopyAction : cmp::Eq {
+    pure fn eq(other: &CopyAction) -> bool {
+        match (self, (*other)) {
+            (INIT, INIT) => true,
+            (DROP_EXISTING, DROP_EXISTING) => true,
+            (INIT, _) => false,
+            (DROP_EXISTING, _) => false,
+        }
+    }
+    pure fn ne(other: &CopyAction) -> bool { !self.eq(other) }
+}
index ea2aa7c98e1566212d8e6cd2908dbd3997b541e7..27a2ad50223e8462fc807d72ed3fc18ad557a8c1 100644 (file)
 use util::ppaux::ty_to_str;
 use util::common::indenter;
 use ty::{AutoPtr, AutoSlice};
+use callee::{AutorefArg, DoAutorefArg, DontAutorefArg};
 
 // The primary two functions for translating expressions:
 export trans_to_datum, trans_into;
@@ -146,6 +147,7 @@ fn to_str(ccx: @crate_ctxt) -> ~str {
     }
 }
 
+#[cfg(stage0)]
 impl Dest : cmp::Eq {
     pure fn eq(&&other: Dest) -> bool {
         match (self, other) {
@@ -157,6 +159,19 @@ impl Dest : cmp::Eq {
     }
     pure fn ne(&&other: Dest) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl Dest : cmp::Eq {
+    pure fn eq(other: &Dest) -> bool {
+        match (self, (*other)) {
+            (SaveIn(e0a), SaveIn(e0b)) => e0a == e0b,
+            (Ignore, Ignore) => true,
+            (SaveIn(*), _) => false,
+            (Ignore, _) => false,
+        }
+    }
+    pure fn ne(other: &Dest) -> bool { !self.eq(other) }
+}
 
 fn trans_to_datum(bcx: block, expr: @ast::expr) -> DatumBlock {
     debug!("trans_to_datum(expr=%s)", bcx.expr_to_str(expr));
@@ -596,15 +611,18 @@ fn ast_proto_to_proto_simple(ast_proto: ast::proto)
         }
         ast::expr_binary(_, lhs, rhs) => {
             // if not overloaded, would be RvalueDatumExpr
-            return trans_overloaded_op(bcx, expr, lhs, ~[rhs], dest);
+            return trans_overloaded_op(bcx, expr, lhs, ~[rhs], dest,
+                                       DoAutorefArg);
         }
         ast::expr_unary(_, subexpr) => {
             // if not overloaded, would be RvalueDatumExpr
-            return trans_overloaded_op(bcx, expr, subexpr, ~[], dest);
+            return trans_overloaded_op(bcx, expr, subexpr, ~[], dest,
+                                       DontAutorefArg);
         }
         ast::expr_index(base, idx) => {
             // if not overloaded, would be RvalueDatumExpr
-            return trans_overloaded_op(bcx, expr, base, ~[idx], dest);
+            return trans_overloaded_op(bcx, expr, base, ~[idx], dest,
+                                       DontAutorefArg);
         }
         ast::expr_cast(val, _) => {
             return meth::trans_trait_cast(bcx, val, expr.id, dest);
@@ -1302,7 +1320,8 @@ fn trans_overloaded_op(bcx: block,
                        expr: @ast::expr,
                        rcvr: @ast::expr,
                        +args: ~[@ast::expr],
-                       dest: Dest) -> block
+                       dest: Dest,
+                       +autoref_arg: AutorefArg) -> block
 {
     let origin = bcx.ccx().maps.method_map.get(expr.id);
     let fty = node_id_type(bcx, expr.callee_id);
@@ -1310,7 +1329,7 @@ fn trans_overloaded_op(bcx: block,
         bcx, expr.info(), fty,
         expr_ty(bcx, expr),
         |bcx| meth::trans_method_callee(bcx, expr.callee_id, rcvr, origin),
-        callee::ArgExprs(args), dest);
+        callee::ArgExprs(args), dest, autoref_arg);
 }
 
 fn int_cast(bcx: block, lldsttype: TypeRef, llsrctype: TypeRef,
@@ -1347,6 +1366,7 @@ enum cast_kind {
     cast_other,
 }
 
+#[cfg(stage0)]
 impl cast_kind : cmp::Eq {
     pure fn eq(&&other: cast_kind) -> bool {
         match (self, other) {
@@ -1364,6 +1384,25 @@ impl cast_kind : cmp::Eq {
     }
     pure fn ne(&&other: cast_kind) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl cast_kind : cmp::Eq {
+    pure fn eq(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,
+        }
+    }
+    pure fn ne(other: &cast_kind) -> bool { !self.eq(other) }
+}
 
 fn cast_type_kind(t: ty::t) -> cast_kind {
     match ty::get(t).sty {
@@ -1461,7 +1500,7 @@ fn trans_assign_op(bcx: block,
         // FIXME(#2582) evaluates the receiver twice!!
         let scratch = scratch_datum(bcx, dst_datum.ty, false);
         let bcx = trans_overloaded_op(bcx, expr, dst, ~[src],
-                                      SaveIn(scratch.val));
+                                      SaveIn(scratch.val), DoAutorefArg);
         return scratch.move_to_datum(bcx, DROP_EXISTING, dst_datum);
     }
 
index cd762f135bb476563cf1afc406101e0e2955f7da..71c342101d0d63116739c945227bbaae225d579a 100644 (file)
@@ -40,12 +40,21 @@ enum x86_64_reg_class {
     memory_class
 }
 
+#[cfg(stage0)]
 impl x86_64_reg_class: cmp::Eq {
     pure fn eq(&&other: x86_64_reg_class) -> bool {
         (self as uint) == (other as uint)
     }
     pure fn ne(&&other: x86_64_reg_class) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl x86_64_reg_class : cmp::Eq {
+    pure fn eq(other: &x86_64_reg_class) -> bool {
+        (self as uint) == ((*other) as uint)
+    }
+    pure fn ne(other: &x86_64_reg_class) -> bool { !self.eq(other) }
+}
 
 fn is_sse(++c: x86_64_reg_class) -> bool {
     return match c {
@@ -974,7 +983,7 @@ fn trans_intrinsic(ccx: @crate_ctxt, decl: ValueRef, item: @ast::foreign_item,
             bcx = trans_call_inner(
                 bcx, None, fty, ty::mk_nil(bcx.tcx()),
                 |bcx| Callee {bcx: bcx, data: Closure(datum)},
-                ArgVals(~[frameaddress_val]), Ignore);
+                ArgVals(~[frameaddress_val]), Ignore, DontAutorefArg);
         }
         ~"morestack_addr" => {
             // XXX This is a hack to grab the address of this particular
index 1c973620ba29915ba11f1f91e202446186fd9ca8..82843d431a4e2f12356b3363ae95086a2ec88c60 100644 (file)
@@ -99,7 +99,7 @@ fn trans_self_arg(bcx: block, base: @ast::expr,
     let self_arg = {mode: mentry.self_arg.mode,
                     ty: monomorphize_type(bcx, mentry.self_arg.ty)};
     let result = trans_arg_expr(bcx, self_arg, base,
-                                &mut temp_cleanups, None);
+                                &mut temp_cleanups, None, DontAutorefArg);
 
     // FIXME(#3446)---this is wrong, actually.  The temp_cleanups
     // should be revoked only after all arguments have been passed.
index 149a751c41fcee3848cc36ac25b99746560c02d3..8ef9cad4964151ebae424a65251b8382872fa897 100644 (file)
@@ -10,7 +10,7 @@
 use ast::def_id;
 use util::ppaux::ty_to_str;
 use datum::*;
-use callee::ArgVals;
+use callee::{ArgVals, DontAutorefArg};
 use expr::SaveIn;
 
 enum reflector = {
@@ -74,7 +74,7 @@ fn visit(ty_name: ~str, args: ~[ValueRef]) {
             self.bcx, None, mth_ty, bool_ty,
             |bcx| meth::trans_trait_callee_from_llval(bcx, mth_ty,
                                                       mth_idx, v),
-            ArgVals(args), SaveIn(scratch.val));
+            ArgVals(args), SaveIn(scratch.val), DontAutorefArg);
         let result = scratch.to_value_llval(bcx);
         let next_bcx = sub_block(bcx, ~"next");
         CondBr(bcx, result, next_bcx.llbb, self.final_bcx.llbb);
index bed945815d465378af02ec3dfef328149ddcd300..54cc640cebf83f13175338174bb46acd97972cca 100644 (file)
@@ -26,6 +26,7 @@
                     tps: ~[ty::t]};
 type nominal_id = @nominal_id_;
 
+#[cfg(stage0)]
 impl nominal_id_ : core::cmp::Eq {
     pure fn eq(&&other: nominal_id_) -> bool {
         if self.did != other.did ||
@@ -41,6 +42,23 @@ impl nominal_id_ : core::cmp::Eq {
         ! (self == other)
     }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl nominal_id_ : core::cmp::Eq {
+    pure fn eq(other: &nominal_id_) -> bool {
+        if self.did != other.did ||
+            self.parent_id != other.parent_id {
+            false
+        } else {
+            do vec::all2(self.tps, other.tps) |m_tp, n_tp| {
+                ty::type_id(m_tp) == ty::type_id(n_tp)
+            }
+        }
+    }
+    pure fn ne(other: &nominal_id_) -> bool {
+        ! (self == *other)
+    }
+}
 
 impl nominal_id_ : to_bytes::IterBytes {
     pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) {
index 8f9f8fb03ade5dc482716fdd1305f18536e98593..ca8680fd8d5404cfa0d8600b9e62032dc75c402b 100644 (file)
@@ -235,6 +235,7 @@ enum vstore {
 type creader_cache_key = {cnum: int, pos: uint, len: uint};
 type creader_cache = HashMap<creader_cache_key, t>;
 
+#[cfg(stage0)]
 impl creader_cache_key : cmp::Eq {
     pure fn eq(&&other: creader_cache_key) -> bool {
         self.cnum == other.cnum &&
@@ -245,6 +246,18 @@ impl creader_cache_key : cmp::Eq {
         !(self == other)
     }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl creader_cache_key : cmp::Eq {
+    pure fn eq(other: &creader_cache_key) -> bool {
+        self.cnum == (*other).cnum &&
+            self.pos == (*other).pos &&
+            self.len == (*other).len
+    }
+    pure fn ne(other: &creader_cache_key) -> bool {
+        !(self == (*other))
+    }
+}
 
 impl creader_cache_key : to_bytes::IterBytes {
     pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) {
@@ -254,12 +267,21 @@ impl creader_cache_key : to_bytes::IterBytes {
 
 type intern_key = {sty: sty, o_def_id: Option<ast::def_id>};
 
+#[cfg(stage0)]
 impl intern_key: cmp::Eq {
     pure fn eq(&&other: intern_key) -> bool {
         self.sty == other.sty && self.o_def_id == other.o_def_id
     }
     pure fn ne(&&other: intern_key) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl intern_key : cmp::Eq {
+    pure fn eq(other: &intern_key) -> bool {
+        self.sty == (*other).sty && self.o_def_id == (*other).o_def_id
+    }
+    pure fn ne(other: &intern_key) -> bool { !self.eq(other) }
+}
 
 impl intern_key : to_bytes::IterBytes {
     pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) {
@@ -278,6 +300,7 @@ enum ast_ty_to_ty_cache_entry {
 #[auto_serialize]
 enum region_variance { rv_covariant, rv_invariant, rv_contravariant }
 
+#[cfg(stage0)]
 impl region_variance: cmp::Eq {
     pure fn eq(&&other: region_variance) -> bool {
         match (self, other) {
@@ -291,6 +314,21 @@ impl region_variance: cmp::Eq {
     }
     pure fn ne(&&other: region_variance) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl region_variance : cmp::Eq {
+    pure fn eq(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
+        }
+    }
+    pure fn ne(other: &region_variance) -> bool { !self.eq(other) }
+}
 
 #[auto_serialize]
 type AutoAdjustment = {
@@ -410,12 +448,21 @@ impl closure_kind : to_bytes::IterBytes {
     }
 }
 
+#[cfg(stage0)]
 impl closure_kind : cmp::Eq {
     pure fn eq(&&other: closure_kind) -> bool {
         (self as uint) == (other as uint)
     }
     pure fn ne(&&other: closure_kind) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl closure_kind : cmp::Eq {
+    pure fn eq(other: &closure_kind) -> bool {
+        (self as uint) == ((*other) as uint)
+    }
+    pure fn ne(other: &closure_kind) -> bool { !self.eq(other) }
+}
 
 enum fn_proto {
     proto_bare,             // supertype of all other protocols
@@ -434,6 +481,7 @@ impl fn_proto : to_bytes::IterBytes {
     }
 }
 
+#[cfg(stage0)]
 impl fn_proto : cmp::Eq {
     pure fn eq(&&other: fn_proto) -> bool {
         match self {
@@ -453,6 +501,27 @@ impl fn_proto : cmp::Eq {
     }
     pure fn ne(&&other: fn_proto) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl fn_proto : cmp::Eq {
+    pure fn eq(other: &fn_proto) -> bool {
+        match self {
+            proto_bare => {
+                match (*other) {
+                    proto_bare => true,
+                    _ => false
+                }
+            }
+            proto_vstore(e0a) => {
+                match (*other) {
+                    proto_vstore(e0b) => e0a == e0b,
+                    _ => false
+                }
+            }
+        }
+    }
+    pure fn ne(other: &fn_proto) -> bool { !self.eq(other) }
+}
 
 /**
  * Meta information about a closure.
@@ -493,12 +562,21 @@ struct FnTyBase<M: cmp::Eq> {
 
 type param_ty = {idx: uint, def_id: def_id};
 
+#[cfg(stage0)]
 impl param_ty: cmp::Eq {
     pure fn eq(&&other: param_ty) -> bool {
         self.idx == other.idx && self.def_id == other.def_id
     }
     pure fn ne(&&other: param_ty) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl param_ty : cmp::Eq {
+    pure fn eq(other: &param_ty) -> bool {
+        self.idx == (*other).idx && self.def_id == (*other).def_id
+    }
+    pure fn ne(other: &param_ty) -> bool { !self.eq(other) }
+}
 
 impl param_ty : to_bytes::IterBytes {
     pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) {
@@ -1816,6 +1894,7 @@ fn remove_copyable(k: kind) -> kind {
     k - kind_(KIND_MASK_COPY | KIND_MASK_DEFAULT_MODE)
 }
 
+#[cfg(stage0)]
 impl kind: ops::BitAnd<kind,kind> {
     pure fn bitand(other: kind) -> kind {
         unsafe {
@@ -1823,7 +1902,17 @@ impl kind: ops::BitAnd<kind,kind> {
         }
     }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl kind : ops::BitAnd<kind,kind> {
+    pure fn bitand(other: &kind) -> kind {
+        unsafe {
+            lower_kind(self, (*other))
+        }
+    }
+}
 
+#[cfg(stage0)]
 impl kind: ops::BitOr<kind,kind> {
     pure fn bitor(other: kind) -> kind {
         unsafe {
@@ -1831,7 +1920,17 @@ impl kind: ops::BitOr<kind,kind> {
         }
     }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl kind : ops::BitOr<kind,kind> {
+    pure fn bitor(other: &kind) -> kind {
+        unsafe {
+            raise_kind(self, (*other))
+        }
+    }
+}
 
+#[cfg(stage0)]
 impl kind: ops::Sub<kind,kind> {
     pure fn sub(other: kind) -> kind {
         unsafe {
@@ -1839,6 +1938,15 @@ impl kind: ops::Sub<kind,kind> {
         }
     }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl kind : ops::Sub<kind,kind> {
+    pure fn sub(other: &kind) -> kind {
+        unsafe {
+            kind_(*self & !*(*other))
+        }
+    }
+}
 
 // Using these query functions is preferable to direct comparison or matching
 // against the kind constants, as we may modify the kind hierarchy in the
@@ -3932,27 +4040,55 @@ fn eval_repeat_count(tcx: ctxt, count_expr: @ast::expr, span: span) -> uint {
     } else { child_purity }
 }
 
+#[cfg(stage0)]
 impl mt : cmp::Eq {
     pure fn eq(&&other: mt) -> bool {
         self.ty == other.ty && self.mutbl == other.mutbl
     }
     pure fn ne(&&other: mt) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl mt : cmp::Eq {
+    pure fn eq(other: &mt) -> bool {
+        self.ty == (*other).ty && self.mutbl == (*other).mutbl
+    }
+    pure fn ne(other: &mt) -> bool { !self.eq(other) }
+}
 
+#[cfg(stage0)]
 impl arg : cmp::Eq {
     pure fn eq(&&other: arg) -> bool {
         self.mode == other.mode && self.ty == other.ty
     }
     pure fn ne(&&other: arg) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl arg : cmp::Eq {
+    pure fn eq(other: &arg) -> bool {
+        self.mode == (*other).mode && self.ty == (*other).ty
+    }
+    pure fn ne(other: &arg) -> bool { !self.eq(other) }
+}
 
+#[cfg(stage0)]
 impl field : cmp::Eq {
     pure fn eq(&&other: field) -> bool {
         self.ident == other.ident && self.mt == other.mt
     }
     pure fn ne(&&other: field) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl field : cmp::Eq {
+    pure fn eq(other: &field) -> bool {
+        self.ident == (*other).ident && self.mt == (*other).mt
+    }
+    pure fn ne(other: &field) -> bool { !self.eq(other) }
+}
 
+#[cfg(stage0)]
 impl vstore : cmp::Eq {
     pure fn eq(&&other: vstore) -> bool {
         match self {
@@ -3984,7 +4120,41 @@ impl vstore : cmp::Eq {
     }
     pure fn ne(&&other: vstore) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl vstore : cmp::Eq {
+    pure fn eq(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
+                }
+            }
+        }
+    }
+    pure fn ne(other: &vstore) -> bool { !self.eq(other) }
+}
 
+#[cfg(stage0)]
 impl FnMeta : cmp::Eq {
     pure fn eq(&&other: FnMeta) -> bool {
         self.purity == other.purity &&
@@ -3994,7 +4164,19 @@ impl FnMeta : cmp::Eq {
     }
     pure fn ne(&&other: FnMeta) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl FnMeta : cmp::Eq {
+    pure fn eq(other: &FnMeta) -> bool {
+        self.purity == (*other).purity &&
+        self.proto == (*other).proto &&
+        self.bounds == (*other).bounds &&
+        self.ret_style == (*other).ret_style
+    }
+    pure fn ne(other: &FnMeta) -> bool { !self.eq(other) }
+}
 
+#[cfg(stage0)]
 impl FnSig : cmp::Eq {
     pure fn eq(&&other: FnSig) -> bool {
         self.inputs == other.inputs &&
@@ -4002,34 +4184,81 @@ impl FnSig : cmp::Eq {
     }
     pure fn ne(&&other: FnSig) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl FnSig : cmp::Eq {
+    pure fn eq(other: &FnSig) -> bool {
+        self.inputs == (*other).inputs &&
+        self.output == (*other).output
+    }
+    pure fn ne(other: &FnSig) -> bool { !self.eq(other) }
+}
 
+#[cfg(stage0)]
 impl<M: cmp::Eq> FnTyBase<M> : cmp::Eq {
     pure fn eq(&&other: FnTyBase<M>) -> bool {
         self.meta == other.meta && self.sig == other.sig
     }
     pure fn ne(&&other: FnTyBase<M>) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl<M: cmp::Eq> FnTyBase<M> : cmp::Eq {
+    pure fn eq(other: &FnTyBase<M>) -> bool {
+        self.meta == (*other).meta && self.sig == (*other).sig
+    }
+    pure fn ne(other: &FnTyBase<M>) -> bool { !self.eq(other) }
+}
 
+#[cfg(stage0)]
 impl TyVid: cmp::Eq {
     pure fn eq(&&other: TyVid) -> bool { *self == *other }
     pure fn ne(&&other: TyVid) -> bool { *self != *other }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl TyVid : cmp::Eq {
+    pure fn eq(other: &TyVid) -> bool { *self == *(*other) }
+    pure fn ne(other: &TyVid) -> bool { *self != *(*other) }
+}
 
+#[cfg(stage0)]
 impl IntVid: cmp::Eq {
     pure fn eq(&&other: IntVid) -> bool { *self == *other }
     pure fn ne(&&other: IntVid) -> bool { *self != *other }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl IntVid : cmp::Eq {
+    pure fn eq(other: &IntVid) -> bool { *self == *(*other) }
+    pure fn ne(other: &IntVid) -> bool { *self != *(*other) }
+}
 
+#[cfg(stage0)]
 impl FnVid: cmp::Eq {
     pure fn eq(&&other: FnVid) -> bool { *self == *other }
     pure fn ne(&&other: FnVid) -> bool { *self != *other }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl FnVid : cmp::Eq {
+    pure fn eq(other: &FnVid) -> bool { *self == *(*other) }
+    pure fn ne(other: &FnVid) -> bool { *self != *(*other) }
+}
 
+#[cfg(stage0)]
 impl RegionVid: cmp::Eq {
     pure fn eq(&&other: RegionVid) -> bool { *self == *other }
     pure fn ne(&&other: RegionVid) -> bool { *self != *other }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl RegionVid : cmp::Eq {
+    pure fn eq(other: &RegionVid) -> bool { *self == *(*other) }
+    pure fn ne(other: &RegionVid) -> bool { *self != *(*other) }
+}
 
+#[cfg(stage0)]
 impl region : cmp::Eq {
     pure fn eq(&&other: region) -> bool {
         match self {
@@ -4067,7 +4296,47 @@ impl region : cmp::Eq {
     }
     pure fn ne(&&other: region) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl region : cmp::Eq {
+    pure fn eq(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_var(e0a) => {
+                match (*other) {
+                    re_var(e0b) => e0a == e0b,
+                    _ => false
+                }
+            }
+        }
+    }
+    pure fn ne(other: &region) -> bool { !self.eq(other) }
+}
 
+#[cfg(stage0)]
 impl bound_region : cmp::Eq {
     pure fn eq(&&other: bound_region) -> bool {
         match self {
@@ -4099,7 +4368,41 @@ impl bound_region : cmp::Eq {
     }
     pure fn ne(&&other: bound_region) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl bound_region : cmp::Eq {
+    pure fn eq(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
+                }
+            }
+        }
+    }
+    pure fn ne(other: &bound_region) -> bool { !self.eq(other) }
+}
 
+#[cfg(stage0)]
 impl substs : cmp::Eq {
     pure fn eq(&&other: substs) -> bool {
         self.self_r == other.self_r &&
@@ -4108,14 +4411,34 @@ impl substs : cmp::Eq {
     }
     pure fn ne(&&other: substs) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl substs : cmp::Eq {
+    pure fn eq(other: &substs) -> bool {
+        self.self_r == (*other).self_r &&
+        self.self_ty == (*other).self_ty &&
+        self.tps == (*other).tps
+    }
+    pure fn ne(other: &substs) -> bool { !self.eq(other) }
+}
 
+#[cfg(stage0)]
 impl InferTy : cmp::Eq {
     pure fn eq(&&other: InferTy) -> bool {
         self.to_hash() == other.to_hash()
     }
     pure fn ne(&&other: InferTy) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl InferTy : cmp::Eq {
+    pure fn eq(other: &InferTy) -> bool {
+        self.to_hash() == (*other).to_hash()
+    }
+    pure fn ne(other: &InferTy) -> bool { !self.eq(other) }
+}
 
+#[cfg(stage0)]
 impl sty : cmp::Eq {
     pure fn eq(&&other: sty) -> bool {
         match self {
@@ -4274,7 +4597,168 @@ impl sty : cmp::Eq {
     }
     pure fn ne(&&other: sty) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl sty : cmp::Eq {
+    pure fn eq(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
+                }
+            }
+        }
+    }
+    pure fn ne(other: &sty) -> bool { !self.eq(other) }
+}
 
+#[cfg(stage0)]
 impl param_bound : cmp::Eq {
     pure fn eq(&&other: param_bound) -> bool {
         match self {
@@ -4312,11 +4796,57 @@ impl param_bound : cmp::Eq {
     }
     pure fn ne(&&other: param_bound) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl param_bound : cmp::Eq {
+    pure fn eq(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
+                }
+            }
+        }
+    }
+    pure fn ne(other: &param_bound) -> bool { !self.eq(other) }
+}
 
+#[cfg(stage0)]
 impl kind : cmp::Eq {
     pure fn eq(&&other: kind) -> bool { *self == *other }
     pure fn ne(&&other: kind) -> bool { *self != *other }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl kind : cmp::Eq {
+    pure fn eq(other: &kind) -> bool { *self == *(*other) }
+    pure fn ne(other: &kind) -> bool { *self != *(*other) }
+}
 
 
 // Local Variables:
index b7cdbbb8571b2cf8fa65214f00eddab87f860636..932e32762a6e8f4b9e5576b65f80b0723e43e090 100644 (file)
@@ -940,6 +940,13 @@ 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 {
+    DontDerefArgs,
+    DoDerefArgs
+}
+
 fn check_expr_with_unifier(fcx: @fn_ctxt,
                            expr: @ast::expr,
                            expected: Option<ty::t>,
@@ -955,7 +962,8 @@ fn check_call_inner(
         call_expr_id: ast::node_id,
         in_fty: ty::t,
         callee_expr: @ast::expr,
-        args: ~[@ast::expr]) -> {fty: ty::t, bot: bool} {
+        args: ~[@ast::expr],
+        deref_args: DerefArgs) -> {fty: ty::t, bot: bool} {
 
         let mut bot = false;
 
@@ -1043,7 +1051,20 @@ fn check_call_inner(
 
                 if is_block == check_blocks {
                     debug!("checking the argument");
-                    let formal_ty = formal_tys[i];
+                    let mut formal_ty = formal_tys[i];
+
+                    match deref_args {
+                        DoDerefArgs => {
+                            match ty::get(formal_ty).sty {
+                                ty::ty_rptr(_, mt) => formal_ty = mt.ty,
+                                _ => {
+                                    fcx.ccx.tcx.sess.span_bug(arg.span,
+                                                              ~"no ref");
+                                }
+                            }
+                        }
+                        DontDerefArgs => {}
+                    }
 
                     bot |= check_expr_with_unifier(
                         fcx, arg, Some(formal_ty),
@@ -1082,7 +1103,7 @@ fn check_call(fcx: @fn_ctxt, sp: span, call_expr_id: ast::node_id,
         // Call the generic checker.
         let fty = {
             let r = check_call_inner(fcx, sp, call_expr_id,
-                                     fn_ty, f, args);
+                                     fn_ty, f, args, DontDerefArgs);
             bot |= r.bot;
             r.fty
         };
@@ -1138,7 +1159,8 @@ fn check_then_else(fcx: @fn_ctxt, thn: ast::blk,
 
     fn lookup_op_method(fcx: @fn_ctxt, op_ex: @ast::expr,
                         self_ex: @ast::expr, self_t: ty::t,
-                        opname: ast::ident, args: ~[@ast::expr])
+                        opname: ast::ident, args: ~[@ast::expr],
+                        +deref_args: DerefArgs)
         -> Option<(ty::t, bool)>
     {
         match method::lookup(fcx, op_ex, self_ex,
@@ -1147,7 +1169,7 @@ fn lookup_op_method(fcx: @fn_ctxt, op_ex: @ast::expr,
             let {fty: method_ty, bot: bot} = {
                 let method_ty = fcx.node_ty(op_ex.callee_id);
                 check_call_inner(fcx, op_ex.span, op_ex.id,
-                                 method_ty, op_ex, args)
+                                 method_ty, op_ex, args, deref_args)
             };
             fcx.ccx.method_map.insert(op_ex.id, origin);
             Some((ty::ty_fn_ret(method_ty), bot))
@@ -1182,7 +1204,8 @@ fn check_binop(fcx: @fn_ctxt, expr: @ast::expr,
             let rhs_bot = check_expr_with(fcx, rhs, tvar);
 
             let result_t = match op {
-                ast::eq | ast::ne | ast::lt | ast::le | ast::ge | ast::gt => {
+                ast::eq | ast::ne | ast::lt | ast::le | ast::ge |
+                ast::gt => {
                     ty::mk_bool(tcx)
                 }
                 _ => {
@@ -1212,7 +1235,7 @@ fn check_user_binop(fcx: @fn_ctxt, ex: @ast::expr,
           Some(name) => {
             match lookup_op_method(fcx, ex, lhs_expr, lhs_resolved_t,
                                    fcx.tcx().sess.ident_of(name),
-                                   ~[rhs]) {
+                                   ~[rhs], DoDerefArgs) {
               Some(pair) => return pair,
               _ => ()
             }
@@ -1246,7 +1269,8 @@ fn check_user_unop(fcx: @fn_ctxt, op_str: ~str, mname: ~str,
                        ex: @ast::expr,
                        rhs_expr: @ast::expr, rhs_t: ty::t) -> ty::t {
         match lookup_op_method(fcx, ex, rhs_expr, rhs_t,
-                               fcx.tcx().sess.ident_of(mname), ~[]) {
+                               fcx.tcx().sess.ident_of(mname), ~[],
+                               DontDerefArgs) {
           Some((ret_ty, _)) => ret_ty,
           _ => {
             fcx.ccx.tcx.sess.span_err(
@@ -2054,7 +2078,7 @@ fn get_node(f: spanned<field>) -> field { f.node }
                                                             raw_base_t);
                   match lookup_op_method(fcx, expr, base, resolved,
                                          tcx.sess.ident_of(~"index"),
-                                         ~[idx]) {
+                                         ~[idx], DontDerefArgs) {
                       Some((ret_ty, _)) => fcx.write_ty(id, ret_ty),
                       _ => {
                           tcx.sess.span_fatal(
index 02e170d575e93619f1aa72e08d0a83a85e076287..de99046412535fb2bd3314b18d2ac79e41d45b34 100644 (file)
@@ -329,6 +329,7 @@ enum Constraint {
     ConstrainVarSubReg(RegionVid, region)
 }
 
+#[cfg(stage0)]
 impl Constraint: cmp::Eq {
     pure fn eq(&&other: Constraint) -> bool {
         match (self, other) {
@@ -348,6 +349,27 @@ impl Constraint: cmp::Eq {
     }
     pure fn ne(&&other: Constraint) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl Constraint : cmp::Eq {
+    pure fn eq(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
+        }
+    }
+    pure fn ne(other: &Constraint) -> bool { !self.eq(other) }
+}
 
 impl Constraint : to_bytes::IterBytes {
    pure  fn iter_bytes(lsb0: bool, f: to_bytes::Cb) {
@@ -369,12 +391,21 @@ struct TwoRegions {
     b: region,
 }
 
+#[cfg(stage0)]
 impl TwoRegions: cmp::Eq {
     pure fn eq(&&other: TwoRegions) -> bool {
         self.a == other.a && self.b == other.b
     }
     pure fn ne(&&other: TwoRegions) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl TwoRegions : cmp::Eq {
+    pure fn eq(other: &TwoRegions) -> bool {
+        self.a == (*other).a && self.b == (*other).b
+    }
+    pure fn ne(other: &TwoRegions) -> bool { !self.eq(other) }
+}
 
 impl TwoRegions : to_bytes::IterBytes {
     pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) {
@@ -755,21 +786,39 @@ fn report_type_error(span: span, terr: &ty::type_err) {
 
 enum Direction { Incoming = 0, Outgoing = 1 }
 
+#[cfg(stage0)]
 impl Direction : cmp::Eq {
     pure fn eq(&&other: Direction) -> bool {
         (self as uint) == (other as uint)
     }
     pure fn ne(&&other: Direction) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl Direction : cmp::Eq {
+    pure fn eq(other: &Direction) -> bool {
+        (self as uint) == ((*other) as uint)
+    }
+    pure fn ne(other: &Direction) -> bool { !self.eq(other) }
+}
 
 enum Classification { Expanding, Contracting }
 
+#[cfg(stage0)]
 impl Classification : cmp::Eq {
     pure fn eq(&&other: Classification) -> bool {
         (self as uint) == (other as uint)
     }
     pure fn ne(&&other: Classification) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl Classification : cmp::Eq {
+    pure fn eq(other: &Classification) -> bool {
+        (self as uint) == ((*other) as uint)
+    }
+    pure fn ne(other: &Classification) -> bool { !self.eq(other) }
+}
 
 enum GraphNodeValue { NoValue, Value(region), ErrorValue }
 
index 9c34b0629615c1f20845a30af7480e4a46c1d3d7..2dddc42b50c5a108f2f110d21d8ce94d125da0cf 100644 (file)
@@ -18,12 +18,21 @@ enum OutputFormat {
     PandocHtml
 }
 
+#[cfg(stage0)]
 impl OutputFormat : cmp::Eq {
     pure fn eq(&&other: OutputFormat) -> bool {
         (self as uint) == (other as uint)
     }
     pure fn ne(&&other: OutputFormat) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl OutputFormat : cmp::Eq {
+    pure fn eq(other: &OutputFormat) -> bool {
+        (self as uint) == ((*other) as uint)
+    }
+    pure fn ne(other: &OutputFormat) -> bool { !self.eq(other) }
+}
 
 /// How to organize the output
 enum OutputStyle {
@@ -33,12 +42,21 @@ enum OutputStyle {
     DocPerMod
 }
 
+#[cfg(stage0)]
 impl OutputStyle : cmp::Eq {
     pure fn eq(&&other: OutputStyle) -> bool {
         (self as uint) == (other as uint)
     }
     pure fn ne(&&other: OutputStyle) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl OutputStyle : cmp::Eq {
+    pure fn eq(other: &OutputStyle) -> bool {
+        (self as uint) == ((*other) as uint)
+    }
+    pure fn ne(other: &OutputStyle) -> bool { !self.eq(other) }
+}
 
 /// The configuration for a rustdoc session
 type Config = {
index 5d758fd061249a2d97fec5f522879f558ad7aabd..126ea10c30108b96355a86d9ce848dea1b25a0ce 100644 (file)
@@ -6,27 +6,44 @@
     pages: ~[Page]
 };
 
+#[cfg(stage0)]
 impl Doc_ : cmp::Eq {
     pure fn eq(&&other: Doc_) -> bool {
         self.pages == other.pages
     }
     pure fn ne(&&other: Doc_) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl Doc_ : cmp::Eq {
+    pure fn eq(other: &Doc_) -> bool {
+        self.pages == (*other).pages
+    }
+    pure fn ne(other: &Doc_) -> bool { !self.eq(other) }
+}
 
 enum Doc {
     Doc_(Doc_)
 }
 
+#[cfg(stage0)]
 impl Doc : cmp::Eq {
     pure fn eq(&&other: Doc) -> bool { *self == *other }
     pure fn ne(&&other: Doc) -> bool { *self != *other }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl Doc : cmp::Eq {
+    pure fn eq(other: &Doc) -> bool { *self == *(*other) }
+    pure fn ne(other: &Doc) -> bool { *self != *(*other) }
+}
 
 enum Page {
     CratePage(CrateDoc),
     ItemPage(ItemTag)
 }
 
+#[cfg(stage0)]
 impl Page : cmp::Eq {
     pure fn eq(&&other: Page) -> bool {
         match self {
@@ -46,18 +63,48 @@ impl Page : cmp::Eq {
     }
     pure fn ne(&&other: Page) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl Page : cmp::Eq {
+    pure fn eq(other: &Page) -> bool {
+        match self {
+            CratePage(e0a) => {
+                match (*other) {
+                    CratePage(e0b) => e0a == e0b,
+                    _ => false
+                }
+            }
+            ItemPage(e0a) => {
+                match (*other) {
+                    ItemPage(e0b) => e0a == e0b,
+                    _ => false
+                }
+            }
+        }
+    }
+    pure fn ne(other: &Page) -> bool { !self.eq(other) }
+}
 
 enum Implementation {
     Required,
     Provided,
 }
 
+#[cfg(stage0)]
 impl Implementation : cmp::Eq {
     pure fn eq(&&other: Implementation) -> bool {
         (self as uint) == (other as uint)
     }
     pure fn ne(&&other: Implementation) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl Implementation : cmp::Eq {
+    pure fn eq(other: &Implementation) -> bool {
+        (self as uint) == ((*other) as uint)
+    }
+    pure fn ne(other: &Implementation) -> bool { !self.eq(other) }
+}
 
 
 /**
@@ -69,12 +116,21 @@ impl Implementation : cmp::Eq {
     body: ~str
 };
 
+#[cfg(stage0)]
 impl Section : cmp::Eq {
     pure fn eq(&&other: Section) -> bool {
         self.header == other.header && self.body == other.body
     }
     pure fn ne(&&other: Section) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl Section : cmp::Eq {
+    pure fn eq(other: &Section) -> bool {
+        self.header == (*other).header && self.body == (*other).body
+    }
+    pure fn ne(other: &Section) -> bool { !self.eq(other) }
+}
 
 // FIXME (#2596): We currently give topmod the name of the crate.  There
 // would probably be fewer special cases if the crate had its own name
@@ -83,12 +139,21 @@ impl Section : cmp::Eq {
     topmod: ModDoc,
 };
 
+#[cfg(stage0)]
 impl CrateDoc : cmp::Eq {
     pure fn eq(&&other: CrateDoc) -> bool {
         self.topmod == other.topmod
     }
     pure fn ne(&&other: CrateDoc) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl CrateDoc : cmp::Eq {
+    pure fn eq(other: &CrateDoc) -> bool {
+        self.topmod == (*other).topmod
+    }
+    pure fn ne(other: &CrateDoc) -> bool { !self.eq(other) }
+}
 
 enum ItemTag {
     ModTag(ModDoc),
@@ -102,6 +167,7 @@ enum ItemTag {
     StructTag(StructDoc)
 }
 
+#[cfg(stage0)]
 impl ItemTag : cmp::Eq {
     pure fn eq(&&other: ItemTag) -> bool {
         match self {
@@ -163,6 +229,69 @@ impl ItemTag : cmp::Eq {
     }
     pure fn ne(&&other: ItemTag) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl ItemTag : cmp::Eq {
+    pure fn eq(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
+                }
+            }
+        }
+    }
+    pure fn ne(other: &ItemTag) -> bool { !self.eq(other) }
+}
 
 type ItemDoc = {
     id: AstId,
@@ -175,6 +304,7 @@ impl ItemTag : cmp::Eq {
     reexport: bool
 };
 
+#[cfg(stage0)]
 impl ItemDoc : cmp::Eq {
     pure fn eq(&&other: ItemDoc) -> bool {
         self.id == other.id &&
@@ -187,18 +317,41 @@ impl ItemDoc : cmp::Eq {
     }
     pure fn ne(&&other: ItemDoc) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl ItemDoc : cmp::Eq {
+    pure fn eq(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
+    }
+    pure fn ne(other: &ItemDoc) -> bool { !self.eq(other) }
+}
 
 type SimpleItemDoc = {
     item: ItemDoc,
     sig: Option<~str>
 };
 
+#[cfg(stage0)]
 impl SimpleItemDoc : cmp::Eq {
     pure fn eq(&&other: SimpleItemDoc) -> bool {
         self.item == other.item && self.sig == other.sig
     }
     pure fn ne(&&other: SimpleItemDoc) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl SimpleItemDoc : cmp::Eq {
+    pure fn eq(other: &SimpleItemDoc) -> bool {
+        self.item == (*other).item && self.sig == (*other).sig
+    }
+    pure fn ne(other: &SimpleItemDoc) -> bool { !self.eq(other) }
+}
 
 type ModDoc_ = {
     item: ItemDoc,
@@ -206,6 +359,7 @@ impl SimpleItemDoc : cmp::Eq {
     index: Option<Index>
 };
 
+#[cfg(stage0)]
 impl ModDoc_ : cmp::Eq {
     pure fn eq(&&other: ModDoc_) -> bool {
         self.item == other.item &&
@@ -214,15 +368,32 @@ impl ModDoc_ : cmp::Eq {
     }
     pure fn ne(&&other: ModDoc_) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl ModDoc_ : cmp::Eq {
+    pure fn eq(other: &ModDoc_) -> bool {
+        self.item == (*other).item &&
+        self.items == (*other).items &&
+        self.index == (*other).index
+    }
+    pure fn ne(other: &ModDoc_) -> bool { !self.eq(other) }
+}
 
 enum ModDoc {
     ModDoc_(ModDoc_)
 }
 
+#[cfg(stage0)]
 impl ModDoc : cmp::Eq {
     pure fn eq(&&other: ModDoc) -> bool { *self == *other }
     pure fn ne(&&other: ModDoc) -> bool { *self != *other }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl ModDoc : cmp::Eq {
+    pure fn eq(other: &ModDoc) -> bool { *self == *(*other) }
+    pure fn ne(other: &ModDoc) -> bool { *self != *(*other) }
+}
 
 type NmodDoc = {
     item: ItemDoc,
@@ -230,6 +401,7 @@ impl ModDoc : cmp::Eq {
     index: Option<Index>
 };
 
+#[cfg(stage0)]
 impl NmodDoc : cmp::Eq {
     pure fn eq(&&other: NmodDoc) -> bool {
         self.item == other.item &&
@@ -238,6 +410,16 @@ impl NmodDoc : cmp::Eq {
     }
     pure fn ne(&&other: NmodDoc) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl NmodDoc : cmp::Eq {
+    pure fn eq(other: &NmodDoc) -> bool {
+        self.item == (*other).item &&
+        self.fns == (*other).fns &&
+        self.index == (*other).index
+    }
+    pure fn ne(other: &NmodDoc) -> bool { !self.eq(other) }
+}
 
 type ConstDoc = SimpleItemDoc;
 
@@ -248,12 +430,21 @@ impl NmodDoc : cmp::Eq {
     variants: ~[VariantDoc]
 };
 
+#[cfg(stage0)]
 impl EnumDoc : cmp::Eq {
     pure fn eq(&&other: EnumDoc) -> bool {
         self.item == other.item && self.variants == other.variants
     }
     pure fn ne(&&other: EnumDoc) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl EnumDoc : cmp::Eq {
+    pure fn eq(other: &EnumDoc) -> bool {
+        self.item == (*other).item && self.variants == (*other).variants
+    }
+    pure fn ne(other: &EnumDoc) -> bool { !self.eq(other) }
+}
 
 type VariantDoc = {
     name: ~str,
@@ -261,6 +452,7 @@ impl EnumDoc : cmp::Eq {
     sig: Option<~str>
 };
 
+#[cfg(stage0)]
 impl VariantDoc : cmp::Eq {
     pure fn eq(&&other: VariantDoc) -> bool {
         self.name == other.name &&
@@ -269,18 +461,37 @@ impl VariantDoc : cmp::Eq {
     }
     pure fn ne(&&other: VariantDoc) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl VariantDoc : cmp::Eq {
+    pure fn eq(other: &VariantDoc) -> bool {
+        self.name == (*other).name &&
+        self.desc == (*other).desc &&
+        self.sig == (*other).sig
+    }
+    pure fn ne(other: &VariantDoc) -> bool { !self.eq(other) }
+}
 
 type TraitDoc = {
     item: ItemDoc,
     methods: ~[MethodDoc]
 };
 
+#[cfg(stage0)]
 impl TraitDoc : cmp::Eq {
     pure fn eq(&&other: TraitDoc) -> bool {
         self.item == other.item && self.methods == other.methods
     }
     pure fn ne(&&other: TraitDoc) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl TraitDoc : cmp::Eq {
+    pure fn eq(other: &TraitDoc) -> bool {
+        self.item == (*other).item && self.methods == (*other).methods
+    }
+    pure fn ne(other: &TraitDoc) -> bool { !self.eq(other) }
+}
 
 type MethodDoc = {
     name: ~str,
@@ -291,6 +502,7 @@ impl TraitDoc : cmp::Eq {
     implementation: Implementation,
 };
 
+#[cfg(stage0)]
 impl MethodDoc : cmp::Eq {
     pure fn eq(&&other: MethodDoc) -> bool {
         self.name == other.name &&
@@ -302,6 +514,19 @@ impl MethodDoc : cmp::Eq {
     }
     pure fn ne(&&other: MethodDoc) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl MethodDoc : cmp::Eq {
+    pure fn eq(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
+    }
+    pure fn ne(other: &MethodDoc) -> bool { !self.eq(other) }
+}
 
 type ImplDoc = {
     item: ItemDoc,
@@ -310,6 +535,7 @@ impl MethodDoc : cmp::Eq {
     methods: ~[MethodDoc]
 };
 
+#[cfg(stage0)]
 impl ImplDoc : cmp::Eq {
     pure fn eq(&&other: ImplDoc) -> bool {
         self.item == other.item &&
@@ -319,6 +545,17 @@ impl ImplDoc : cmp::Eq {
     }
     pure fn ne(&&other: ImplDoc) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl ImplDoc : cmp::Eq {
+    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
+    }
+    pure fn ne(other: &ImplDoc) -> bool { !self.eq(other) }
+}
 
 type TyDoc = SimpleItemDoc;
 
@@ -329,24 +566,33 @@ impl ImplDoc : cmp::Eq {
 };
 
 impl StructDoc : cmp::Eq {
-    pure fn eq(&&other: StructDoc) -> bool {
+    pure fn eq(other: &StructDoc) -> bool {
         return self.item == other.item
             && self.fields == other.fields
             && self.sig == other.sig;
     }
-    pure fn ne(&&other: StructDoc) -> bool { !self.eq(other) }
+    pure fn ne(other: &StructDoc) -> bool { !self.eq(other) }
 }
 
 type Index = {
     entries: ~[IndexEntry]
 };
 
+#[cfg(stage0)]
 impl Index : cmp::Eq {
     pure fn eq(&&other: Index) -> bool {
         self.entries == other.entries
     }
     pure fn ne(&&other: Index) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl Index : cmp::Eq {
+    pure fn eq(other: &Index) -> bool {
+        self.entries == (*other).entries
+    }
+    pure fn ne(other: &Index) -> bool { !self.eq(other) }
+}
 
 /**
  * A single entry in an index
@@ -365,6 +611,7 @@ impl Index : cmp::Eq {
     link: ~str
 };
 
+#[cfg(stage0)]
 impl IndexEntry : cmp::Eq {
     pure fn eq(&&other: IndexEntry) -> bool {
         self.kind == other.kind &&
@@ -374,6 +621,17 @@ impl IndexEntry : cmp::Eq {
     }
     pure fn ne(&&other: IndexEntry) -> bool { !self.eq(other) }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl IndexEntry : cmp::Eq {
+    pure fn eq(other: &IndexEntry) -> bool {
+        self.kind == (*other).kind &&
+        self.name == (*other).name &&
+        self.brief == (*other).brief &&
+        self.link == (*other).link
+    }
+    pure fn ne(other: &IndexEntry) -> bool { !self.eq(other) }
+}
 
 impl Doc {
     fn CrateDoc() -> CrateDoc {
index cc07ea04e7708ed5665a3e77683a5d83d5d0b0cd..b0a4b6469d8d4f8be0490f5962c3beecf572396f 100644 (file)
@@ -23,6 +23,7 @@ struct cmplx {
     im: f64
 }
 
+#[cfg(stage0)]
 impl cmplx : ops::Mul<cmplx,cmplx> {
     pure fn mul(x: cmplx) -> cmplx {
         cmplx {
@@ -31,7 +32,18 @@ impl cmplx : ops::Mul<cmplx,cmplx> {
         }
     }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl cmplx : ops::Mul<cmplx,cmplx> {
+    pure fn mul(x: &cmplx) -> cmplx {
+        cmplx {
+            re: self.re*(*x).re - self.im*(*x).im,
+            im: self.re*(*x).im + self.im*(*x).re
+        }
+    }
+}
 
+#[cfg(stage0)]
 impl cmplx : ops::Add<cmplx,cmplx> {
     pure fn add(x: cmplx) -> cmplx {
         cmplx {
@@ -40,6 +52,16 @@ impl cmplx : ops::Add<cmplx,cmplx> {
         }
     }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl cmplx : ops::Add<cmplx,cmplx> {
+    pure fn add(x: &cmplx) -> cmplx {
+        cmplx {
+            re: self.re + (*x).re,
+            im: self.im + (*x).im
+        }
+    }
+}
 
 type line = {i: uint, b: ~[u8]};
 
index ef7c8da4b1921bf66e38b0dff1855cbc006f95e6..7bba80d2a9eac8b921369d6c1cc28a899fade418 100644 (file)
@@ -2,11 +2,19 @@
 
 enum foo = ~uint;
 
+#[cfg(stage0)]
 impl foo: Add<foo, foo> {
     pure fn add(f: foo) -> foo {
         foo(~(**self + **f))
     }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl foo : Add<foo, foo> {
+    pure fn add(f: &foo) -> foo {
+        foo(~(**self + **(*f)))
+    }
+}
 
 fn main() {
     let x = foo(~3);
index 7fdfbae75a68e35458075f45d19968e5cb66e7e8..cc555dce476e7dfc14dc1a5fec456e906024ab6a 100644 (file)
@@ -1,13 +1,26 @@
+// xfail-test
+// xfail-fast
+
+// XFAIL'd because of error message problems with demoded Add.
+
 struct Point { 
     x: int,
     y: int,
 }
 
+#[cfg(stage0)]
 impl Point : ops::Add<int,int> {
     pure fn add(&&z: int) -> int {
         self.x + self.y + z
     }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl Point : ops::Add<int,int> {
+    pure fn add(z: &int) -> int {
+        self.x + self.y + (*z)
+    }
+}
 
 impl Point {
     fn times(z: int) -> int {
index a8381f223afc03bb2d726c004915107202cd1dae..0f6eaee0d46ae62a7779f75344f63135b1fe93a7 100644 (file)
@@ -1,3 +1,8 @@
+// xfail-fast
+// xfail-test
+
+// XFAIL'd due to problems with error messages on demoded Add.
+
 #[legacy_modes];
 
 fn foo<T: Copy>(+_t: T) { fail; }
@@ -11,11 +16,19 @@ struct S {
 
 fn S(x: int) -> S { S { x: x } }
 
+#[cfg(stage0)]
 impl S: Add<S, S> {
     pure fn add(rhs: S) -> S {
         S { x: self.x + rhs.x }
     }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl S : Add<S, S> {
+    pure fn add(rhs: &S) -> S {
+        S { x: self.x + (*rhs).x }
+    }
+}
 
 fn main() {
    let v = S(5);
index a9fa659398639f3fca678337da2b02fe24396358..227f589397e92a80a499cf7ee34e3f2b90ba7fd5 100644 (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(other: &thing) -> bool { *self < *other }
+    pure fn le(other: &thing) -> bool { *self < *other }
+    pure fn ge(other: &thing) -> bool { *self < *other }
 }
 fn main() {}
index 8291c883d4f6f99997304488903b356ebb0112a4..3a07faa75c5e591b7eb6fbf90ede7b64d55a1709 100644 (file)
@@ -47,77 +47,78 @@ enum expr {
 }
 
 impl an_enum : cmp::Eq {
-    pure fn eq(&&other: an_enum) -> bool {
-        self.v == other.v
+    pure fn eq(other: &an_enum) -> bool {
+        self.v == (*other).v
     }
-    pure fn ne(&&other: an_enum) -> bool { !self.eq(other) }
+    pure fn ne(other: &an_enum) -> bool { !self.eq(other) }
 }
 
 impl point : cmp::Eq {
-    pure fn eq(&&other: point) -> bool {
-        self.x == other.x && self.y == other.y
+    pure fn eq(other: &point) -> bool {
+        self.x == (*other).x && self.y == (*other).y
     }
-    pure fn ne(&&other: point) -> bool { !self.eq(other) }
+    pure fn ne(other: &point) -> bool { !self.eq(other) }
 }
 
 impl<T:cmp::Eq> quark<T> : cmp::Eq {
-    pure fn eq(&&other: quark<T>) -> bool {
+    pure fn eq(other: &quark<T>) -> bool {
         match self {
-          top(ref q) => match other {
+          top(ref q) => match (*other) {
             top(ref r) => q == r,
             bottom(_) => false
           },
-          bottom(ref q) => match other {
+          bottom(ref q) => match (*other) {
             top(_) => false,
             bottom(ref r) => q == r
           }
         }
     }
-    pure fn ne(&&other: quark<T>) -> bool { !self.eq(other) }
+    pure fn ne(other: &quark<T>) -> bool { !self.eq(other) }
 }
 
 
 impl c_like : cmp::Eq {
-    pure fn eq(&&other: c_like) -> bool {
-        self as int == other as int
+    pure fn eq(other: &c_like) -> bool {
+        self as int == (*other) as int
     }
-    pure fn ne(&&other: c_like) -> bool { !self.eq(other) }
+    pure fn ne(other: &c_like) -> bool { !self.eq(other) }
 }
 
 impl expr : cmp::Eq {
-    pure fn eq(&&other: expr) -> bool {
+    pure fn eq(other: &expr) -> bool {
         match self {
             val(e0a) => {
-                match other {
+                match (*other) {
                     val(e0b) => e0a == e0b,
                     _ => false
                 }
             }
             plus(e0a, e1a) => {
-                match other {
+                match (*other) {
                     plus(e0b, e1b) => e0a == e0b && e1a == e1b,
                     _ => false
                 }
             }
             minus(e0a, e1a) => {
-                match other {
+                match (*other) {
                     minus(e0b, e1b) => e0a == e0b && e1a == e1b,
                     _ => false
                 }
             }
         }
     }
-    pure fn ne(&&other: expr) -> bool { !self.eq(other) }
+    pure fn ne(other: &expr) -> bool { !self.eq(other) }
 }
 
 #[auto_serialize]
 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.eq(other.node)
+    pure fn eq(other: &spanned<T>) -> bool {
+        self.lo == (*other).lo && self.hi == (*other).hi &&
+        self.node.eq(&(*other).node)
     }
-    pure fn ne(&&other: spanned<T>) -> bool { !self.eq(other) }
+    pure fn ne(other: &spanned<T>) -> bool { !self.eq(other) }
 }
 
 #[auto_serialize]
index 55e104b3fa2cad2c8518642baf6442e31b831e64..bd541e818ad832e070784c9bab7eec9367b11009 100644 (file)
@@ -90,10 +90,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(other: &p) -> bool {
+        self.x == (*other).x && self.y == (*other).y
     }
-    pure fn ne(&&other: p) -> bool { !self.eq(other) }
+    pure fn ne(other: &p) -> bool { !self.eq(other) }
 }
 
 fn test_class() {
index 325b09f77edd1d1c27e49188fbcf53a6c5f0cd13..95abfc6cb016f01ca62b3481aef6dca8bc590e6e 100644 (file)
@@ -7,10 +7,10 @@
 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(other: &cat_type) -> bool {
+        (self as uint) == ((*other) as uint)
     }
-    pure fn ne(&&other: cat_type) -> bool { !self.eq(other) }
+    pure fn ne(other: &cat_type) -> bool { !self.eq(other) }
 }
 
 // Very silly -- this just returns the value of the name field
index f69c8782c9ae567d9fe0810aa1b5fbf9f33c6ba4..a911bc77d98423137aa66f1cb3b3e46b22f0ac55 100644 (file)
@@ -1,7 +1,7 @@
 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(other: &x) -> bool { self as int == (*other) as int }
+        pure fn ne(other: &x) -> bool { !self.eq(other) }
     }
 }
index 457c80e38a21c2067ebcdae4171aba7685c5d360..dd6adadf98559f78f05cf95bfeb2b43a117de5e5 100644 (file)
@@ -2,10 +2,10 @@
 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(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(other: &foo) -> bool { !self.eq(other) }
 }
 
 const x : foo = foo { a:1, b:2, c: 3 };
index 0b736be2168ca2f8678633cb0145ef313f188517..d715cf2adbc7e44bc5662726a3cf950a9133aee9 100644 (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(other: &chan) -> bool {
+        (self as uint) == ((*other) as uint)
     }
-    pure fn ne(&&other: chan) -> bool { !self.eq(other) }
+    pure fn ne(other: &chan) -> bool { !self.eq(other) }
 }
 
 fn wrapper3(i: chan) {
diff --git a/src/test/run-pass/estr-internal.rs b/src/test/run-pass/estr-internal.rs
deleted file mode 100644 (file)
index 1dc99b0..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-fn main() {
-    let x : str/5 = "hello"/5;
-    let _y : str/5 = "there"/_;
-    let mut z = "thing"/_;
-    z = x;
-    assert z[0] == ('h' as u8);
-    assert z[4] == ('o' as u8);
-
-    let a = "aaaa"/_;
-    let b = "bbbb"/_;
-    let c = "cccc"/_;
-
-    log(debug, a);
-
-    assert a < b;
-    assert a <= b;
-    assert a != b;
-    assert b >= a;
-    assert b > a;
-
-    log(debug, b);
-
-    assert b < c;
-    assert b <= c;
-    assert b != c;
-    assert c >= b;
-    assert c > b;
-
-    assert a < c;
-    assert a <= c;
-    assert a != c;
-    assert c >= a;
-    assert c > a;
-
-    log(debug, c);
-}
index 4f3bd10e4def33c2f6a055a9a8dae5470e818d82..789660c11f0f9568777b06df922aeb997b2b51eb 100644 (file)
@@ -1,3 +1,8 @@
+// xfail-test
+// xfail-fast
+
+// Doesn't work; needs a design decision.
+
 fn main() {
     let x : [int]/5 = [1,2,3,4,5]/5;
     let _y : [int]/5 = [1,2,3,4,5]/_;
index 3d634fa55a518a0e403b06ba796b1d6e4853ff7d..1d0e64dc366c61537fc35bd22472293047b70e31 100644 (file)
@@ -9,10 +9,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(other: &t) -> bool {
+            (self as uint) == ((*other) as uint)
         }
-        pure fn ne(&&other: t) -> bool { !self.eq(other) }
+        pure fn ne(other: &t) -> bool { !self.eq(other) }
     }
 
     fn f() -> t { return t1; }
index c4d50c33139e0cb837fc3c8bac1b36eb28d1b22e..3daf400054ff44ec98bf01f8c7968cce83bbe0c0 100644 (file)
@@ -10,11 +10,12 @@ 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(other: &mood) -> bool {
+        (self as uint) == ((*other) as uint)
     }
-    pure fn ne(&&other: mood) -> bool { !self.eq(other) }
+    pure fn ne(other: &mood) -> bool { !self.eq(other) }
 }
 
 fn test_tag() {
index 62fc904a82c09bef510290275607642fd1c82a5e..a1fb87f7d9e4538eafa24afc0d2ca59543b48a37 100644 (file)
@@ -10,11 +10,12 @@ 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(other: &mood) -> bool {
+        (self as uint) == ((*other) as uint)
     }
-    pure fn ne(&&other: mood) -> bool { !self.eq(other) }
+    pure fn ne(other: &mood) -> bool { !self.eq(other) }
 }
 
 fn test_tag() {
index fbae44bf3279cca1290d2ede41dca1ec2054db6c..3122985d6b5e55d80f097bb728a841fe73ca8dc0 100644 (file)
@@ -9,10 +9,10 @@ enum state {
     }
 
     impl state : cmp::Eq {
-        pure fn eq(&&other: state) -> bool {
-            (self as uint) == (other as uint)
+        pure fn eq(other: &state) -> bool {
+            (self as uint) == ((*other) as uint)
         }
-        pure fn ne(&&other: state) -> bool { !self.eq(other) }
+        pure fn ne(other: &state) -> bool { !self.eq(other) }
     }
 
     type packet<T: Send> = {
index 9dbe80fd020c1eeea6843478cee00b4a7e25e304..d5af5a54377def2ece71d83e4b55e7fc1c2e9930 100644 (file)
@@ -7,14 +7,14 @@ struct Point {
 }
 
 impl Point : ops::Add<Point,Point> {
-    pure fn add(other: Point) -> Point {
-        Point {x: self.x + other.x, y: self.y + other.y}
+    pure fn add(other: &Point) -> Point {
+        Point {x: self.x + (*other).x, y: self.y + (*other).y}
     }
 }
 
 impl Point : ops::Sub<Point,Point> {
-    pure fn sub(other: Point) -> Point {
-        Point {x: self.x - other.x, y: self.y - other.y}
+    pure fn sub(other: &Point) -> Point {
+        Point {x: self.x - (*other).x, y: self.y - (*other).y}
     }
 }
 
@@ -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(other: &Point) -> bool {
+        self.x == (*other).x && self.y == (*other).y
     }
-    pure fn ne(&&other: Point) -> bool { !self.eq(other) }
+    pure fn ne(other: &Point) -> bool { !self.eq(other) }
 }
 
 fn main() {
index 06b3cb3c3f6de410511a7631c9b51fb5ea1b503c..5688dc5178a1aca888dd29675c33ffe5d31d4f02 100644 (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(other: &foo) -> bool {
+        (self as uint) == ((*other) as uint)
     }
-    pure fn ne(&&other: foo) -> bool { !self.eq(other) }
+    pure fn ne(other: &foo) -> bool { !self.eq(other) }
 }
 
 fn main() {
index f0dce1f624705c2bed2be98f37ff527a40950336..6e5cce33e21f264688f80077e80f7b764845855e 100644 (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(other: &color) -> bool {
+        (self as uint) == ((*other) as uint)
     }
-    pure fn ne(&&other: color) -> bool { !self.eq(other) }
+    pure fn ne(other: &color) -> bool { !self.eq(other) }
 }
 
 fn main() {
index 6d6e2ad09d0a3b1ee2fc30db14b19203c652c04e..4167afee35c438fb80d051c44376ce3d4a370188 100644 (file)
@@ -5,23 +5,23 @@
 enum colour { red(int, int), green, }
 
 impl colour : cmp::Eq {
-    pure fn eq(&&other: colour) -> bool {
+    pure fn eq(other: &colour) -> bool {
         match self {
             red(a0, b0) => {
-                match other {
+                match (*other) {
                     red(a1, b1) => a0 == a1 && b0 == b1,
                     green => false,
                 }
             }
             green => {
-                match other {
+                match (*other) {
                     red(*) => false,
                     green => true
                 }
             }
         }
     }
-    pure fn ne(&&other: colour) -> bool { !self.eq(other) }
+    pure fn ne(other: &colour) -> bool { !self.eq(other) }
 }
 
 fn f() { let x = red(1, 2); let y = green; assert (x != y); }
index 9b7d05488de8ffde631c1c11b3c9b5fccdf83b39..a69b7b0c15bc8004b7ad64f7c925c5e160595ee2 100644 (file)
@@ -48,22 +48,22 @@ enum t {
 }
 
 impl t : cmp::Eq {
-    pure fn eq(&&other: t) -> bool {
+    pure fn eq(other: &t) -> bool {
         match self {
             tag1 => {
-                match other {
+                match (*other) {
                     tag1 => true,
                     _ => false
                 }
             }
             tag2(e0a) => {
-                match other {
+                match (*other) {
                     tag2(e0b) => e0a == e0b,
                     _ => false
                 }
             }
             tag3(e0a, e1a, e2a) => {
-                match other {
+                match (*other) {
                     tag3(e0b, e1b, e2b) =>
                         e0a == e0b && e1a == e1b && e2a == e2b,
                     _ => false
@@ -71,7 +71,7 @@ impl t : cmp::Eq {
             }
         }
     }
-    pure fn ne(&&other: t) -> bool { !self.eq(other) }
+    pure fn ne(other: &t) -> bool { !self.eq(other) }
 }
 
 fn test_tag() {
index 8b1ea84ba0d4580ab408e42f8d8b49aa8fcdfe47..8990c21656799195a365dfee3650a8e9c6274295 100644 (file)
@@ -33,14 +33,14 @@ fn gte(a: self) -> bool {
 }
 
 // pronounced "impl of Ord for int" -- not sold on this yet
-impl int: Ord {
-    fn lt(a: int) -> bool {
-        self < a
+impl int : Ord {
+    fn lt(a: &int) -> bool {
+        self < (*a)
     }
 
     // is this the place to put this?
-    fn eq(a: int) -> bool {
-        self == a
+    fn eq(a: &int) -> bool {
+        self == (*a)
     }
 }
 
index 9400840dd8ef66ea718cb9e641978df13096cfd5..a4a685caff6da59e2a1f055ba861ad7cf82606ff 100644 (file)
@@ -2,23 +2,23 @@
 enum t { a, b(~str), }
 
 impl t : cmp::Eq {
-    pure fn eq(&&other: t) -> bool {
+    pure fn eq(other: &t) -> bool {
         match self {
             a => {
-                match other {
+                match (*other) {
                     a => true,
                     b(_) => false
                 }
             }
             b(s0) => {
-                match other {
+                match (*other) {
                     a => false,
                     b(s1) => s0 == s1
                 }
             }
         }
     }
-    pure fn ne(&&other: t) -> bool { !self.eq(other) }
+    pure fn ne(other: &t) -> bool { !self.eq(other) }
 }
 
 fn make(i: int) -> t {