diff options
| author | bors <bors@rust-lang.org> | 2014-02-24 22:17:02 -0800 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-02-24 22:17:02 -0800 |
| commit | 4243cad56bbd266872770218873900da22fed5ea (patch) | |
| tree | e6641cd309453d27c829fdca475650b797b3ad48 /src/libsyntax/parse | |
| parent | 043c9721791731bbf7b9d8be354a65ed25b9a6d9 (diff) | |
| parent | 7d85546721cf954606a2fe25a63e9fb9e8a256ad (diff) | |
| download | rust-4243cad56bbd266872770218873900da22fed5ea.tar.gz rust-4243cad56bbd266872770218873900da22fed5ea.zip | |
auto merge of #12535 : alexcrichton/rust/rollup, r=alexcrichton
Closes #12474 (rustc: Don't error on the rlib symlinks) r=brson
Closes #12475 (Use lines_any() when parsing output form "ar") r=brson
Closes #12476 (Remove some obsolete ignored tests) r=alexcrichton
Closes #12481 (Make .swap_remove return Option<T>) r=brson
Closes #12485 (Remove some non-essential trait re-exports from the prelude.) r=brson
Closes #12489 (Handle multibyte characters in source files better) r=alexcrichton
Closes #12494 (Mark by-value parameters that are passed on the stack as nocapture) r=nmatsakis
Closes #12497 (syntax: allow stmt/expr macro invocations to be delimited by {}) r=alexcrichton
Closes #12508 (Match binding is assignment) r=nmatsakis
Closes #12513 (Run the travis build as one large command) r=huonw
Closes #12515 (Update source code layout in src/) r=alexcrichton
Closes #12521 (Tutorial: Add std::num::sqrt to the example) r=cmr
Closes #12529 (test: single-variant enum can't be dereferenced) r=huonw
Diffstat (limited to 'src/libsyntax/parse')
| -rw-r--r-- | src/libsyntax/parse/lexer.rs | 3 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 26 |
2 files changed, 24 insertions, 5 deletions
diff --git a/src/libsyntax/parse/lexer.rs b/src/libsyntax/parse/lexer.rs index b711e95bc94..5bace75a5ea 100644 --- a/src/libsyntax/parse/lexer.rs +++ b/src/libsyntax/parse/lexer.rs @@ -264,8 +264,7 @@ pub fn bump(rdr: &StringReader) { } if byte_offset_diff > 1 { - rdr.filemap.record_multibyte_char( - Pos::from_uint(current_byte_offset), byte_offset_diff); + rdr.filemap.record_multibyte_char(rdr.last_pos.get(), byte_offset_diff); } } else { rdr.curr.set(None); diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index dac668da343..cbe371a06a5 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -3185,15 +3185,35 @@ impl Parser { let pth = self.parse_path(NoTypesAllowed).path; self.bump(); - let id = if self.token == token::LPAREN { + let id = if self.token == token::LPAREN || self.token == token::LBRACE { token::special_idents::invalid // no special identifier } else { self.parse_ident() }; + // check that we're pointing at delimiters (need to check + // again after the `if`, because of `parse_ident` + // consuming more tokens). + let (bra, ket) = match self.token { + token::LPAREN => (token::LPAREN, token::RPAREN), + token::LBRACE => (token::LBRACE, token::RBRACE), + _ => { + // we only expect an ident if we didn't parse one + // above. + let ident_str = if id == token::special_idents::invalid { + "identifier, " + } else { + "" + }; + let tok_str = self.this_token_to_str(); + self.fatal(format!("expected {}`(` or `\\{`, but found `{}`", + ident_str, tok_str)) + } + }; + let tts = self.parse_unspanned_seq( - &token::LPAREN, - &token::RPAREN, + &bra, + &ket, seq_sep_none(), |p| p.parse_token_tree() ); |
