From 4e0311214160ea0dc7d1ff7347db6c6550c79de2 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 16 Nov 2011 12:32:38 +0100 Subject: Add a pass-by-copy parameter passing convention This is intended to solve the problem of how to pass arguments to constructor functions -- you want to move in rvalues, but not have to explicitly copy stuff that is not an rvalue. The by-copy passing convention will ensure the callee gets its own copy of the value. For rvalues, it'll just pass off the value. For lvalues, it'll make a copy. Issue #1177 --- src/comp/syntax/parse/parser.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/comp/syntax/parse') diff --git a/src/comp/syntax/parse/parser.rs b/src/comp/syntax/parse/parser.rs index 3731a6af7d0..d33bd89d5d8 100644 --- a/src/comp/syntax/parse/parser.rs +++ b/src/comp/syntax/parse/parser.rs @@ -573,7 +573,10 @@ fn parse_arg_mode(p: parser) -> ast::mode { if eat(p, token::BINOP(token::AND)) { ast::by_mut_ref } else if eat(p, token::BINOP(token::MINUS)) { ast::by_move } else if eat(p, token::ANDAND) { ast::by_ref } - else if eat(p, token::BINOP(token::PLUS)) { ast::by_val } + else if eat(p, token::BINOP(token::PLUS)) { + if eat(p, token::BINOP(token::PLUS)) { ast::by_val } + else { ast::by_copy } + } else { ast::mode_infer } } -- cgit 1.4.1-3-g733a5