diff --git a/src/librustc/middle/astencode.rs b/src/librustc/middle/astencode.rs index da58062f55376..e992c2a3af747 100644 --- a/src/librustc/middle/astencode.rs +++ b/src/librustc/middle/astencode.rs @@ -821,7 +821,7 @@ fn encode_side_tables_for_ii(ecx: @e::encode_ctxt, let ebml_w = copy ebml_w; ast_util::visit_ids_for_inlined_item( ii, - fn@(id: ast::node_id, copy ebml_w) { + fn@(id: ast::node_id) { // Note: this will cause a copy of ebml_w, which is bad as // it has mut fields. But I believe it's harmless since // we generate balanced EBML. diff --git a/src/librustdoc/text_pass.rs b/src/librustdoc/text_pass.rs index ab1d77a36db40..b9dbe523fdd33 100644 --- a/src/librustdoc/text_pass.rs +++ b/src/librustdoc/text_pass.rs @@ -76,7 +76,7 @@ fn apply_to_sections( op: NominalOp, sections: ~[doc::Section] ) -> ~[doc::Section] { - sections.map(|section, copy op| doc::Section { + sections.map(|section| doc::Section { header: (op.op)(copy section.header), body: (op.op)(copy section.body) }) @@ -89,7 +89,7 @@ fn fold_enum( let fold_copy = copy *fold; doc::EnumDoc { - variants: do doc.variants.map |variant, copy fold_copy| { + variants: do doc.variants.map |variant| { doc::VariantDoc { desc: maybe_apply_op(copy fold_copy.ctxt, &variant.desc), .. copy *variant diff --git a/src/librustdoc/tystr_pass.rs b/src/librustdoc/tystr_pass.rs index 42961e7bca613..b39cee875251a 100644 --- a/src/librustdoc/tystr_pass.rs +++ b/src/librustdoc/tystr_pass.rs @@ -137,7 +137,7 @@ fn fold_enum( variants: do vec::map(doc.variants) |variant| { let sig = { let variant = copy *variant; - do astsrv::exec(srv.clone()) |copy variant, ctxt| { + do astsrv::exec(srv.clone()) |ctxt| { match ctxt.ast_map.get(&doc_id) { ast_map::node_item(@ast::item { node: ast::item_enum(ref enum_definition, _), _ @@ -198,7 +198,7 @@ fn get_method_sig( item_id: doc::AstId, method_name: ~str ) -> Option<~str> { - do astsrv::exec(srv) |copy method_name, ctxt| { + do astsrv::exec(srv) |ctxt| { match ctxt.ast_map.get(&item_id) { ast_map::node_item(@ast::item { node: ast::item_trait(_, _, ref methods), _ diff --git a/src/librusti/rusti.rc b/src/librusti/rusti.rc index dead9ca58fc87..cd479aadb2561 100644 --- a/src/librusti/rusti.rc +++ b/src/librusti/rusti.rc @@ -368,7 +368,7 @@ fn run_line(repl: &mut Repl, in: io::Reader, out: io::Writer, line: ~str) } let r = *repl; - let result = do task::try |copy r| { + let result = do task::try { run(r, line) }; diff --git a/src/libstd/future.rs b/src/libstd/future.rs index e8c9a568a96e7..ff81393a914db 100644 --- a/src/libstd/future.rs +++ b/src/libstd/future.rs @@ -202,7 +202,7 @@ pub mod test { #[test] pub fn test_sendable_future() { let expected = ~"schlorf"; - let f = do spawn |copy expected| { copy expected }; + let f = do spawn { copy expected }; do task::spawn || { let actual = f.get(); assert actual == expected; diff --git a/src/libstd/par.rs b/src/libstd/par.rs index 3929e8c0ea763..c48f56dd143bb 100644 --- a/src/libstd/par.rs +++ b/src/libstd/par.rs @@ -107,7 +107,7 @@ pub fn mapi( { let slices = map_slices(xs, || { let f = fn_factory(); - fn~(base: uint, slice : &[A], copy f) -> ~[B] { + fn~(base: uint, slice : &[A]) -> ~[B] { vec::mapi(slice, |i, x| { f(i + base, x) }) @@ -126,7 +126,7 @@ pub fn alli( { do vec::all(map_slices(xs, || { let f = fn_factory(); - fn~(base: uint, slice : &[A], copy f) -> bool { + fn~(base: uint, slice : &[A]) -> bool { vec::alli(slice, |i, x| { f(i + base, x) }) @@ -140,7 +140,7 @@ pub fn any( fn_factory: &fn() -> ~fn(&A) -> bool) -> bool { do vec::any(map_slices(xs, || { let f = fn_factory(); - fn~(_base : uint, slice: &[A], copy f) -> bool { + fn~(_base : uint, slice: &[A]) -> bool { vec::any(slice, |x| f(x)) } })) |x| { *x } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 799f0d40a4617..ead5a5bb47453 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -105,7 +105,6 @@ enum restriction { enum class_contents { dtor_decl(blk, ~[attribute], codemap::span), members(~[@struct_field]) } -type arg_or_capture_item = Either; type item_info = (ident, item_, Option<~[attribute]>); pub enum item_or_view_item { @@ -435,7 +434,7 @@ pub impl Parser { let (self_ty, d) = do self.parse_fn_decl_with_self() |p| { // This is somewhat dubious; We don't want to allow argument // names to be left off if there is a definition... - either::Left(p.parse_arg_general(false)) + p.parse_arg_general(false) }; // XXX: Wrong. Shouldn't allow both static and self_ty let self_ty = if is_static { static_sty } else { self_ty }; @@ -732,16 +731,8 @@ pub impl Parser { } } - fn parse_capture_item_or(parse_arg_fn: fn(Parser) -> arg_or_capture_item) - -> arg_or_capture_item - { - if self.eat_keyword(~"copy") { - // XXX outdated syntax now that moves-based-on-type has gone in - self.parse_ident(); - either::Right(()) - } else { - parse_arg_fn(self) - } + fn parse_arg() -> ast::arg { + self.parse_arg_general(true) } // This version of parse arg doesn't necessarily require @@ -768,35 +759,26 @@ pub impl Parser { ty: t, pat: pat, id: self.get_id() } } - fn parse_arg() -> arg_or_capture_item { - either::Left(self.parse_arg_general(true)) - } - - fn parse_arg_or_capture_item() -> arg_or_capture_item { - self.parse_capture_item_or(|p| p.parse_arg()) - } - fn parse_fn_block_arg() -> arg_or_capture_item { - do self.parse_capture_item_or |p| { - let m = p.parse_arg_mode(); - let is_mutbl = self.eat_keyword(~"mut"); - let pat = p.parse_pat(false); - let t = if p.eat(token::COLON) { - p.parse_ty(false) - } else { - @Ty { - id: p.get_id(), - node: ty_infer, - span: mk_sp(p.span.lo, p.span.hi), - } - }; - either::Left(ast::arg { - mode: m, - is_mutbl: is_mutbl, - ty: t, - pat: pat, - id: p.get_id() - }) + fn parse_fn_block_arg() -> ast::arg { + let m = self.parse_arg_mode(); + let is_mutbl = self.eat_keyword(~"mut"); + let pat = self.parse_pat(false); + let t = if self.eat(token::COLON) { + self.parse_ty(false) + } else { + @Ty { + id: self.get_id(), + node: ty_infer, + span: mk_sp(self.span.lo, self.span.hi), + } + }; + ast::arg { + mode: m, + is_mutbl: is_mutbl, + ty: t, + pat: pat, + id: self.get_id() } } @@ -1696,7 +1678,7 @@ pub impl Parser { // if we want to allow fn expression argument types to be inferred in // the future, just have to change parse_arg to parse_fn_block_arg. - let decl = self.parse_fn_decl(|p| p.parse_arg_or_capture_item()); + let decl = self.parse_fn_decl(|p| p.parse_arg()); let body = self.parse_block(); @@ -2678,19 +2660,17 @@ pub impl Parser { } else { ~[] } } - fn parse_fn_decl(parse_arg_fn: fn(Parser) -> arg_or_capture_item) + fn parse_fn_decl(parse_arg_fn: fn(Parser) -> ast::arg) -> fn_decl { - let args_or_capture_items: ~[arg_or_capture_item] = + let args: ~[ast::arg] = self.parse_unspanned_seq( token::LPAREN, token::RPAREN, seq_sep_trailing_disallowed(token::COMMA), parse_arg_fn); - let inputs = either::lefts(args_or_capture_items); - let (ret_style, ret_ty) = self.parse_ret_ty(); ast::fn_decl { - inputs: inputs, + inputs: args, output: ret_ty, cf: ret_style, } @@ -2713,7 +2693,7 @@ pub impl Parser { } fn parse_fn_decl_with_self(parse_arg_fn: - fn(Parser) -> arg_or_capture_item) + fn(Parser) -> ast::arg) -> (self_ty, fn_decl) { fn maybe_parse_self_ty(cnstr: fn(+v: mutability) -> ast::self_ty_, @@ -2758,19 +2738,19 @@ pub impl Parser { }; // If we parsed a self type, expect a comma before the argument list. - let args_or_capture_items; + let args; if self_ty != sty_by_ref { match copy self.token { token::COMMA => { self.bump(); let sep = seq_sep_trailing_disallowed(token::COMMA); - args_or_capture_items = + args = self.parse_seq_to_before_end(token::RPAREN, sep, parse_arg_fn); } token::RPAREN => { - args_or_capture_items = ~[]; + args = ~[]; } _ => { self.fatal(~"expected `,` or `)`, found `" + @@ -2779,7 +2759,7 @@ pub impl Parser { } } else { let sep = seq_sep_trailing_disallowed(token::COMMA); - args_or_capture_items = + args = self.parse_seq_to_before_end(token::RPAREN, sep, parse_arg_fn); @@ -2789,11 +2769,10 @@ pub impl Parser { let hi = self.span.hi; - let inputs = either::lefts(args_or_capture_items); let (ret_style, ret_ty) = self.parse_ret_ty(); let fn_decl = ast::fn_decl { - inputs: inputs, + inputs: args, output: ret_ty, cf: ret_style }; @@ -2802,7 +2781,7 @@ pub impl Parser { } fn parse_fn_block_decl() -> fn_decl { - let inputs_captures = { + let args = { if self.eat(token::OROR) { ~[] } else { @@ -2819,7 +2798,7 @@ pub impl Parser { }; ast::fn_decl { - inputs: either::lefts(inputs_captures), + inputs: args, output: output, cf: return_val, } diff --git a/src/test/auxiliary/cci_capture_clause.rs b/src/test/auxiliary/cci_capture_clause.rs index fd319aacd05f8..70a2b8f680a5c 100644 --- a/src/test/auxiliary/cci_capture_clause.rs +++ b/src/test/auxiliary/cci_capture_clause.rs @@ -12,7 +12,7 @@ use core::pipes::*; pub fn foo(x: T) -> Port { let (p, c) = stream(); - do task::spawn() |copy x| { + do task::spawn() { c.send(x); } p diff --git a/src/test/compile-fail/kindck-nonsendable-1.rs b/src/test/compile-fail/kindck-nonsendable-1.rs index c88dae232fa06..397b0f682d62c 100644 --- a/src/test/compile-fail/kindck-nonsendable-1.rs +++ b/src/test/compile-fail/kindck-nonsendable-1.rs @@ -13,6 +13,6 @@ fn foo(_x: @uint) {} fn main() { let x = @3u; let _ = fn~() { foo(x); }; //~ ERROR value has non-owned type `@uint` - let _ = fn~(copy x) { foo(x); }; //~ ERROR value has non-owned type `@uint` + let _ = fn~() { foo(x); }; //~ ERROR value has non-owned type `@uint` let _ = fn~() { foo(x); }; //~ ERROR value has non-owned type `@uint` } diff --git a/src/test/run-pass/cap-clause-not-used.rs b/src/test/run-pass/cap-clause-not-used.rs deleted file mode 100644 index e26a8ae11fdb2..0000000000000 --- a/src/test/run-pass/cap-clause-not-used.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern: warning: Captured variable 'y' not used in closure -pub fn main() { - let x = 5; - let _y = fn~(copy x) { }; -} diff --git a/src/test/run-pass/capture_nil.rs b/src/test/run-pass/capture_nil.rs index 6c052b95a2bc5..b77e91c8d212c 100644 --- a/src/test/run-pass/capture_nil.rs +++ b/src/test/run-pass/capture_nil.rs @@ -28,7 +28,7 @@ use core::pipes::*; fn foo(&&x: ()) -> Port<()> { let (p, c) = stream::<()>(); - do task::spawn() |copy x| { + do task::spawn() { c.send(x); } p diff --git a/src/test/run-pass/issue-3609.rs b/src/test/run-pass/issue-3609.rs index 0eacb34b1ef88..6eb540c473726 100644 --- a/src/test/run-pass/issue-3609.rs +++ b/src/test/run-pass/issue-3609.rs @@ -12,7 +12,6 @@ enum Msg fn foo(name: ~str, samples_chan: Chan) { do task::spawn - |copy name| { let callback: SamplesFn = |buffer|