diff --git a/src/librustc/middle/liveness.rs b/src/librustc/middle/liveness.rs index 15fc4317bf3a8..4d6226a5db697 100644 --- a/src/librustc/middle/liveness.rs +++ b/src/librustc/middle/liveness.rs @@ -111,7 +111,6 @@ use middle::typeck; use middle::moves; use util::ppaux::ty_to_str; -use core::cmp; use core::hashmap::linear::LinearMap; use core::io::WriterUtil; use core::io; @@ -137,19 +136,12 @@ use syntax::{visit, ast_util}; // if it detects an outstanding loan (that is, the addr is taken). pub type last_use_map = @mut LinearMap; +#[deriving(Eq)] struct Variable(uint); +#[deriving(Eq)] struct LiveNode(uint); -impl cmp::Eq for Variable { - fn eq(&self, other: &Variable) -> bool { *(*self) == *(*other) } - fn ne(&self, other: &Variable) -> bool { *(*self) != *(*other) } -} - -impl cmp::Eq for LiveNode { - fn eq(&self, other: &LiveNode) -> bool { *(*self) == *(*other) } - fn ne(&self, other: &LiveNode) -> bool { *(*self) != *(*other) } -} - +#[deriving(Eq)] enum LiveNodeKind { FreeVarNode(span), ExprNode(span), @@ -157,38 +149,6 @@ enum LiveNodeKind { ExitNode } -impl cmp::Eq for LiveNodeKind { - fn eq(&self, other: &LiveNodeKind) -> bool { - match (*self) { - FreeVarNode(e0a) => { - match (*other) { - FreeVarNode(e0b) => e0a == e0b, - _ => false - } - } - ExprNode(e0a) => { - match (*other) { - ExprNode(e0b) => e0a == e0b, - _ => false - } - } - VarDefNode(e0a) => { - match (*other) { - VarDefNode(e0b) => e0a == e0b, - _ => false - } - } - ExitNode => { - match (*other) { - ExitNode => true, - _ => false - } - } - } - } - fn ne(&self, other: &LiveNodeKind) -> bool { !(*self).eq(other) } -} - fn live_node_kind_to_str(lnk: LiveNodeKind, cx: ty::ctxt) -> ~str { let cm = cx.sess.codemap; match lnk { diff --git a/src/librustc/middle/trans/cabi_x86_64.rs b/src/librustc/middle/trans/cabi_x86_64.rs index 4d0ad2c19f115..e9769f14b72da 100644 --- a/src/librustc/middle/trans/cabi_x86_64.rs +++ b/src/librustc/middle/trans/cabi_x86_64.rs @@ -18,13 +18,13 @@ use lib::llvm::struct_tys; use middle::trans::common::*; use middle::trans::cabi::*; -use core::cmp; use core::libc::c_uint; use core::option; use core::option::Option; use core::uint; use core::vec; +#[deriving(Eq)] enum x86_64_reg_class { no_class, integer_class, @@ -40,13 +40,6 @@ enum x86_64_reg_class { memory_class } -impl cmp::Eq for x86_64_reg_class { - fn eq(&self, other: &x86_64_reg_class) -> bool { - ((*self) as uint) == ((*other) as uint) - } - fn ne(&self, other: &x86_64_reg_class) -> bool { !(*self).eq(other) } -} - fn is_sse(++c: x86_64_reg_class) -> bool { return match c { sse_fs_class | sse_fv_class | diff --git a/src/librustc/middle/trans/datum.rs b/src/librustc/middle/trans/datum.rs index f81973e169daa..164f6fe44fc6d 100644 --- a/src/librustc/middle/trans/datum.rs +++ b/src/librustc/middle/trans/datum.rs @@ -104,7 +104,6 @@ use middle::ty; use util::common::indenter; use util::ppaux::ty_to_str; -use core::cmp; use core::container::Set; // XXX: this should not be necessary use core::to_bytes; use core::uint; @@ -140,6 +139,7 @@ pub struct DatumBlock { datum: Datum, } +#[deriving(Eq)] pub enum DatumMode { /// `val` is a pointer to the actual value (and thus has type *T) ByRef, @@ -158,13 +158,6 @@ pub impl DatumMode { } } -impl cmp::Eq for DatumMode { - fn eq(&self, other: &DatumMode) -> bool { - (*self) as uint == (*other as uint) - } - fn ne(&self, other: &DatumMode) -> bool { !(*self).eq(other) } -} - impl to_bytes::IterBytes for DatumMode { fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) { (*self as uint).iter_bytes(lsb0, f) diff --git a/src/librustc/middle/trans/expr.rs b/src/librustc/middle/trans/expr.rs index 0da1a9acef212..3e1496692ae47 100644 --- a/src/librustc/middle/trans/expr.rs +++ b/src/librustc/middle/trans/expr.rs @@ -160,6 +160,7 @@ use syntax::codemap; // These are passed around by the code generating functions to track the // destination of a computation's value. +#[deriving(Eq)] pub enum Dest { SaveIn(ValueRef), Ignore, @@ -174,18 +175,6 @@ pub impl Dest { } } -impl cmp::Eq for Dest { - fn eq(&self, other: &Dest) -> bool { - match ((*self), (*other)) { - (SaveIn(e0a), SaveIn(e0b)) => e0a == e0b, - (Ignore, Ignore) => true, - (SaveIn(*), _) => false, - (Ignore, _) => false, - } - } - fn ne(&self, other: &Dest) -> bool { !(*self).eq(other) } -} - fn drop_and_cancel_clean(bcx: block, dat: Datum) -> block { let bcx = dat.drop_val(bcx); dat.cancel_clean(bcx); @@ -1682,6 +1671,7 @@ fn float_cast(bcx: block, lldsttype: TypeRef, llsrctype: TypeRef, } else { llsrc }; } +#[deriving(Eq)] pub enum cast_kind { cast_pointer, cast_integral, @@ -1690,24 +1680,6 @@ pub enum cast_kind { cast_other, } -impl cmp::Eq for cast_kind { - fn eq(&self, other: &cast_kind) -> bool { - match ((*self), (*other)) { - (cast_pointer, cast_pointer) => true, - (cast_integral, cast_integral) => true, - (cast_float, cast_float) => true, - (cast_enum, cast_enum) => true, - (cast_other, cast_other) => true, - (cast_pointer, _) => false, - (cast_integral, _) => false, - (cast_float, _) => false, - (cast_enum, _) => false, - (cast_other, _) => false, - } - } - fn ne(&self, other: &cast_kind) -> bool { !(*self).eq(other) } -} - pub fn cast_type_kind(t: ty::t) -> cast_kind { match ty::get(t).sty { ty::ty_float(*) => cast_float, diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 0d36453c75739..088d8183d4818 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -76,6 +76,7 @@ pub struct method { def_id: ast::def_id } +#[deriving(Eq)] pub struct mt { ty: t, mutbl: ast::mutability, @@ -161,22 +162,9 @@ pub type opt_region_variance = Option; #[auto_encode] #[auto_decode] +#[deriving(Eq)] pub enum region_variance { rv_covariant, rv_invariant, rv_contravariant } -impl cmp::Eq for region_variance { - fn eq(&self, other: ®ion_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 - } - } - fn ne(&self, other: ®ion_variance) -> bool { !(*self).eq(other) } -} - #[auto_encode] #[auto_decode] pub enum AutoAdjustment { @@ -417,6 +405,7 @@ impl to_bytes::IterBytes for param_ty { /// Representation of regions: #[auto_encode] #[auto_decode] +#[deriving(Eq)] pub enum Region { /// Bound regions are found (primarily) in function types. They indicate /// region parameters that have yet to be replaced with actual regions @@ -446,6 +435,7 @@ pub enum Region { #[auto_encode] #[auto_decode] +#[deriving(Eq)] pub enum bound_region { /// The self region for structs, impls (&T in a type defn or &'self T) br_self, @@ -585,6 +575,7 @@ pub enum type_err { terr_float_mismatch(expected_found) } +#[deriving(Eq)] pub enum param_bound { bound_copy, bound_durable, @@ -4367,127 +4358,6 @@ pub fn get_impl_id(tcx: ctxt, trait_id: def_id, self_ty: t) -> def_id { } } -impl cmp::Eq for mt { - fn eq(&self, other: &mt) -> bool { - (*self).ty == (*other).ty && (*self).mutbl == (*other).mutbl - } - fn ne(&self, other: &mt) -> bool { !(*self).eq(other) } -} - -impl cmp::Eq for Region { - fn eq(&self, other: &Region) -> bool { - match (*self) { - re_bound(e0a) => { - match (*other) { - re_bound(e0b) => e0a == e0b, - _ => false - } - } - re_free(e0a, e1a) => { - match (*other) { - re_free(e0b, e1b) => e0a == e0b && e1a == e1b, - _ => false - } - } - re_scope(e0a) => { - match (*other) { - re_scope(e0b) => e0a == e0b, - _ => false - } - } - re_static => { - match (*other) { - re_static => true, - _ => false - } - } - re_infer(e0a) => { - match (*other) { - re_infer(e0b) => e0a == e0b, - _ => false - } - } - } - } - fn ne(&self, other: &Region) -> bool { !(*self).eq(other) } -} - -impl cmp::Eq for bound_region { - fn eq(&self, other: &bound_region) -> bool { - match (*self) { - br_self => { - match (*other) { - br_self => true, - _ => false - } - } - br_anon(e0a) => { - match (*other) { - br_anon(e0b) => e0a == e0b, - _ => false - } - } - br_named(e0a) => { - match (*other) { - br_named(e0b) => e0a == e0b, - _ => false - } - } - br_cap_avoid(e0a, e1a) => { - match (*other) { - br_cap_avoid(e0b, e1b) => e0a == e0b && e1a == e1b, - _ => false - } - } - br_fresh(e0a) => { - match (*other) { - br_fresh(e0b) => e0a == e0b, - _ => false - } - } - } - } - fn ne(&self, other: &bound_region) -> bool { !(*self).eq(other) } -} - -impl cmp::Eq for param_bound { - fn eq(&self, other: ¶m_bound) -> bool { - match (*self) { - bound_copy => { - match (*other) { - bound_copy => true, - _ => false - } - } - bound_durable => { - match (*other) { - bound_durable => true, - _ => false - } - } - bound_owned => { - match (*other) { - bound_owned => true, - _ => false - } - } - bound_const => { - match (*other) { - bound_const => true, - _ => false - } - } - bound_trait(e0a) => { - match (*other) { - bound_trait(e0b) => e0a == e0b, - _ => false - } - } - } - } - fn ne(&self, other: ¶m_bound) -> bool { !self.eq(other) } -} - // Local Variables: // mode: rust // fill-column: 78; diff --git a/src/librustc/middle/typeck/infer/region_inference.rs b/src/librustc/middle/typeck/infer/region_inference.rs index 031363469cd0a..24d763eaee13f 100644 --- a/src/librustc/middle/typeck/infer/region_inference.rs +++ b/src/librustc/middle/typeck/infer/region_inference.rs @@ -548,7 +548,6 @@ use util::common::indenter; use util::ppaux::note_and_explain_region; use core::cell::{Cell, empty_cell}; -use core::cmp; use core::hashmap::linear::{LinearMap, LinearSet}; use core::result::{Err, Ok, Result}; use core::to_bytes; @@ -556,32 +555,13 @@ use core::uint; use core::vec; use syntax::codemap::span; +#[deriving(Eq)] enum Constraint { ConstrainVarSubVar(RegionVid, RegionVid), ConstrainRegSubVar(Region, RegionVid), ConstrainVarSubReg(RegionVid, Region) } -impl cmp::Eq for Constraint { - fn eq(&self, other: &Constraint) -> bool { - match ((*self), (*other)) { - (ConstrainVarSubVar(v0a, v1a), ConstrainVarSubVar(v0b, v1b)) => { - v0a == v0b && v1a == v1b - } - (ConstrainRegSubVar(ra, va), ConstrainRegSubVar(rb, vb)) => { - ra == rb && va == vb - } - (ConstrainVarSubReg(va, ra), ConstrainVarSubReg(vb, rb)) => { - va == vb && ra == rb - } - (ConstrainVarSubVar(*), _) => false, - (ConstrainRegSubVar(*), _) => false, - (ConstrainVarSubReg(*), _) => false - } - } - fn ne(&self, other: &Constraint) -> bool { !(*self).eq(other) } -} - impl to_bytes::IterBytes for Constraint { fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) { match *self { @@ -597,18 +577,12 @@ impl to_bytes::IterBytes for Constraint { } } +#[deriving(Eq)] struct TwoRegions { a: Region, b: Region, } -impl cmp::Eq for TwoRegions { - fn eq(&self, other: &TwoRegions) -> bool { - (*self).a == (*other).a && (*self).b == (*other).b - } - fn ne(&self, other: &TwoRegions) -> bool { !(*self).eq(other) } -} - impl to_bytes::IterBytes for TwoRegions { fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) { to_bytes::iter_bytes_2(&self.a, &self.b, lsb0, f) diff --git a/src/librustdoc/astsrv.rs b/src/librustdoc/astsrv.rs index 8f02b789121be..5bf7e18552ff6 100644 --- a/src/librustdoc/astsrv.rs +++ b/src/librustdoc/astsrv.rs @@ -45,18 +45,11 @@ enum Msg { Exit } +#[deriving(Clone)] pub struct Srv { ch: SharedChan } -impl Clone for Srv { - fn clone(&self) -> Srv { - Srv { - ch: self.ch.clone() - } - } -} - pub fn from_str(source: ~str, owner: SrvOwner) -> T { run(owner, copy source, parse::from_str_sess) } diff --git a/src/librustdoc/config.rs b/src/librustdoc/config.rs index 84f2f5191f31a..2b95d42f40e75 100644 --- a/src/librustdoc/config.rs +++ b/src/librustdoc/config.rs @@ -11,7 +11,6 @@ use core::prelude::*; use core::cell::Cell; -use core::cmp; use core::os; use core::result; use core::run; @@ -21,6 +20,7 @@ use core::result::Result; use std::getopts; /// The type of document to output +#[deriving(Eq)] pub enum OutputFormat { /// Markdown pub Markdown, @@ -28,14 +28,8 @@ pub enum OutputFormat { pub PandocHtml } -impl cmp::Eq for OutputFormat { - fn eq(&self, other: &OutputFormat) -> bool { - ((*self) as uint) == ((*other) as uint) - } - fn ne(&self, other: &OutputFormat) -> bool { !(*self).eq(other) } -} - /// How to organize the output +#[deriving(Eq)] pub enum OutputStyle { /// All in a single document pub DocPerCrate, @@ -43,13 +37,6 @@ pub enum OutputStyle { pub DocPerMod } -impl cmp::Eq for OutputStyle { - fn eq(&self, other: &OutputStyle) -> bool { - ((*self) as uint) == ((*other) as uint) - } - fn ne(&self, other: &OutputStyle) -> bool { !(*self).eq(other) } -} - /// The configuration for a rustdoc session pub struct Config { input_crate: Path, diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index b22d71afaed2d..90e8c0aa61680 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -19,7 +19,6 @@ use codemap::BytePos; use diagnostic::span_handler; use parse::comments::{doc_comment_style, strip_doc_comment_decoration}; -use core::cmp; use core::either::Either; use core::vec; use core::hashmap::linear::LinearSet; @@ -325,6 +324,7 @@ pub fn foreign_abi(attrs: &[ast::attribute]) }; } +#[deriving(Eq)] pub enum inline_attr { ia_none, ia_hint, @@ -332,13 +332,6 @@ pub enum inline_attr { ia_never, } -impl cmp::Eq for inline_attr { - fn eq(&self, other: &inline_attr) -> bool { - ((*self) as uint) == ((*other) as uint) - } - fn ne(&self, other: &inline_attr) -> bool { !(*self).eq(other) } -} - /// True if something like #[inline] is found in the list of attrs. pub fn find_inline_attr(attrs: &[ast::attribute]) -> inline_attr { // FIXME (#2809)---validate the usage of #[inline] and #[inline(always)] diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index c082f4c083850..b086670956e24 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -35,10 +35,12 @@ pub trait Pos { } /// A byte offset +#[deriving(Eq)] pub struct BytePos(uint); /// A character offset. Because of multibyte utf8 characters, a byte offset /// is not equivalent to a character offset. The CodeMap will convert BytePos /// values to CharPos values as necessary. +#[deriving(Eq)] pub struct CharPos(uint); // XXX: Lots of boilerplate in these impls, but so far my attempts to fix @@ -49,11 +51,6 @@ impl Pos for BytePos { fn to_uint(&self) -> uint { **self } } -impl cmp::Eq for BytePos { - fn eq(&self, other: &BytePos) -> bool { **self == **other } - fn ne(&self, other: &BytePos) -> bool { !(*self).eq(other) } -} - impl cmp::Ord for BytePos { fn lt(&self, other: &BytePos) -> bool { **self < **other } fn le(&self, other: &BytePos) -> bool { **self <= **other } @@ -84,11 +81,6 @@ impl Pos for CharPos { fn to_uint(&self) -> uint { **self } } -impl cmp::Eq for CharPos { - fn eq(&self, other: &CharPos) -> bool { **self == **other } - fn ne(&self, other: &CharPos) -> bool { !(*self).eq(other) } -} - impl cmp::Ord for CharPos { fn lt(&self, other: &CharPos) -> bool { **self < **other } fn le(&self, other: &CharPos) -> bool { **self <= **other } diff --git a/src/libsyntax/parse/comments.rs b/src/libsyntax/parse/comments.rs index 1b6b25db38ad6..e5685cdb4c7d1 100644 --- a/src/libsyntax/parse/comments.rs +++ b/src/libsyntax/parse/comments.rs @@ -20,13 +20,13 @@ use parse::lexer; use parse::token; use parse; -use core::cmp; use core::io::ReaderUtil; use core::io; use core::str; use core::uint; use core::vec; +#[deriving(Eq)] pub enum cmnt_style { isolated, // No code on either side of each line of the comment trailing, // Code exists to the left of the comment @@ -34,15 +34,6 @@ pub enum cmnt_style { blank_line, // Just a manual blank line "\n\n", for layout } -impl cmp::Eq for cmnt_style { - fn eq(&self, other: &cmnt_style) -> bool { - ((*self) as uint) == ((*other) as uint) - } - fn ne(&self, other: &cmnt_style) -> bool { - ((*self) as uint) != ((*other) as uint) - } -} - pub struct cmnt { style: cmnt_style, lines: ~[~str],