Skip to content

Commit c946c87

Browse files
committed
libsyntax: Remove the "by-mutable-ref" obsolete syntax error; it blocks useful function argument patterns. Add a test for the latter. r=brson
1 parent 3beff12 commit c946c87

File tree

3 files changed

+13
-14
lines changed

3 files changed

+13
-14
lines changed

src/libsyntax/parse/obsolete.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ pub enum ObsoleteSyntax {
2323
ObsoleteClassTraits,
2424
ObsoletePrivSection,
2525
ObsoleteModeInFnType,
26-
ObsoleteByMutRefMode,
2726
ObsoleteMoveInit,
2827
ObsoleteBinaryMove
2928
}
@@ -106,10 +105,6 @@ impl Parser : ObsoleteReporter {
106105
"to use a (deprecated) mode in a fn type, you should \
107106
give the argument an explicit name (like `&&v: int`)"
108107
),
109-
ObsoleteByMutRefMode => (
110-
"by-mutable-reference mode",
111-
"Declare an argument of type &mut T instead"
112-
),
113108
ObsoleteMoveInit => (
114109
"initializer-by-move",
115110
"Write `let foo = move bar` instead"

src/libsyntax/parse/parser.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ use obsolete::{
2020
ObsoleteLowerCaseKindBounds, ObsoleteLet,
2121
ObsoleteFieldTerminator, ObsoleteStructCtor,
2222
ObsoleteWith, ObsoleteClassMethod, ObsoleteClassTraits,
23-
ObsoleteModeInFnType, ObsoleteByMutRefMode,
24-
ObsoleteMoveInit, ObsoleteBinaryMove,
23+
ObsoleteModeInFnType, ObsoleteMoveInit, ObsoleteBinaryMove,
2524
};
2625
use ast::{_mod, add, arg, arm, attribute,
2726
bind_by_ref, bind_by_implicit_ref, bind_by_value, bind_by_move,
@@ -627,12 +626,7 @@ impl Parser {
627626
}
628627
629628
fn parse_arg_mode() -> mode {
630-
if self.eat(token::BINOP(token::AND)) {
631-
self.obsolete(copy self.span,
632-
ObsoleteByMutRefMode);
633-
// Bogus mode, but doesn't matter since it's an error
634-
expl(by_ref)
635-
} else if self.eat(token::BINOP(token::MINUS)) {
629+
if self.eat(token::BINOP(token::MINUS)) {
636630
expl(by_move)
637631
} else if self.eat(token::ANDAND) {
638632
expl(by_ref)
@@ -642,7 +636,9 @@ impl Parser {
642636
} else {
643637
expl(by_copy)
644638
}
645-
} else { infer(self.get_id()) }
639+
} else {
640+
infer(self.get_id())
641+
}
646642
}
647643
648644
fn is_named_argument() -> bool {
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
fn main() {
2+
let v = [ (1, 2), (3, 4), (5, 6) ];
3+
for v.each |&(x, y)| {
4+
io::println(y.to_str());
5+
io::println(x.to_str());
6+
}
7+
}
8+

0 commit comments

Comments
 (0)