From 653ffa845d70b26a49e227ae4445729c369c9f80 Mon Sep 17 00:00:00 2001 From: Lindsey Kuper Date: Sat, 14 Sep 2013 19:34:03 -0400 Subject: [PATCH 1/2] Kill off method impls made redundant by default methods. --- src/libsyntax/ast_util.rs | 39 --------------------------------------- 1 file changed, 39 deletions(-) diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index 965f4a49aec5..67c47093ff62 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -519,20 +519,11 @@ fn visit_stmt(&mut self, statement: @Stmt, env: ()) { visit::walk_stmt(self, statement, env) } - // XXX: Default - fn visit_arm(&mut self, arm: &Arm, env: ()) { - visit::walk_arm(self, arm, env) - } - fn visit_pat(&mut self, pattern: @Pat, env: ()) { (self.visit_callback)(pattern.id); visit::walk_pat(self, pattern, env) } - // XXX: Default - fn visit_decl(&mut self, declaration: @Decl, env: ()) { - visit::walk_decl(self, declaration, env) - } fn visit_expr(&mut self, expression: @Expr, env: ()) { { @@ -545,11 +536,6 @@ fn visit_expr(&mut self, expression: @Expr, env: ()) { visit::walk_expr(self, expression, env) } - // XXX: Default - fn visit_expr_post(&mut self, _: @Expr, _: ()) { - // Empty! - } - fn visit_ty(&mut self, typ: &Ty, env: ()) { (self.visit_callback)(typ.id); match typ.node { @@ -612,31 +598,6 @@ fn visit_fn(&mut self, } } - // XXX: Default - fn visit_ty_method(&mut self, type_method: &TypeMethod, env: ()) { - visit::walk_ty_method(self, type_method, env) - } - - // XXX: Default - fn visit_trait_method(&mut self, trait_method: &trait_method, env: ()) { - visit::walk_trait_method(self, trait_method, env) - } - - // XXX: Default - fn visit_struct_def(&mut self, - struct_definition: @struct_def, - identifier: Ident, - generics: &Generics, - node_id: NodeId, - env: ()) { - visit::walk_struct_def(self, - struct_definition, - identifier, - generics, - node_id, - env) - } - fn visit_struct_field(&mut self, struct_field: @struct_field, env: ()) { (self.visit_callback)(struct_field.node.id); visit::walk_struct_field(self, struct_field, env) From 6ba2cb88a6866f96f26f2906654f03f97dd8e53b Mon Sep 17 00:00:00 2001 From: Lindsey Kuper Date: Sat, 14 Sep 2013 19:37:39 -0400 Subject: [PATCH 2/2] These impls, at least, can be avoided by deriving Ord. --- src/libsyntax/codemap.rs | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index 1c3a8e81e552..c8e40b82e0c3 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -30,12 +30,12 @@ pub trait Pos { } /// A byte offset -#[deriving(Clone, Eq, IterBytes)] +#[deriving(Clone, Eq, IterBytes, Ord)] 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,IterBytes)] +#[deriving(Eq,IterBytes, Ord)] pub struct CharPos(uint); // XXX: Lots of boilerplate in these impls, but so far my attempts to fix @@ -46,13 +46,6 @@ fn from_uint(n: uint) -> BytePos { BytePos(n) } fn to_uint(&self) -> uint { **self } } -impl cmp::Ord for BytePos { - fn lt(&self, other: &BytePos) -> bool { **self < **other } - fn le(&self, other: &BytePos) -> bool { **self <= **other } - fn ge(&self, other: &BytePos) -> bool { **self >= **other } - fn gt(&self, other: &BytePos) -> bool { **self > **other } -} - impl Add for BytePos { fn add(&self, rhs: &BytePos) -> BytePos { BytePos(**self + **rhs) @@ -70,13 +63,6 @@ fn from_uint(n: uint) -> CharPos { CharPos(n) } fn to_uint(&self) -> uint { **self } } -impl cmp::Ord for CharPos { - fn lt(&self, other: &CharPos) -> bool { **self < **other } - fn le(&self, other: &CharPos) -> bool { **self <= **other } - fn ge(&self, other: &CharPos) -> bool { **self >= **other } - fn gt(&self, other: &CharPos) -> bool { **self > **other } -} - impl Add for CharPos { fn add(&self, rhs: &CharPos) -> CharPos { CharPos(**self + **rhs)