mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-11 15:23:05 +00:00
Change "etc" syntax for record patterns from {a:b ...}
to {a:b, _}
.
This commit is contained in:
parent
48dbee6b47
commit
9a0e85a920
@ -1465,10 +1465,11 @@ fn parse_pat(&parser p) -> @ast::pat {
|
||||
auto etc = false;
|
||||
auto first = true;
|
||||
while (p.peek() != token::RBRACE) {
|
||||
if (p.peek() == token::DOT) {
|
||||
if (first) { first = false; }
|
||||
else { expect(p, token::COMMA); }
|
||||
|
||||
if (p.peek() == token::UNDERSCORE) {
|
||||
p.bump();
|
||||
expect(p, token::DOT);
|
||||
expect(p, token::DOT);
|
||||
if (p.peek() != token::RBRACE) {
|
||||
p.fatal("expecting }, found " +
|
||||
token::to_str(p.get_reader(), p.peek()));
|
||||
@ -1476,8 +1477,7 @@ fn parse_pat(&parser p) -> @ast::pat {
|
||||
etc = true;
|
||||
break;
|
||||
}
|
||||
if (first) { first = false; }
|
||||
else { expect(p, token::COMMA); }
|
||||
|
||||
auto fieldname = parse_ident(p);
|
||||
auto subpat;
|
||||
if (p.peek() == token::COLON) {
|
||||
|
@ -116,6 +116,7 @@ fn to_str(lexer::reader r, token t) -> str {
|
||||
/* Structural symbols */
|
||||
case (AT) { ret "@"; }
|
||||
case (DOT) { ret "."; }
|
||||
case (ELIPSIS) { ret "..."; }
|
||||
case (COMMA) { ret ","; }
|
||||
case (SEMI) { ret ";"; }
|
||||
case (COLON) { ret ":"; }
|
||||
|
@ -4,7 +4,7 @@ tag t3 { c(t2, uint); }
|
||||
|
||||
fn m(&t3 in) -> int {
|
||||
alt in {
|
||||
c({x: a(?m) ...}, _) { ret m; }
|
||||
c({x: a(?m), _}, _) { ret m; }
|
||||
c({x: b(?m), y}, ?z) { ret (m + z) as int + y; }
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user