about summary refs log tree commit diff
path: root/src/libsyntax/ext
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2013-06-27 17:41:35 -0700
committerPatrick Walton <pcwalton@mimiga.net>2013-07-17 14:56:42 -0700
commitb4e674f6e662bc80f2e7a5a1a9834f2152f08d32 (patch)
tree1b567620d7ea1641fa58338b8f6e5c68bb324248 /src/libsyntax/ext
parent8c082658bed1877d5741f7badceb8efc3015598d (diff)
downloadrust-b4e674f6e662bc80f2e7a5a1a9834f2152f08d32.tar.gz
rust-b4e674f6e662bc80f2e7a5a1a9834f2152f08d32.zip
librustc: Add a lint mode for unnecessary `copy` and remove a bunch of them.
Diffstat (limited to 'src/libsyntax/ext')
-rw-r--r--src/libsyntax/ext/base.rs2
-rw-r--r--src/libsyntax/ext/build.rs6
-rw-r--r--src/libsyntax/ext/deriving/generic.rs2
-rw-r--r--src/libsyntax/ext/pipes/liveness.rs12
-rw-r--r--src/libsyntax/ext/pipes/mod.rs2
-rw-r--r--src/libsyntax/ext/pipes/pipec.rs19
-rw-r--r--src/libsyntax/ext/pipes/proto.rs5
-rw-r--r--src/libsyntax/ext/trace_macros.rs8
-rw-r--r--src/libsyntax/ext/tt/macro_rules.rs5
-rw-r--r--src/libsyntax/ext/tt/transcribe.rs2
10 files changed, 30 insertions, 33 deletions
diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs
index c9bd2986a42..0e464208de3 100644
--- a/src/libsyntax/ext/base.rs
+++ b/src/libsyntax/ext/base.rs
@@ -257,7 +257,7 @@ impl ExtCtxt {
                     Some(@ExpnInfo {
                         call_site: span {lo: cs.lo, hi: cs.hi,
                                          expn_info: *self.backtrace},
-                        callee: copy *callee});
+                        callee: *callee});
             }
         }
     }
diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs
index 83fce24bef8..89290b78b72 100644
--- a/src/libsyntax/ext/build.rs
+++ b/src/libsyntax/ext/build.rs
@@ -347,7 +347,7 @@ impl AstBuilder for @ExtCtxt {
 
     fn strip_bounds(&self, generics: &Generics) -> Generics {
         let new_params = do generics.ty_params.map |ty_param| {
-            ast::TyParam { bounds: opt_vec::Empty, ..copy *ty_param }
+            ast::TyParam { bounds: opt_vec::Empty, ..*ty_param }
         };
         Generics {
             ty_params: new_params,
@@ -611,13 +611,13 @@ impl AstBuilder for @ExtCtxt {
     }
     fn lambda0(&self, _span: span, blk: ast::blk) -> @ast::expr {
         let ext_cx = *self;
-        let blk_e = self.expr(copy blk.span, ast::expr_block(copy blk));
+        let blk_e = self.expr(blk.span, ast::expr_block(copy blk));
         quote_expr!(|| $blk_e )
     }
 
     fn lambda1(&self, _span: span, blk: ast::blk, ident: ast::ident) -> @ast::expr {
         let ext_cx = *self;
-        let blk_e = self.expr(copy blk.span, ast::expr_block(copy blk));
+        let blk_e = self.expr(blk.span, ast::expr_block(copy blk));
         quote_expr!(|$ident| $blk_e )
     }
 
diff --git a/src/libsyntax/ext/deriving/generic.rs b/src/libsyntax/ext/deriving/generic.rs
index 3bc16477c80..f90ee1f8d79 100644
--- a/src/libsyntax/ext/deriving/generic.rs
+++ b/src/libsyntax/ext/deriving/generic.rs
@@ -323,7 +323,7 @@ impl<'self> TraitDef<'self> {
         let mut trait_generics = self.generics.to_generics(cx, span, type_ident, generics);
         // Copy the lifetimes
         for generics.lifetimes.iter().advance |l| {
-            trait_generics.lifetimes.push(copy *l)
+            trait_generics.lifetimes.push(*l)
         };
         // Create the type parameters.
         for generics.ty_params.iter().advance |ty_param| {
diff --git a/src/libsyntax/ext/pipes/liveness.rs b/src/libsyntax/ext/pipes/liveness.rs
index b1f98d78fb3..6a8f3c89a2f 100644
--- a/src/libsyntax/ext/pipes/liveness.rs
+++ b/src/libsyntax/ext/pipes/liveness.rs
@@ -45,7 +45,7 @@ use extra::bitv::Bitv;
 pub fn analyze(proto: @mut protocol_, _cx: @ExtCtxt) {
     debug!("initializing colive analysis");
     let num_states = proto.num_states();
-    let mut colive: ~[~Bitv] = do (copy proto.states).iter().transform() |state| {
+    let mut colive: ~[~Bitv] = do proto.states.iter().transform() |state| {
         let mut bv = ~Bitv::new(num_states, false);
         for state.reachable |s| {
             bv.set(s.id, true);
@@ -85,10 +85,11 @@ pub fn analyze(proto: @mut protocol_, _cx: @ExtCtxt) {
     }
 
     if self_live.len() > 0 {
-        let states = self_live.map(|s| copy s.name).connect(" ");
+        let states = self_live.map(|s| s.name).connect(" ");
 
         debug!("protocol %s is unbounded due to loops involving: %s",
-               copy proto.name, states);
+               proto.name,
+               states);
 
         // Someday this will be configurable with a warning
         //cx.span_warn(empty_span(),
@@ -98,9 +99,8 @@ pub fn analyze(proto: @mut protocol_, _cx: @ExtCtxt) {
         //                   states));
 
         proto.bounded = Some(false);
-    }
-    else {
-        debug!("protocol %s is bounded. yay!", copy proto.name);
+    } else {
+        debug!("protocol %s is bounded. yay!", proto.name);
         proto.bounded = Some(true);
     }
 }
diff --git a/src/libsyntax/ext/pipes/mod.rs b/src/libsyntax/ext/pipes/mod.rs
index 165d3c39c6b..73c6c6d5fff 100644
--- a/src/libsyntax/ext/pipes/mod.rs
+++ b/src/libsyntax/ext/pipes/mod.rs
@@ -65,7 +65,7 @@ pub fn expand_proto(cx: @ExtCtxt, _sp: span, id: ast::ident,
                     tt: ~[ast::token_tree]) -> base::MacResult {
     let sess = cx.parse_sess();
     let cfg = cx.cfg();
-    let tt_rdr = new_tt_reader(copy cx.parse_sess().span_diagnostic,
+    let tt_rdr = new_tt_reader(cx.parse_sess().span_diagnostic,
                                None,
                                copy tt);
     let rdr = tt_rdr as @reader;
diff --git a/src/libsyntax/ext/pipes/pipec.rs b/src/libsyntax/ext/pipes/pipec.rs
index 478c0861990..e5581cada37 100644
--- a/src/libsyntax/ext/pipes/pipec.rs
+++ b/src/libsyntax/ext/pipes/pipec.rs
@@ -382,7 +382,7 @@ impl gen_init for protocol {
 
         cx.ty_path(path(~[cx.ident_of("super"),
                           cx.ident_of("__Buffer")],
-                        copy self.span)
+                        self.span)
                    .add_tys(cx.ty_vars_global(&params)), None)
     }
 
@@ -432,7 +432,7 @@ impl gen_init for protocol {
         let mut client_states = ~[];
         let mut server_states = ~[];
 
-        for (copy self.states).iter().advance |s| {
+        for self.states.iter().advance |s| {
             items.push_all_move(s.to_type_decls(cx));
 
             client_states.push_all_move(s.to_endpoint_decls(cx, send));
@@ -443,11 +443,11 @@ impl gen_init for protocol {
             items.push(self.gen_buffer_type(cx))
         }
 
-        items.push(cx.item_mod(copy self.span,
+        items.push(cx.item_mod(self.span,
                                cx.ident_of("client"),
                                ~[], ~[],
                                client_states));
-        items.push(cx.item_mod(copy self.span,
+        items.push(cx.item_mod(self.span,
                                cx.ident_of("server"),
                                ~[], ~[],
                                server_states));
@@ -455,12 +455,11 @@ impl gen_init for protocol {
         // XXX: Would be nice if our generated code didn't violate
         // Rust coding conventions
         let allows = cx.attribute(
-            copy self.span,
-            cx.meta_list(copy self.span,
+            self.span,
+            cx.meta_list(self.span,
                          @"allow",
-                         ~[cx.meta_word(copy self.span, @"non_camel_case_types"),
-                           cx.meta_word(copy self.span, @"unused_mut")]));
-        cx.item_mod(copy self.span, cx.ident_of(copy self.name),
-                    ~[allows], ~[], items)
+                         ~[cx.meta_word(self.span, @"non_camel_case_types"),
+                           cx.meta_word(self.span, @"unused_mut")]));
+        cx.item_mod(self.span, cx.ident_of(self.name), ~[allows], ~[], items)
     }
 }
diff --git a/src/libsyntax/ext/pipes/proto.rs b/src/libsyntax/ext/pipes/proto.rs
index 5866b8a5af5..92e1b2bd09f 100644
--- a/src/libsyntax/ext/pipes/proto.rs
+++ b/src/libsyntax/ext/pipes/proto.rs
@@ -214,9 +214,8 @@ pub trait visitor<Tproto, Tstate, Tmessage> {
 pub fn visit<Tproto, Tstate, Tmessage, V: visitor<Tproto, Tstate, Tmessage>>(
     proto: protocol, visitor: V) -> Tproto {
 
-    // the copy keywords prevent recursive use of dvec
-    let states: ~[Tstate] = do (copy proto.states).iter().transform |&s| {
-        let messages: ~[Tmessage] = do (copy s.messages).iter().transform |m| {
+    let states: ~[Tstate] = do proto.states.iter().transform |&s| {
+        let messages: ~[Tmessage] = do s.messages.iter().transform |m| {
             let message(name, span, tys, this, next) = copy *m;
             visitor.visit_message(name, span, tys, this, next)
         }.collect();
diff --git a/src/libsyntax/ext/trace_macros.rs b/src/libsyntax/ext/trace_macros.rs
index ba3b8f22e69..5c6032785e3 100644
--- a/src/libsyntax/ext/trace_macros.rs
+++ b/src/libsyntax/ext/trace_macros.rs
@@ -22,11 +22,9 @@ pub fn expand_trace_macros(cx: @ExtCtxt,
                         -> base::MacResult {
     let sess = cx.parse_sess();
     let cfg = cx.cfg();
-    let tt_rdr = new_tt_reader(
-        copy cx.parse_sess().span_diagnostic,
-        None,
-        tt.to_owned()
-    );
+    let tt_rdr = new_tt_reader(cx.parse_sess().span_diagnostic,
+                               None,
+                               tt.to_owned());
     let rdr = tt_rdr as @reader;
     let rust_parser = Parser(
         sess,
diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs
index a2e3d7bfeca..6b3ce1c9a2f 100644
--- a/src/libsyntax/ext/tt/macro_rules.rs
+++ b/src/libsyntax/ext/tt/macro_rules.rs
@@ -53,8 +53,9 @@ pub fn add_new_extension(cx: @ExtCtxt,
 
 
     // Parse the macro_rules! invocation (`none` is for no interpolations):
-    let arg_reader = new_tt_reader(copy cx.parse_sess().span_diagnostic,
-                                   None, copy arg);
+    let arg_reader = new_tt_reader(cx.parse_sess().span_diagnostic,
+                                   None,
+                                   copy arg);
     let argument_map = parse_or_else(cx.parse_sess(),
                                      cx.cfg(),
                                      arg_reader as @reader,
diff --git a/src/libsyntax/ext/tt/transcribe.rs b/src/libsyntax/ext/tt/transcribe.rs
index 92feaa154fe..94ecff178ea 100644
--- a/src/libsyntax/ext/tt/transcribe.rs
+++ b/src/libsyntax/ext/tt/transcribe.rs
@@ -285,7 +285,7 @@ pub fn tt_next_token(r: &mut TtReader) -> TokenAndSpan {
               }
               matched_seq(*) => {
                 r.sp_diag.span_fatal(
-                    copy r.cur_span, /* blame the macro writer */
+                    r.cur_span, /* blame the macro writer */
                     fmt!("variable '%s' is still repeating at this depth",
                          ident_to_str(&ident)));
               }