From f02ee42a869fea6fbfcea27b79fb71fbd5a055ec Mon Sep 17 00:00:00 2001 From: Andrew Paseltiner Date: Tue, 26 Mar 2013 08:04:54 -0400 Subject: derive Eq and Clone impls where applicable --- src/libsyntax/attr.rs | 9 +-------- src/libsyntax/codemap.rs | 12 ++---------- src/libsyntax/parse/comments.rs | 11 +---------- 3 files changed, 4 insertions(+), 28 deletions(-) (limited to 'src/libsyntax') diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index b22d71afaed..90e8c0aa616 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 c082f4c0838..b086670956e 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 1b6b25db38a..e5685cdb4c7 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], -- cgit 1.4.1-3-g733a5