Skip to content

Commit a92dcb0

Browse files
committed
auto merge of #12854 : nick29581/rust/parse-enum-struct, r=alexcrichton
...where the field and variable are unified
2 parents 7aded2a + aa5c8ea commit a92dcb0

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

src/libsyntax/parse/parser.rs

+8-10
Original file line numberDiff line numberDiff line change
@@ -2781,7 +2781,6 @@ impl<'a> Parser<'a> {
27812781
break;
27822782
}
27832783

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

27932792
let fieldname = self.parse_ident();
2794-
let hi1 = self.last_span.lo;
2795-
let fieldpath = ast_util::ident_to_path(mk_sp(lo1, hi1),
2796-
fieldname);
2797-
let subpat;
2798-
if self.token == token::COLON {
2793+
2794+
let subpat = if self.token == token::COLON {
27992795
match bind_type {
28002796
BindByRef(..) | BindByValue(MutMutable) => {
28012797
let token_str = self.this_token_to_str();
@@ -2805,14 +2801,16 @@ impl<'a> Parser<'a> {
28052801
}
28062802

28072803
self.bump();
2808-
subpat = self.parse_pat();
2804+
self.parse_pat()
28092805
} else {
2810-
subpat = @ast::Pat {
2806+
let fieldpath = ast_util::ident_to_path(self.last_span,
2807+
fieldname);
2808+
@ast::Pat {
28112809
id: ast::DUMMY_NODE_ID,
28122810
node: PatIdent(bind_type, fieldpath, None),
28132811
span: self.last_span
2814-
};
2815-
}
2812+
}
2813+
};
28162814
fields.push(ast::FieldPat { ident: fieldname, pat: subpat });
28172815
}
28182816
return (fields, etc);

0 commit comments

Comments
 (0)