Skip to content

Commit

Permalink
auto merge of #12854 : nick29581/rust/parse-enum-struct, r=alexcrichton
Browse files Browse the repository at this point in the history
...where the field and variable are unified
  • Loading branch information
bors committed Mar 20, 2014
2 parents 7aded2a + aa5c8ea commit a92dcb0
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/libsyntax/parse/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2781,7 +2781,6 @@ impl<'a> Parser<'a> {
break;
}

let lo1 = self.last_span.lo;
let bind_type = if self.eat_keyword(keywords::Mut) {
BindByValue(MutMutable)
} else if self.eat_keyword(keywords::Ref) {
Expand All @@ -2791,11 +2790,8 @@ impl<'a> Parser<'a> {
};

let fieldname = self.parse_ident();
let hi1 = self.last_span.lo;
let fieldpath = ast_util::ident_to_path(mk_sp(lo1, hi1),
fieldname);
let subpat;
if self.token == token::COLON {

let subpat = if self.token == token::COLON {
match bind_type {
BindByRef(..) | BindByValue(MutMutable) => {
let token_str = self.this_token_to_str();
Expand All @@ -2805,14 +2801,16 @@ impl<'a> Parser<'a> {
}

self.bump();
subpat = self.parse_pat();
self.parse_pat()
} else {
subpat = @ast::Pat {
let fieldpath = ast_util::ident_to_path(self.last_span,
fieldname);
@ast::Pat {
id: ast::DUMMY_NODE_ID,
node: PatIdent(bind_type, fieldpath, None),
span: self.last_span
};
}
}
};
fields.push(ast::FieldPat { ident: fieldname, pat: subpat });
}
return (fields, etc);
Expand Down

0 comments on commit a92dcb0

Please sign in to comment.