From feb014eb3c3aa1ccaae1df407801dffa090499fd Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Fri, 7 Sep 2012 12:06:02 -0700 Subject: [PATCH] rustc: Add an "ne" method to the Eq trait, and implement it everywhere --- src/cargo/cargo.rs | 1 + src/compiletest/common.rs | 1 + src/fuzzer/fuzzer.rs | 1 + src/libcore/bool.rs | 5 +-- src/libcore/box.rs | 1 + src/libcore/char.rs | 1 + src/libcore/cmp.rs | 6 +++ src/libcore/either.rs | 1 + src/libcore/extfmt.rs | 1 + src/libcore/float.rs | 1 + src/libcore/int-template.rs | 5 +-- src/libcore/io.rs | 1 + src/libcore/option.rs | 1 + src/libcore/path.rs | 2 + src/libcore/pipes.rs | 1 + src/libcore/ptr.rs | 6 +-- src/libcore/result.rs | 1 + src/libcore/str.rs | 6 +++ src/libcore/task.rs | 8 ++-- src/libcore/tuple.rs | 2 + src/libcore/uint-template.rs | 5 +-- src/libcore/uniq.rs | 1 + src/libcore/unit.rs | 1 + src/libcore/vec.rs | 18 ++++---- src/libstd/getopts.rs | 3 ++ src/libstd/json.rs | 6 +-- src/libstd/list.rs | 1 + src/libstd/net_url.rs | 2 + src/libstd/test.rs | 1 + src/libstd/time.rs | 7 +-- src/libsyntax/ast.rs | 23 ++++++++++ src/libsyntax/ast_map.rs | 1 + src/libsyntax/codemap.rs | 2 + src/libsyntax/diagnostic.rs | 1 + src/libsyntax/ext/pipes/proto.rs | 1 + src/libsyntax/parse/parser.rs | 1 + src/libsyntax/parse/token.rs | 2 + src/libsyntax/print/pp.rs | 1 + src/rustc/back/link.rs | 1 + src/rustc/driver/driver.rs | 1 + src/rustc/driver/rustc.rs | 1 + src/rustc/driver/session.rs | 3 ++ src/rustc/lib/llvm.rs | 1 + src/rustc/metadata/decoder.rs | 1 + src/rustc/middle/borrowck.rs | 2 + src/rustc/middle/borrowck/check_loans.rs | 1 + src/rustc/middle/check_alt.rs | 1 + src/rustc/middle/const_eval.rs | 1 + src/rustc/middle/lint.rs | 2 + src/rustc/middle/liveness.rs | 11 +++-- src/rustc/middle/mem_categorization.rs | 6 +++ src/rustc/middle/region.rs | 1 + src/rustc/middle/resolve.rs | 6 +++ src/rustc/middle/trans/alt.rs | 1 + src/rustc/middle/trans/common.rs | 3 ++ src/rustc/middle/trans/datum.rs | 1 + src/rustc/middle/trans/expr.rs | 4 +- src/rustc/middle/trans/foreign.rs | 1 + src/rustc/middle/ty.rs | 45 ++++++++++++------- .../typeck/infer/region_var_bindings.rs | 4 ++ src/rustdoc/config.rs | 2 + src/rustdoc/doc.rs | 27 ++++++++--- src/test/run-pass/auto_serialize.rs | 9 +++- src/test/run-pass/binops.rs | 1 + .../class-impl-very-parameterized-trait.rs | 1 + src/test/run-pass/coherence-impl-in-fn.rs | 1 + src/test/run-pass/const-struct.rs | 1 + src/test/run-pass/empty-tag.rs | 1 + src/test/run-pass/export-unexported-dep.rs | 1 + src/test/run-pass/expr-alt-struct.rs | 1 + src/test/run-pass/expr-if-struct.rs | 1 + src/test/run-pass/issue-2718.rs | 1 + src/test/run-pass/operator-overloading.rs | 1 + src/test/run-pass/structured-compare.rs | 1 + src/test/run-pass/tag-variant-disr-val.rs | 1 + src/test/run-pass/task-comm-16.rs | 1 + 76 files changed, 218 insertions(+), 60 deletions(-) diff --git a/src/cargo/cargo.rs b/src/cargo/cargo.rs index 431b72012e7..ac75d132b3e 100644 --- a/src/cargo/cargo.rs +++ b/src/cargo/cargo.rs @@ -100,6 +100,7 @@ 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] { diff --git a/src/compiletest/common.rs b/src/compiletest/common.rs index 714f04e4a9d..5a8b98cd857 100644 --- a/src/compiletest/common.rs +++ b/src/compiletest/common.rs @@ -6,6 +6,7 @@ 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 = { diff --git a/src/fuzzer/fuzzer.rs b/src/fuzzer/fuzzer.rs index 134b0773f6b..ea88c5865d5 100644 --- a/src/fuzzer/fuzzer.rs +++ b/src/fuzzer/fuzzer.rs @@ -12,6 +12,7 @@ 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) { diff --git a/src/libcore/bool.rs b/src/libcore/bool.rs index 56d4e399cac..7deb5b30eef 100644 --- a/src/libcore/bool.rs +++ b/src/libcore/bool.rs @@ -70,9 +70,8 @@ fn all_values(blk: fn(v: bool)) { pure fn to_bit(v: bool) -> u8 { if v { 1u8 } else { 0u8 } } impl bool : cmp::Eq { - pure fn eq(&&other: bool) -> bool { - self == other - } + pure fn eq(&&other: bool) -> bool { self == other } + pure fn ne(&&other: bool) -> bool { self != other } } #[test] diff --git a/src/libcore/box.rs b/src/libcore/box.rs index 49fd9b8706f..8629ffc78e0 100644 --- a/src/libcore/box.rs +++ b/src/libcore/box.rs @@ -15,6 +15,7 @@ pure fn ptr_eq(a: @T, b: @T) -> bool { impl @const T : Eq { pure fn eq(&&other: @const T) -> bool { *self == *other } + pure fn ne(&&other: @const T) -> bool { *self != *other } } impl @const T : Ord { diff --git a/src/libcore/char.rs b/src/libcore/char.rs index 20b0857f5c8..69392d8648f 100644 --- a/src/libcore/char.rs +++ b/src/libcore/char.rs @@ -191,6 +191,7 @@ pure fn cmp(a: char, b: char) -> int { impl char: Eq { pure fn eq(&&other: char) -> bool { self == other } + pure fn ne(&&other: char) -> bool { self != other } } #[test] diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs index 6647963bc5e..82a830d05cd 100644 --- a/src/libcore/cmp.rs +++ b/src/libcore/cmp.rs @@ -26,11 +26,13 @@ trait Ord { #[lang="eq"] trait Eq { pure fn eq(&&other: self) -> bool; + pure fn ne(&&other: self) -> bool; } #[cfg(test)] trait Eq { pure fn eq(&&other: self) -> bool; + pure fn ne(&&other: self) -> bool; } pure fn lt(v1: &T, v2: &T) -> bool { @@ -45,6 +47,10 @@ pure fn eq(v1: &T, v2: &T) -> bool { v1.eq(v2) } +pure fn ne(v1: &T, v2: &T) -> bool { + v1.ne(v2) +} + pure fn ge(v1: &T, v2: &T) -> bool { v1.ge(v2) } diff --git a/src/libcore/either.rs b/src/libcore/either.rs index 36fc13c12af..00706280ebc 100644 --- a/src/libcore/either.rs +++ b/src/libcore/either.rs @@ -143,6 +143,7 @@ impl Either : Eq { } } } + pure fn ne(&&other: Either) -> bool { !self.eq(other) } } #[test] diff --git a/src/libcore/extfmt.rs b/src/libcore/extfmt.rs index 4db222ea332..731c4a6f457 100644 --- a/src/libcore/extfmt.rs +++ b/src/libcore/extfmt.rs @@ -401,6 +401,7 @@ mod rt { (pad_float, _) => false } } + pure fn ne(&&other: pad_mode) -> bool { !self.eq(other) } } fn pad(cv: conv, &s: ~str, mode: pad_mode) -> ~str { diff --git a/src/libcore/float.rs b/src/libcore/float.rs index a69260abaab..b570f1a1495 100644 --- a/src/libcore/float.rs +++ b/src/libcore/float.rs @@ -416,6 +416,7 @@ pure fn tan(x: float) -> float { f64::tan(x as f64) as float } impl float: Eq { pure fn eq(&&other: float) -> bool { self == other } + pure fn ne(&&other: float) -> bool { self != other } } impl float: Ord { diff --git a/src/libcore/int-template.rs b/src/libcore/int-template.rs index 0fd8ea1d5f1..e1b592522e6 100644 --- a/src/libcore/int-template.rs +++ b/src/libcore/int-template.rs @@ -76,9 +76,8 @@ impl T: Ord { } impl T: Eq { - pure fn eq(&&other: T) -> bool { - return self == other; - } + pure fn eq(&&other: T) -> bool { return self == other; } + pure fn ne(&&other: T) -> bool { return self != other; } } impl T: num::Num { diff --git a/src/libcore/io.rs b/src/libcore/io.rs index 483c96206b5..a9d83194713 100644 --- a/src/libcore/io.rs +++ b/src/libcore/io.rs @@ -337,6 +337,7 @@ impl WriterType: Eq { (Screen, _) | (File, _) => false } } + pure fn ne(&&other: WriterType) -> bool { !self.eq(other) } } // FIXME (#2004): Seekable really should be orthogonal. diff --git a/src/libcore/option.rs b/src/libcore/option.rs index dfa02303751..4c4e0048f17 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -266,6 +266,7 @@ impl Option : Eq { } } } + pure fn ne(&&other: Option) -> bool { !self.eq(other) } } #[test] diff --git a/src/libcore/path.rs b/src/libcore/path.rs index 2151fc599e6..a9dda62d950 100644 --- a/src/libcore/path.rs +++ b/src/libcore/path.rs @@ -69,6 +69,7 @@ impl PosixPath : Eq { return self.is_absolute == other.is_absolute && self.components == other.components; } + pure fn ne(&&other: PosixPath) -> bool { !self.eq(other) } } impl WindowsPath : Eq { @@ -78,6 +79,7 @@ impl WindowsPath : Eq { 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 diff --git a/src/libcore/pipes.rs b/src/libcore/pipes.rs index f0b656ea649..2078b1ed71b 100644 --- a/src/libcore/pipes.rs +++ b/src/libcore/pipes.rs @@ -128,6 +128,7 @@ 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 { diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index c7558ffba1c..6e8a2bb3611 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -188,6 +188,7 @@ impl *const T : Eq { let b: uint = unsafe::reinterpret_cast(&other); return a == b; } + pure fn ne(&&other: *const T) -> bool { !self.eq(other) } } // Comparison for pointers @@ -216,9 +217,8 @@ impl *const T : Ord { // Equality for region pointers impl &const T : Eq { - pure fn eq(&&other: &const T) -> bool { - return *self == *other; - } + pure fn eq(&&other: &const T) -> bool { return *self == *other; } + pure fn ne(&&other: &const T) -> bool { return *self != *other; } } // Comparison for region pointers diff --git a/src/libcore/result.rs b/src/libcore/result.rs index 5fb53b1fed4..e4028a466e0 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -373,6 +373,7 @@ impl Result : Eq { } } } + pure fn ne(&&other: Result) -> bool { !self.eq(other) } } #[cfg(test)] diff --git a/src/libcore/str.rs b/src/libcore/str.rs index bc669870c49..b83ef1064fd 100644 --- a/src/libcore/str.rs +++ b/src/libcore/str.rs @@ -780,6 +780,8 @@ impl &str: Eq { pure fn eq(&&other: &str) -> bool { eq_slice(self, other) } + #[inline(always)] + pure fn ne(&&other: &str) -> bool { !self.eq(other) } } impl ~str: Eq { @@ -787,6 +789,8 @@ impl ~str: Eq { pure fn eq(&&other: ~str) -> bool { eq_slice(self, other) } + #[inline(always)] + pure fn ne(&&other: ~str) -> bool { !self.eq(other) } } impl @str: Eq { @@ -794,6 +798,8 @@ impl @str: Eq { pure fn eq(&&other: @str) -> bool { eq_slice(self, other) } + #[inline(always)] + pure fn ne(&&other: @str) -> bool { !self.eq(other) } } impl ~str : Ord { diff --git a/src/libcore/task.rs b/src/libcore/task.rs index 04197506d5d..f4514ecd367 100644 --- a/src/libcore/task.rs +++ b/src/libcore/task.rs @@ -85,9 +85,8 @@ enum Task { } impl Task : cmp::Eq { - pure fn eq(&&other: Task) -> bool { - *self == *other - } + pure fn eq(&&other: Task) -> bool { *self == *other } + pure fn ne(&&other: Task) -> bool { !self.eq(other) } } /** @@ -113,6 +112,7 @@ impl TaskResult: Eq { (Success, _) | (Failure, _) => false } } + pure fn ne(&&other: TaskResult) -> bool { !self.eq(other) } } /// A message type for notifying of task lifecycle events @@ -131,6 +131,7 @@ impl Notification : cmp::Eq { } } } + pure fn ne(&&other: Notification) -> bool { !self.eq(other) } } /// Scheduler modes @@ -1324,6 +1325,7 @@ impl LocalData: Eq { let ptr_b: (uint, uint) = unsafe::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 diff --git a/src/libcore/tuple.rs b/src/libcore/tuple.rs index 92a0f681a56..2ab8af78b8a 100644 --- a/src/libcore/tuple.rs +++ b/src/libcore/tuple.rs @@ -81,6 +81,7 @@ impl (A, B): Eq { } } } + pure fn ne(&&other: (A, B)) -> bool { !self.eq(other) } } impl (A, B): Ord { @@ -119,6 +120,7 @@ impl (A, B, C): Eq { } } } + pure fn ne(&&other: (A, B, C)) -> bool { !self.eq(other) } } impl (A, B, C): Ord { diff --git a/src/libcore/uint-template.rs b/src/libcore/uint-template.rs index c54c8a8c5eb..01668edf3b6 100644 --- a/src/libcore/uint-template.rs +++ b/src/libcore/uint-template.rs @@ -69,9 +69,8 @@ impl T: Ord { } impl T: Eq { - pure fn eq(&&other: T) -> bool { - return self == other; - } + pure fn eq(&&other: T) -> bool { return self == other; } + pure fn ne(&&other: T) -> bool { return self != other; } } impl T: num::Num { diff --git a/src/libcore/uniq.rs b/src/libcore/uniq.rs index 8cdacba0286..7a9aa71d199 100644 --- a/src/libcore/uniq.rs +++ b/src/libcore/uniq.rs @@ -4,6 +4,7 @@ use cmp::{Eq, Ord}; impl ~const T : Eq { pure fn eq(&&other: ~const T) -> bool { *self == *other } + pure fn ne(&&other: ~const T) -> bool { *self != *other } } impl ~const T : Ord { diff --git a/src/libcore/unit.rs b/src/libcore/unit.rs index e4ca11bbd8a..2b09425f752 100644 --- a/src/libcore/unit.rs +++ b/src/libcore/unit.rs @@ -6,6 +6,7 @@ use cmp::{Eq, Ord}; impl () : Eq { pure fn eq(&&_other: ()) -> bool { true } + pure fn ne(&&_other: ()) -> bool { false } } impl () : Ord { diff --git a/src/libcore/vec.rs b/src/libcore/vec.rs index 85aebc9ee90..4dedde8e177 100644 --- a/src/libcore/vec.rs +++ b/src/libcore/vec.rs @@ -1406,23 +1406,23 @@ pure fn eq(a: &[T], b: &[T]) -> bool { impl &[T]: Eq { #[inline(always)] - pure fn eq(&&other: &[T]) -> bool { - eq(self, other) - } + pure fn eq(&&other: &[T]) -> bool { eq(self, other) } + #[inline(always)] + pure fn ne(&&other: &[T]) -> bool { !self.eq(other) } } impl ~[T]: Eq { #[inline(always)] - pure fn eq(&&other: ~[T]) -> bool { - eq(self, other) - } + pure fn eq(&&other: ~[T]) -> bool { eq(self, other) } + #[inline(always)] + pure fn ne(&&other: ~[T]) -> bool { !self.eq(other) } } impl @[T]: Eq { #[inline(always)] - pure fn eq(&&other: @[T]) -> bool { - eq(self, other) - } + pure fn eq(&&other: @[T]) -> bool { eq(self, other) } + #[inline(always)] + pure fn ne(&&other: @[T]) -> bool { !self.eq(other) } } // Lexicographical comparison diff --git a/src/libstd/getopts.rs b/src/libstd/getopts.rs index 50bad1e748a..092bf5cfd78 100644 --- a/src/libstd/getopts.rs +++ b/src/libstd/getopts.rs @@ -124,12 +124,14 @@ impl Name : Eq { } } } + pure fn ne(&&other: Name) -> bool { !self.eq(other) } } 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 @@ -449,6 +451,7 @@ 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)] diff --git a/src/libstd/json.rs b/src/libstd/json.rs index 161fdf53b99..f2207f2a913 100644 --- a/src/libstd/json.rs +++ b/src/libstd/json.rs @@ -609,12 +609,12 @@ impl Error : Eq { self.col == other.col && self.msg == other.msg } + pure fn ne(&&other: Error) -> bool { !self.eq(other) } } impl Json : Eq { - pure fn eq(&&other: Json) -> bool { - eq(self, other) - } + pure fn eq(&&other: Json) -> bool { eq(self, other) } + pure fn ne(&&other: Json) -> bool { !self.eq(other) } } trait ToJson { fn to_json() -> Json; } diff --git a/src/libstd/list.rs b/src/libstd/list.rs index ff4f20e7be7..71b820b4022 100644 --- a/src/libstd/list.rs +++ b/src/libstd/list.rs @@ -165,6 +165,7 @@ impl List : Eq { } } } + pure fn ne(&&other: List) -> bool { !self.eq(other) } } #[cfg(test)] diff --git a/src/libstd/net_url.rs b/src/libstd/net_url.rs index 855608a8fdf..a8872e13f0b 100644 --- a/src/libstd/net_url.rs +++ b/src/libstd/net_url.rs @@ -320,6 +320,7 @@ 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 { @@ -386,6 +387,7 @@ impl Input: Eq { (Unreserved, _) => false } } + pure fn ne(&&other: Input) -> bool { !self.eq(other) } } // returns userinfo, host, port, and unparsed part, or an error diff --git a/src/libstd/test.rs b/src/libstd/test.rs index 8c76c316be4..db8af371cec 100644 --- a/src/libstd/test.rs +++ b/src/libstd/test.rs @@ -96,6 +96,7 @@ 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 = diff --git a/src/libstd/time.rs b/src/libstd/time.rs index 86104c117b5..c012ac8fa05 100644 --- a/src/libstd/time.rs +++ b/src/libstd/time.rs @@ -40,6 +40,7 @@ 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) } } /** @@ -105,6 +106,7 @@ impl Tm_ : Eq { self.tm_zone == other.tm_zone && self.tm_nsec == other.tm_nsec } + pure fn ne(&&other: Tm_) -> bool { !self.eq(other) } } enum Tm { @@ -112,9 +114,8 @@ enum Tm { } impl Tm : Eq { - pure fn eq(&&other: Tm) -> bool { - *self == *other - } + pure fn eq(&&other: Tm) -> bool { *self == *other } + pure fn ne(&&other: Tm) -> bool { *self != *other } } fn empty_tm() -> Tm { diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index ceed0718f6b..03106f97bc7 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -81,6 +81,7 @@ 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; @@ -244,6 +245,7 @@ impl def : cmp::Eq { } } } + pure fn ne(&&other: def) -> bool { !self.eq(other) } } // The set of meta_items that define the compilation environment of the crate, @@ -337,6 +339,7 @@ impl binding_mode : cmp::Eq { } } } + pure fn ne(&&other: binding_mode) -> bool { !self.eq(other) } } #[auto_serialize] @@ -368,6 +371,7 @@ 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] @@ -420,6 +424,7 @@ 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] @@ -454,6 +459,7 @@ impl inferable : cmp::Eq { } } } + pure fn ne(&&other: inferable) -> bool { !self.eq(other) } } // "resolved" mode: the real modes. @@ -464,6 +470,7 @@ 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. @@ -504,6 +511,7 @@ impl init_op : cmp::Eq { } } } + pure fn ne(&&other: init_op) -> bool { !self.eq(other) } } #[auto_serialize] @@ -547,6 +555,7 @@ impl blk_check_mode : cmp::Eq { (unsafe_blk, _) => false, } } + pure fn ne(&&other: blk_check_mode) -> bool { !self.eq(other) } } #[auto_serialize] @@ -781,6 +790,7 @@ impl ast::lit_: cmp::Eq { (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 @@ -828,6 +838,7 @@ impl int_ty: cmp::Eq { (ty_i64, _) => false, } } + pure fn ne(&&other: int_ty) -> bool { !self.eq(other) } } #[auto_serialize] @@ -848,6 +859,7 @@ impl uint_ty: cmp::Eq { (ty_u64, _) => false } } + pure fn ne(&&other: uint_ty) -> bool { !self.eq(other) } } #[auto_serialize] @@ -860,6 +872,7 @@ impl float_ty: cmp::Eq { (ty_f, _) | (ty_f32, _) | (ty_f64, _) => false } } + pure fn ne(&&other: float_ty) -> bool { !self.eq(other) } } #[auto_serialize] @@ -910,6 +923,7 @@ impl prim_ty : cmp::Eq { } } } + pure fn ne(&&other: prim_ty) -> bool { !self.eq(other) } } #[auto_serialize] @@ -960,6 +974,7 @@ 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] @@ -978,6 +993,7 @@ impl ret_style : cmp::Eq { (return_val, _) => false, } } + pure fn ne(&&other: ret_style) -> bool { !self.eq(other) } } #[auto_serialize] @@ -1031,6 +1047,7 @@ impl self_ty_ : cmp::Eq { } } } + pure fn ne(&&other: self_ty_) -> bool { !self.eq(other) } } #[auto_serialize] @@ -1061,6 +1078,7 @@ 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) } } impl foreign_abi : cmp::Eq { @@ -1074,6 +1092,7 @@ impl foreign_abi : cmp::Eq { (foreign_abi_stdcall, _) => false, } } + pure fn ne(&&other: foreign_abi) -> bool { !self.eq(other) } } #[auto_serialize] @@ -1115,6 +1134,7 @@ 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] @@ -1162,6 +1182,7 @@ 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 @@ -1194,6 +1215,7 @@ impl visibility : cmp::Eq { (inherited, _) => false, } } + pure fn ne(&&other: visibility) -> bool { !self.eq(other) } } #[auto_serialize] @@ -1262,6 +1284,7 @@ impl class_mutability : cmp::Eq { (class_immutable, _) => false, } } + pure fn ne(&&other: class_mutability) -> bool { !self.eq(other) } } #[auto_serialize] diff --git a/src/libsyntax/ast_map.rs b/src/libsyntax/ast_map.rs index c131c7d57ad..e0285694460 100644 --- a/src/libsyntax/ast_map.rs +++ b/src/libsyntax/ast_map.rs @@ -28,6 +28,7 @@ impl path_elt : cmp::Eq { } } } + pure fn ne(&&other: path_elt) -> bool { !self.eq(other) } } type path = ~[path_elt]; diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index 40e51adc293..2e3c556084f 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -36,6 +36,7 @@ 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 @@ -174,6 +175,7 @@ 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 { diff --git a/src/libsyntax/diagnostic.rs b/src/libsyntax/diagnostic.rs index 1b7d6bf79d9..99296f72eb7 100644 --- a/src/libsyntax/diagnostic.rs +++ b/src/libsyntax/diagnostic.rs @@ -150,6 +150,7 @@ 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 { diff --git a/src/libsyntax/ext/pipes/proto.rs b/src/libsyntax/ext/pipes/proto.rs index 789ee70249f..d207a65a169 100644 --- a/src/libsyntax/ext/pipes/proto.rs +++ b/src/libsyntax/ext/pipes/proto.rs @@ -14,6 +14,7 @@ impl direction : cmp::Eq { (recv, _) => false, } } + pure fn ne(&&other: direction) -> bool { !self.eq(other) } } impl direction: ToStr { diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index e900b7dd7b3..633ace5e253 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -3626,6 +3626,7 @@ 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) } } // diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index 945f4c6b279..73e4039513e 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -440,6 +440,7 @@ 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) } } impl token : cmp::Eq { @@ -705,6 +706,7 @@ impl token : cmp::Eq { } } } + pure fn ne(&&other: token) -> bool { !self.eq(other) } } // Local Variables: diff --git a/src/libsyntax/print/pp.rs b/src/libsyntax/print/pp.rs index 3c55b7aaf82..71eabb410bb 100644 --- a/src/libsyntax/print/pp.rs +++ b/src/libsyntax/print/pp.rs @@ -64,6 +64,7 @@ impl breaks : cmp::Eq { (inconsistent, _) => false, } } + pure fn ne(&&other: breaks) -> bool { !self.eq(other) } } type break_t = {offset: int, blank_space: int}; diff --git a/src/rustc/back/link.rs b/src/rustc/back/link.rs index e6380fd1be6..afd94e4f437 100644 --- a/src/rustc/back/link.rs +++ b/src/rustc/back/link.rs @@ -30,6 +30,7 @@ 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 { diff --git a/src/rustc/driver/driver.rs b/src/rustc/driver/driver.rs index 024452302da..ecdd02b4697 100644 --- a/src/rustc/driver/driver.rs +++ b/src/rustc/driver/driver.rs @@ -140,6 +140,7 @@ 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, diff --git a/src/rustc/driver/rustc.rs b/src/rustc/driver/rustc.rs index 8b8325853cc..3c0e4d0f9e1 100644 --- a/src/rustc/driver/rustc.rs +++ b/src/rustc/driver/rustc.rs @@ -209,6 +209,7 @@ 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) } } /* diff --git a/src/rustc/driver/session.rs b/src/rustc/driver/session.rs index 290c6e94654..66544d72db5 100644 --- a/src/rustc/driver/session.rs +++ b/src/rustc/driver/session.rs @@ -16,6 +16,7 @@ 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, } @@ -24,6 +25,7 @@ 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, } @@ -95,6 +97,7 @@ 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 = diff --git a/src/rustc/lib/llvm.rs b/src/rustc/lib/llvm.rs index 23566e59cf9..a6d82e14ea5 100644 --- a/src/rustc/lib/llvm.rs +++ b/src/rustc/lib/llvm.rs @@ -165,6 +165,7 @@ impl TypeKind : cmp::Eq { (X86_MMX, _) => false, } } + pure fn ne(&&other: TypeKind) -> bool { !self.eq(other) } } enum AtomicBinOp { diff --git a/src/rustc/metadata/decoder.rs b/src/rustc/metadata/decoder.rs index b738295d262..1ea6f2bcd61 100644 --- a/src/rustc/metadata/decoder.rs +++ b/src/rustc/metadata/decoder.rs @@ -133,6 +133,7 @@ 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 { diff --git a/src/rustc/middle/borrowck.rs b/src/rustc/middle/borrowck.rs index 176e133529c..785665b42bf 100644 --- a/src/rustc/middle/borrowck.rs +++ b/src/rustc/middle/borrowck.rs @@ -365,6 +365,7 @@ impl bckerr_code : cmp::Eq { } } } + pure fn ne(&&other: bckerr_code) -> bool { !self.eq(other) } } // Combination of an error code and the categorization of the expression @@ -375,6 +376,7 @@ 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` diff --git a/src/rustc/middle/borrowck/check_loans.rs b/src/rustc/middle/borrowck/check_loans.rs index a81620b20ba..0a13ee2ae1e 100644 --- a/src/rustc/middle/borrowck/check_loans.rs +++ b/src/rustc/middle/borrowck/check_loans.rs @@ -53,6 +53,7 @@ impl purity_cause : cmp::Eq { } } } + pure fn ne(&&other: purity_cause) -> bool { !self.eq(other) } } fn check_loans(bccx: borrowck_ctxt, diff --git a/src/rustc/middle/check_alt.rs b/src/rustc/middle/check_alt.rs index f56833c1dbc..364cd4890ab 100644 --- a/src/rustc/middle/check_alt.rs +++ b/src/rustc/middle/check_alt.rs @@ -138,6 +138,7 @@ impl ctor: cmp::Eq { } } } + pure fn ne(&&other: ctor) -> bool { !self.eq(other) } } // Algorithm from http://moscova.inria.fr/~maranget/papers/warn/index.html diff --git a/src/rustc/middle/const_eval.rs b/src/rustc/middle/const_eval.rs index a06403af2e0..beceec4cfd3 100644 --- a/src/rustc/middle/const_eval.rs +++ b/src/rustc/middle/const_eval.rs @@ -201,6 +201,7 @@ impl const_val: cmp::Eq { (const_str(_), _) | (const_bool(_), _) => false } } + pure fn ne(&&other: const_val) -> bool { !self.eq(other) } } // FIXME: issue #1417 diff --git a/src/rustc/middle/lint.rs b/src/rustc/middle/lint.rs index 8c2776d3ceb..51210870b41 100644 --- a/src/rustc/middle/lint.rs +++ b/src/rustc/middle/lint.rs @@ -68,6 +68,7 @@ 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 { @@ -87,6 +88,7 @@ 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, diff --git a/src/rustc/middle/liveness.rs b/src/rustc/middle/liveness.rs index f3459aa8cb3..ed7f793197d 100644 --- a/src/rustc/middle/liveness.rs +++ b/src/rustc/middle/liveness.rs @@ -128,15 +128,13 @@ enum Variable = uint; enum LiveNode = uint; impl Variable : cmp::Eq { - pure fn eq(&&other: Variable) -> bool { - *self == *other - } + pure fn eq(&&other: Variable) -> bool { *self == *other } + pure fn ne(&&other: Variable) -> bool { *self != *other } } impl LiveNode : cmp::Eq { - pure fn eq(&&other: LiveNode) -> bool { - *self == *other - } + pure fn eq(&&other: LiveNode) -> bool { *self == *other } + pure fn ne(&&other: LiveNode) -> bool { *self != *other } } enum LiveNodeKind { @@ -175,6 +173,7 @@ impl LiveNodeKind : cmp::Eq { } } } + pure fn ne(&&other: LiveNodeKind) -> bool { !self.eq(other) } } fn check_crate(tcx: ty::ctxt, diff --git a/src/rustc/middle/mem_categorization.rs b/src/rustc/middle/mem_categorization.rs index 99d0e6372e0..77e234770e6 100644 --- a/src/rustc/middle/mem_categorization.rs +++ b/src/rustc/middle/mem_categorization.rs @@ -115,6 +115,7 @@ impl categorization : cmp::Eq { } } } + pure fn ne(&&other: categorization) -> bool { !self.eq(other) } } // different kinds of pointers: @@ -154,6 +155,7 @@ impl ptr_kind : cmp::Eq { } } } + pure fn ne(&&other: ptr_kind) -> bool { !self.eq(other) } } // I am coining the term "components" to mean "pieces of a data @@ -196,6 +198,7 @@ impl comp_kind : cmp::Eq { } } } + pure fn ne(&&other: comp_kind) -> bool { !self.eq(other) } } // different kinds of expressions we might evaluate @@ -210,6 +213,7 @@ 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 @@ -233,6 +237,7 @@ impl cmt_ : cmp::Eq { 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 @@ -274,6 +279,7 @@ impl loan_path : cmp::Eq { } } } + pure fn ne(&&other: loan_path) -> bool { !self.eq(other) } } // We pun on *T to mean both actual deref of a ptr as well diff --git a/src/rustc/middle/region.rs b/src/rustc/middle/region.rs index 579c096e634..514a816a63a 100644 --- a/src/rustc/middle/region.rs +++ b/src/rustc/middle/region.rs @@ -378,6 +378,7 @@ 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_ = { diff --git a/src/rustc/middle/resolve.rs b/src/rustc/middle/resolve.rs index 1168260b519..4bea8e7c508 100644 --- a/src/rustc/middle/resolve.rs +++ b/src/rustc/middle/resolve.rs @@ -114,6 +114,7 @@ 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) } } @@ -154,6 +155,7 @@ 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 { @@ -188,6 +190,7 @@ 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. @@ -274,6 +277,7 @@ 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 { @@ -285,6 +289,7 @@ 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 { @@ -483,6 +488,7 @@ 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. diff --git a/src/rustc/middle/trans/alt.rs b/src/rustc/middle/trans/alt.rs index 643e385cd17..6884bc48d62 100644 --- a/src/rustc/middle/trans/alt.rs +++ b/src/rustc/middle/trans/alt.rs @@ -424,6 +424,7 @@ 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) } } fn compile_submatch(bcx: block, m: match_, vals: ~[ValueRef], diff --git a/src/rustc/middle/trans/common.rs b/src/rustc/middle/trans/common.rs index 7e612051565..9445efe41fa 100644 --- a/src/rustc/middle/trans/common.rs +++ b/src/rustc/middle/trans/common.rs @@ -288,6 +288,7 @@ impl cleantype : cmp::Eq { } } } + pure fn ne(&&other: cleantype) -> bool { !self.eq(other) } } // Used to remember and reuse existing cleanup paths @@ -1114,12 +1115,14 @@ impl mono_param_id: cmp::Eq { (mono_repr(*), _) => false } } + pure fn ne(&&other: mono_param_id) -> bool { !self.eq(other) } } 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) } } pure fn hash_mono_id(mi: &mono_id) -> uint { diff --git a/src/rustc/middle/trans/datum.rs b/src/rustc/middle/trans/datum.rs index 539439ecc81..f2525ce90b0 100644 --- a/src/rustc/middle/trans/datum.rs +++ b/src/rustc/middle/trans/datum.rs @@ -748,4 +748,5 @@ impl CopyAction : cmp::Eq { (DROP_EXISTING, _) => false, } } + pure fn ne(&&other: CopyAction) -> bool { !self.eq(other) } } diff --git a/src/rustc/middle/trans/expr.rs b/src/rustc/middle/trans/expr.rs index 118eff8c53b..b1ee870dbb5 100644 --- a/src/rustc/middle/trans/expr.rs +++ b/src/rustc/middle/trans/expr.rs @@ -157,6 +157,7 @@ impl Dest : cmp::Eq { (Ignore, _) => false, } } + pure fn ne(&&other: Dest) -> bool { !self.eq(other) } } fn trans_to_appropriate_llval(bcx: block, @@ -1265,6 +1266,7 @@ impl cast_kind : cmp::Eq { (cast_other, _) => false, } } + pure fn ne(&&other: cast_kind) -> bool { !self.eq(other) } } fn cast_type_kind(t: ty::t) -> cast_kind { @@ -1381,4 +1383,4 @@ fn trans_assign_op(bcx: block, fn shorten(+x: ~str) -> ~str { if x.len() > 60 { x.substr(0, 60) } else { x } -} \ No newline at end of file +} diff --git a/src/rustc/middle/trans/foreign.rs b/src/rustc/middle/trans/foreign.rs index bb5ea98e1b4..c5cb5ee300b 100644 --- a/src/rustc/middle/trans/foreign.rs +++ b/src/rustc/middle/trans/foreign.rs @@ -44,6 +44,7 @@ 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 { diff --git a/src/rustc/middle/ty.rs b/src/rustc/middle/ty.rs index dd48c2183a7..fa2f021c9b2 100644 --- a/src/rustc/middle/ty.rs +++ b/src/rustc/middle/ty.rs @@ -234,6 +234,7 @@ impl intern_key: cmp::Eq { pure fn eq(&&other: intern_key) -> bool { self.struct == other.struct && self.o_def_id == other.o_def_id } + pure fn ne(&&other: intern_key) -> bool { !self.eq(other) } } enum ast_ty_to_ty_cache_entry { @@ -258,6 +259,7 @@ impl region_variance: cmp::Eq { (rv_contravariant, _) => false } } + pure fn ne(&&other: region_variance) -> bool { !self.eq(other) } } // N.B.: Borrows from inlined content are not accurately deserialized. This @@ -272,6 +274,7 @@ impl borrow : cmp::Eq { pure fn eq(&&other: borrow) -> bool { self.region == other.region && self.mutbl == other.mutbl } + pure fn ne(&&other: borrow) -> bool { !self.eq(other) } } type ctxt = @@ -367,6 +370,7 @@ 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 { @@ -391,6 +395,7 @@ impl fn_proto : cmp::Eq { } } } + pure fn ne(&&other: fn_proto) -> bool { !self.eq(other) } } /** @@ -436,6 +441,7 @@ 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) } } /// Representation of regions: @@ -3709,18 +3715,21 @@ 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) } } 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) } } 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) } } impl vstore : cmp::Eq { @@ -3752,6 +3761,7 @@ impl vstore : cmp::Eq { } } } + pure fn ne(&&other: vstore) -> bool { !self.eq(other) } } impl FnMeta : cmp::Eq { @@ -3761,6 +3771,7 @@ impl FnMeta : cmp::Eq { self.bounds == other.bounds && self.ret_style == other.ret_style } + pure fn ne(&&other: FnMeta) -> bool { !self.eq(other) } } impl FnSig : cmp::Eq { @@ -3768,36 +3779,35 @@ impl FnSig : cmp::Eq { self.inputs == other.inputs && self.output == other.output } + pure fn ne(&&other: FnSig) -> bool { !self.eq(other) } + } impl FnTyBase : cmp::Eq { pure fn eq(&&other: FnTyBase) -> bool { self.meta == other.meta && self.sig == other.sig } + pure fn ne(&&other: FnTyBase) -> bool { !self.eq(other) } } impl TyVid: cmp::Eq { - pure fn eq(&&other: TyVid) -> bool { - *self == *other - } + pure fn eq(&&other: TyVid) -> bool { *self == *other } + pure fn ne(&&other: TyVid) -> bool { *self != *other } } impl IntVid: cmp::Eq { - pure fn eq(&&other: IntVid) -> bool { - *self == *other - } + pure fn eq(&&other: IntVid) -> bool { *self == *other } + pure fn ne(&&other: IntVid) -> bool { *self != *other } } impl FnVid: cmp::Eq { - pure fn eq(&&other: FnVid) -> bool { - *self == *other - } + pure fn eq(&&other: FnVid) -> bool { *self == *other } + pure fn ne(&&other: FnVid) -> bool { *self != *other } } impl RegionVid: cmp::Eq { - pure fn eq(&&other: RegionVid) -> bool { - *self == *other - } + pure fn eq(&&other: RegionVid) -> bool { *self == *other } + pure fn ne(&&other: RegionVid) -> bool { *self != *other } } impl region : cmp::Eq { @@ -3835,6 +3845,7 @@ impl region : cmp::Eq { } } } + pure fn ne(&&other: region) -> bool { !self.eq(other) } } impl bound_region : cmp::Eq { @@ -3866,6 +3877,7 @@ impl bound_region : cmp::Eq { } } } + pure fn ne(&&other: bound_region) -> bool { !self.eq(other) } } impl substs : cmp::Eq { @@ -3874,12 +3886,14 @@ impl substs : cmp::Eq { self.self_ty == other.self_ty && self.tps == other.tps } + pure fn ne(&&other: substs) -> bool { !self.eq(other) } } 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) } } impl sty : cmp::Eq { @@ -4038,6 +4052,7 @@ impl sty : cmp::Eq { } } } + pure fn ne(&&other: sty) -> bool { !self.eq(other) } } impl param_bound : cmp::Eq { @@ -4075,12 +4090,12 @@ impl param_bound : cmp::Eq { } } } + pure fn ne(&&other: param_bound) -> bool { !self.eq(other) } } impl kind : cmp::Eq { - pure fn eq(&&other: kind) -> bool { - *self == *other - } + pure fn eq(&&other: kind) -> bool { *self == *other } + pure fn ne(&&other: kind) -> bool { *self != *other } } diff --git a/src/rustc/middle/typeck/infer/region_var_bindings.rs b/src/rustc/middle/typeck/infer/region_var_bindings.rs index b34ffef811a..96d0cf9c110 100644 --- a/src/rustc/middle/typeck/infer/region_var_bindings.rs +++ b/src/rustc/middle/typeck/infer/region_var_bindings.rs @@ -346,6 +346,7 @@ impl Constraint: cmp::Eq { (ConstrainVarSubReg(*), _) => false } } + pure fn ne(&&other: Constraint) -> bool { !self.eq(other) } } struct TwoRegions { @@ -357,6 +358,7 @@ 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) } } enum UndoLogEntry { @@ -753,6 +755,7 @@ 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 } @@ -761,6 +764,7 @@ 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 } diff --git a/src/rustdoc/config.rs b/src/rustdoc/config.rs index f5d1bea493b..b0c01025320 100644 --- a/src/rustdoc/config.rs +++ b/src/rustdoc/config.rs @@ -22,6 +22,7 @@ impl output_format : cmp::Eq { pure fn eq(&&other: output_format) -> bool { (self as uint) == (other as uint) } + pure fn ne(&&other: output_format) -> bool { !self.eq(other) } } /// How to organize the output @@ -36,6 +37,7 @@ impl output_style : cmp::Eq { pure fn eq(&&other: output_style) -> bool { (self as uint) == (other as uint) } + pure fn ne(&&other: output_style) -> bool { !self.eq(other) } } /// The configuration for a rustdoc session diff --git a/src/rustdoc/doc.rs b/src/rustdoc/doc.rs index 68d7ba045e8..5161fdff270 100644 --- a/src/rustdoc/doc.rs +++ b/src/rustdoc/doc.rs @@ -10,6 +10,7 @@ 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 { @@ -17,9 +18,8 @@ enum doc { } impl doc : cmp::Eq { - pure fn eq(&&other: doc) -> bool { - *self == *other - } + pure fn eq(&&other: doc) -> bool { *self == *other } + pure fn ne(&&other: doc) -> bool { *self != *other } } enum page { @@ -44,6 +44,7 @@ impl page : cmp::Eq { } } } + pure fn ne(&&other: page) -> bool { !self.eq(other) } } enum implementation { @@ -55,6 +56,7 @@ 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) } } @@ -71,6 +73,7 @@ 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 @@ -84,6 +87,7 @@ 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 { @@ -150,6 +154,7 @@ impl itemtag : cmp::Eq { } } } + pure fn ne(&&other: itemtag) -> bool { !self.eq(other) } } type itemdoc = { @@ -173,6 +178,7 @@ impl itemdoc : cmp::Eq { self.sections == other.sections && self.reexport == other.reexport } + pure fn ne(&&other: itemdoc) -> bool { !self.eq(other) } } type simpleitemdoc = { @@ -184,6 +190,7 @@ 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_ = { @@ -198,6 +205,7 @@ impl moddoc_ : cmp::Eq { self.items == other.items && self.index == other.index } + pure fn ne(&&other: moddoc_) -> bool { !self.eq(other) } } enum moddoc { @@ -205,9 +213,8 @@ enum moddoc { } impl moddoc : cmp::Eq { - pure fn eq(&&other: moddoc) -> bool { - *self == *other - } + pure fn eq(&&other: moddoc) -> bool { *self == *other } + pure fn ne(&&other: moddoc) -> bool { *self != *other } } type nmoddoc = { @@ -222,6 +229,7 @@ impl nmoddoc : cmp::Eq { self.fns == other.fns && self.index == other.index } + pure fn ne(&&other: nmoddoc) -> bool { !self.eq(other) } } type constdoc = simpleitemdoc; @@ -237,6 +245,7 @@ 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 = { @@ -251,6 +260,7 @@ impl variantdoc : cmp::Eq { self.desc == other.desc && self.sig == other.sig } + pure fn ne(&&other: variantdoc) -> bool { !self.eq(other) } } type traitdoc = { @@ -262,6 +272,7 @@ 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 = { @@ -282,6 +293,7 @@ impl methoddoc : cmp::Eq { self.sig == other.sig && self.implementation == other.implementation } + pure fn ne(&&other: methoddoc) -> bool { !self.eq(other) } } type impldoc = { @@ -298,6 +310,7 @@ impl impldoc : cmp::Eq { self.self_ty == other.self_ty && self.methods == other.methods } + pure fn ne(&&other: impldoc) -> bool { !self.eq(other) } } type tydoc = simpleitemdoc; @@ -310,6 +323,7 @@ impl index : cmp::Eq { pure fn eq(&&other: index) -> bool { self.entries == other.entries } + pure fn ne(&&other: index) -> bool { !self.eq(other) } } /** @@ -336,6 +350,7 @@ impl index_entry : cmp::Eq { self.brief == other.brief && self.link == other.link } + pure fn ne(&&other: index_entry) -> bool { !self.eq(other) } } impl doc { diff --git a/src/test/run-pass/auto_serialize.rs b/src/test/run-pass/auto_serialize.rs index 112579b808f..0599a6657e6 100644 --- a/src/test/run-pass/auto_serialize.rs +++ b/src/test/run-pass/auto_serialize.rs @@ -46,13 +46,14 @@ impl an_enum : cmp::Eq { pure fn eq(&&other: an_enum) -> bool { self.v == other.v } + 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 + self.x == other.x && self.y == other.y } + pure fn ne(&&other: point) -> bool { !self.eq(other) } } impl quark : cmp::Eq { @@ -68,6 +69,7 @@ impl quark : cmp::Eq { } } } + pure fn ne(&&other: quark) -> bool { !self.eq(other) } } @@ -75,6 +77,7 @@ impl c_like : cmp::Eq { pure fn eq(&&other: c_like) -> bool { self as int == other as int } + pure fn ne(&&other: c_like) -> bool { !self.eq(other) } } impl expr : cmp::Eq { @@ -100,6 +103,7 @@ impl expr : cmp::Eq { } } } + pure fn ne(&&other: expr) -> bool { !self.eq(other) } } #[auto_serialize] @@ -109,6 +113,7 @@ impl spanned : cmp::Eq { pure fn eq(&&other: spanned) -> bool { self.lo == other.lo && self.hi == other.hi && self.node.eq(other.node) } + pure fn ne(&&other: spanned) -> bool { !self.eq(other) } } #[auto_serialize] diff --git a/src/test/run-pass/binops.rs b/src/test/run-pass/binops.rs index 1cad6feef88..88391d95259 100644 --- a/src/test/run-pass/binops.rs +++ b/src/test/run-pass/binops.rs @@ -93,6 +93,7 @@ impl p : cmp::Eq { pure fn eq(&&other: p) -> bool { self.x == other.x && self.y == other.y } + pure fn ne(&&other: p) -> bool { !self.eq(other) } } fn test_class() { diff --git a/src/test/run-pass/class-impl-very-parameterized-trait.rs b/src/test/run-pass/class-impl-very-parameterized-trait.rs index dee9e9c79de..ba878327d9b 100644 --- a/src/test/run-pass/class-impl-very-parameterized-trait.rs +++ b/src/test/run-pass/class-impl-very-parameterized-trait.rs @@ -7,6 +7,7 @@ impl cat_type : cmp::Eq { pure fn eq(&&other: cat_type) -> bool { (self as uint) == (other as uint) } + pure fn ne(&&other: cat_type) -> bool { !self.eq(other) } } // Very silly -- this just returns the value of the name field diff --git a/src/test/run-pass/coherence-impl-in-fn.rs b/src/test/run-pass/coherence-impl-in-fn.rs index fb8b37ce2cd..f69c8782c9a 100644 --- a/src/test/run-pass/coherence-impl-in-fn.rs +++ b/src/test/run-pass/coherence-impl-in-fn.rs @@ -2,5 +2,6 @@ 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) } } } diff --git a/src/test/run-pass/const-struct.rs b/src/test/run-pass/const-struct.rs index a489ea3d1a8..653150e68f7 100644 --- a/src/test/run-pass/const-struct.rs +++ b/src/test/run-pass/const-struct.rs @@ -5,6 +5,7 @@ impl foo : cmp::Eq { 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) } } const x : foo = foo { a:1, b:2, c: 3 }; diff --git a/src/test/run-pass/empty-tag.rs b/src/test/run-pass/empty-tag.rs index d375f0638db..0b736be2168 100644 --- a/src/test/run-pass/empty-tag.rs +++ b/src/test/run-pass/empty-tag.rs @@ -4,6 +4,7 @@ impl chan : cmp::Eq { pure fn eq(&&other: chan) -> bool { (self as uint) == (other as uint) } + pure fn ne(&&other: chan) -> bool { !self.eq(other) } } fn wrapper3(i: chan) { diff --git a/src/test/run-pass/export-unexported-dep.rs b/src/test/run-pass/export-unexported-dep.rs index 22858fa464b..3d634fa55a5 100644 --- a/src/test/run-pass/export-unexported-dep.rs +++ b/src/test/run-pass/export-unexported-dep.rs @@ -12,6 +12,7 @@ mod foo { pure fn eq(&&other: t) -> bool { (self as uint) == (other as uint) } + pure fn ne(&&other: t) -> bool { !self.eq(other) } } fn f() -> t { return t1; } diff --git a/src/test/run-pass/expr-alt-struct.rs b/src/test/run-pass/expr-alt-struct.rs index 73b059eadf5..c4d50c33139 100644 --- a/src/test/run-pass/expr-alt-struct.rs +++ b/src/test/run-pass/expr-alt-struct.rs @@ -14,6 +14,7 @@ impl mood : cmp::Eq { pure fn eq(&&other: mood) -> bool { (self as uint) == (other as uint) } + pure fn ne(&&other: mood) -> bool { !self.eq(other) } } fn test_tag() { diff --git a/src/test/run-pass/expr-if-struct.rs b/src/test/run-pass/expr-if-struct.rs index e96b6baaec5..62fc904a82c 100644 --- a/src/test/run-pass/expr-if-struct.rs +++ b/src/test/run-pass/expr-if-struct.rs @@ -14,6 +14,7 @@ impl mood : cmp::Eq { pure fn eq(&&other: mood) -> bool { (self as uint) == (other as uint) } + pure fn ne(&&other: mood) -> bool { !self.eq(other) } } fn test_tag() { diff --git a/src/test/run-pass/issue-2718.rs b/src/test/run-pass/issue-2718.rs index 7af8d3672c2..8508d251b64 100644 --- a/src/test/run-pass/issue-2718.rs +++ b/src/test/run-pass/issue-2718.rs @@ -12,6 +12,7 @@ mod pipes { pure fn eq(&&other: state) -> bool { (self as uint) == (other as uint) } + pure fn ne(&&other: state) -> bool { !self.eq(other) } } type packet = { diff --git a/src/test/run-pass/operator-overloading.rs b/src/test/run-pass/operator-overloading.rs index 92bde631fcf..37e249b6cf0 100644 --- a/src/test/run-pass/operator-overloading.rs +++ b/src/test/run-pass/operator-overloading.rs @@ -31,6 +31,7 @@ impl Point : cmp::Eq { pure fn eq(&&other: Point) -> bool { self.x == other.x && self.y == other.y } + pure fn ne(&&other: Point) -> bool { !self.eq(other) } } fn main() { diff --git a/src/test/run-pass/structured-compare.rs b/src/test/run-pass/structured-compare.rs index 51733ab29e8..06b3cb3c3f6 100644 --- a/src/test/run-pass/structured-compare.rs +++ b/src/test/run-pass/structured-compare.rs @@ -6,6 +6,7 @@ impl foo : cmp::Eq { pure fn eq(&&other: foo) -> bool { (self as uint) == (other as uint) } + pure fn ne(&&other: foo) -> bool { !self.eq(other) } } fn main() { diff --git a/src/test/run-pass/tag-variant-disr-val.rs b/src/test/run-pass/tag-variant-disr-val.rs index 7182dad62ee..f0dce1f6247 100644 --- a/src/test/run-pass/tag-variant-disr-val.rs +++ b/src/test/run-pass/tag-variant-disr-val.rs @@ -13,6 +13,7 @@ impl color : cmp::Eq { pure fn eq(&&other: color) -> bool { (self as uint) == (other as uint) } + pure fn ne(&&other: color) -> bool { !self.eq(other) } } fn main() { diff --git a/src/test/run-pass/task-comm-16.rs b/src/test/run-pass/task-comm-16.rs index 247d5f4bd40..defa0de79a1 100644 --- a/src/test/run-pass/task-comm-16.rs +++ b/src/test/run-pass/task-comm-16.rs @@ -71,6 +71,7 @@ impl t : cmp::Eq { } } } + pure fn ne(&&other: t) -> bool { !self.eq(other) } } fn test_tag() {