libsyntax: Remove the "by-mutable-ref" obsolete syntax error; it blocks useful function argument patterns. Add a test for the latter. r=brson

This commit is contained in:
Patrick Walton 2012-11-29 11:58:12 -08:00
parent 3beff12309
commit c946c87b6f
3 changed files with 13 additions and 14 deletions

View File

@ -23,7 +23,6 @@ pub enum ObsoleteSyntax {
ObsoleteClassTraits,
ObsoletePrivSection,
ObsoleteModeInFnType,
ObsoleteByMutRefMode,
ObsoleteMoveInit,
ObsoleteBinaryMove
}
@ -106,10 +105,6 @@ impl Parser : ObsoleteReporter {
"to use a (deprecated) mode in a fn type, you should \
give the argument an explicit name (like `&&v: int`)"
),
ObsoleteByMutRefMode => (
"by-mutable-reference mode",
"Declare an argument of type &mut T instead"
),
ObsoleteMoveInit => (
"initializer-by-move",
"Write `let foo = move bar` instead"

View File

@ -20,8 +20,7 @@ use obsolete::{
ObsoleteLowerCaseKindBounds, ObsoleteLet,
ObsoleteFieldTerminator, ObsoleteStructCtor,
ObsoleteWith, ObsoleteClassMethod, ObsoleteClassTraits,
ObsoleteModeInFnType, ObsoleteByMutRefMode,
ObsoleteMoveInit, ObsoleteBinaryMove,
ObsoleteModeInFnType, ObsoleteMoveInit, ObsoleteBinaryMove,
};
use ast::{_mod, add, arg, arm, attribute,
bind_by_ref, bind_by_implicit_ref, bind_by_value, bind_by_move,
@ -627,12 +626,7 @@ impl Parser {
}
fn parse_arg_mode() -> mode {
if self.eat(token::BINOP(token::AND)) {
self.obsolete(copy self.span,
ObsoleteByMutRefMode);
// Bogus mode, but doesn't matter since it's an error
expl(by_ref)
} else if self.eat(token::BINOP(token::MINUS)) {
if self.eat(token::BINOP(token::MINUS)) {
expl(by_move)
} else if self.eat(token::ANDAND) {
expl(by_ref)
@ -642,7 +636,9 @@ impl Parser {
} else {
expl(by_copy)
}
} else { infer(self.get_id()) }
} else {
infer(self.get_id())
}
}
fn is_named_argument() -> bool {

View File

@ -0,0 +1,8 @@
fn main() {
let v = [ (1, 2), (3, 4), (5, 6) ];
for v.each |&(x, y)| {
io::println(y.to_str());
io::println(x.to_str());
}
}