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 | |
| 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')
| -rw-r--r-- | src/libsyntax/codemap.rs | 7 | ||||
| -rw-r--r-- | src/libsyntax/crateid.rs | 3 | ||||
| -rw-r--r-- | src/libsyntax/opt_vec.rs | 1 | ||||
| -rw-r--r-- | src/libsyntax/parse/lexer.rs | 3 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 26 |
5 files changed, 32 insertions, 8 deletions
diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index 83700e390cb..a67d1b933a8 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -460,11 +460,12 @@ impl CodeMap { for mbc in multibyte_chars.get().iter() { debug!("codemap: {:?}-byte char at {:?}", mbc.bytes, mbc.pos); if mbc.pos < bpos { - total_extra_bytes += mbc.bytes; + // every character is at least one byte, so we only + // count the actual extra bytes. + total_extra_bytes += mbc.bytes - 1; // We should never see a byte position in the middle of a // character - assert!(bpos == mbc.pos || - bpos.to_uint() >= mbc.pos.to_uint() + mbc.bytes); + assert!(bpos.to_uint() >= mbc.pos.to_uint() + mbc.bytes); } else { break; } diff --git a/src/libsyntax/crateid.rs b/src/libsyntax/crateid.rs index 2417a6fa1ba..659cd13c94d 100644 --- a/src/libsyntax/crateid.rs +++ b/src/libsyntax/crateid.rs @@ -17,6 +17,9 @@ use std::fmt; /// `1.0`. If no crate name is given after the hash, the name is inferred to /// be the last component of the path. If no version is given, it is inferred /// to be `0.0`. + +use std::from_str::FromStr; + #[deriving(Clone, Eq)] pub struct CrateId { /// A path which represents the codes origin. By convention this is the diff --git a/src/libsyntax/opt_vec.rs b/src/libsyntax/opt_vec.rs index 3abd411a003..325df0ba777 100644 --- a/src/libsyntax/opt_vec.rs +++ b/src/libsyntax/opt_vec.rs @@ -16,6 +16,7 @@ */ use std::vec; +use std::default::Default; #[deriving(Clone, Encodable, Decodable, Hash)] pub enum OptVec<T> { 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() ); |
