diff options
| author | Nick Cameron <ncameron@mozilla.com> | 2014-03-12 15:51:20 -0700 |
|---|---|---|
| committer | Nick Cameron <ncameron@mozilla.com> | 2014-03-20 12:11:31 +1300 |
| commit | aa5c8ea600f38729b8fcb29494295abfa1065842 (patch) | |
| tree | 5be51f8a858090655a375e77de0815537872b62e /src/libsyntax/parse/parser.rs | |
| parent | 4ca51aeea7187a63b987129d67cf7d348b6c60a9 (diff) | |
| download | rust-aa5c8ea600f38729b8fcb29494295abfa1065842.tar.gz rust-aa5c8ea600f38729b8fcb29494295abfa1065842.zip | |
Fix spans for enum-struct match arms
Correct spans for fields in enum struct arms where the field and variable are unified
Diffstat (limited to 'src/libsyntax/parse/parser.rs')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index e1a02d5240f..3e94c179dd4 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -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) { @@ -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(); @@ -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); |
