diff options
| author | bors <bors@rust-lang.org> | 2014-11-21 23:16:48 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-11-21 23:16:48 +0000 |
| commit | 81eeec0941f936f0f3de881c3991a74f32fe0625 (patch) | |
| tree | ce9f2391bdab7d078dc510d7572a3116d4dbf44c /src/libsyntax/parse | |
| parent | cd7584743710aa2355eb7e09146fea7c338a27e5 (diff) | |
| parent | 75ffadf8b65495ababae49d8162f85c58cd2c2a9 (diff) | |
| download | rust-81eeec0941f936f0f3de881c3991a74f32fe0625.tar.gz rust-81eeec0941f936f0f3de881c3991a74f32fe0625.zip | |
auto merge of #18603 : brson/rust/stdchar, r=aturon
* Deprecate the free functions in favor of methods, except the two ctors `from_u32` and `from_digit`, whose methods are deprecated. * Mark the `Char` and `UnicodeChar` traits experimental until we decide for sure that we won't have some sort of inherent methods for primitives. * The `UnicodeChar` methods related to numerics are now called e.g. `is_numeric` to match the 'numeric' unicode character class, and the `*_digit_radix` methods on `Char` now just called `*_digit`. * `len_utf8_bytes` -> `len_utf8` * Converted methods to take self by-value * Converted `escape_default` and `escape_unicode` to iterators over chars. * Renamed `is_XID_start`, `is_XID_continue` to `is_xid_start`, `is_xid_continue` to match conventions This also converts `encode_utf8` and `encode_utf16` to return iterators. I suspect this is not the final form of these methods. Perf is worse (numbers in the commit). Many of the uses ended up being awkward, copying into a buffer then writing that buffer to a `Writer`. It might be more appropriate for these to return `Reader`s instead, but that type is defined in `std`. Note: although I *did* add the `from_u32` ctor to the `Char` trait, I deprecated it again later, preferring the free ctors. I've been sitting on this for a while. cc @aturon
Diffstat (limited to 'src/libsyntax/parse')
| -rw-r--r-- | src/libsyntax/parse/lexer/mod.rs | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs index fbca4868255..a88029e087b 100644 --- a/src/libsyntax/parse/lexer/mod.rs +++ b/src/libsyntax/parse/lexer/mod.rs @@ -193,7 +193,7 @@ impl<'a> StringReader<'a> { fn fatal_span_char(&self, from_pos: BytePos, to_pos: BytePos, m: &str, c: char) -> ! { let mut m = m.to_string(); m.push_str(": "); - char::escape_default(c, |c| m.push(c)); + for c in c.escape_default() { m.push(c) } self.fatal_span_(from_pos, to_pos, m.as_slice()); } @@ -202,7 +202,7 @@ impl<'a> StringReader<'a> { fn err_span_char(&self, from_pos: BytePos, to_pos: BytePos, m: &str, c: char) { let mut m = m.to_string(); m.push_str(": "); - char::escape_default(c, |c| m.push(c)); + for c in c.escape_default() { m.push(c) } self.err_span_(from_pos, to_pos, m.as_slice()); } @@ -645,7 +645,7 @@ impl<'a> StringReader<'a> { loop { let c = self.curr; if c == Some('_') { debug!("skipping a _"); self.bump(); continue; } - match c.and_then(|cc| char::to_digit(cc, radix)) { + match c.and_then(|cc| cc.to_digit(radix)) { Some(_) => { debug!("{} in scan_digits", c); len += 1; @@ -677,7 +677,7 @@ impl<'a> StringReader<'a> { return token::Integer(self.name_from(start_bpos)); } } - } else if c.is_digit_radix(10) { + } else if c.is_digit(10) { num_digits = self.scan_digits(10) + 1; } else { num_digits = 0; @@ -692,11 +692,11 @@ impl<'a> StringReader<'a> { // integer literal followed by field/method access or a range pattern // (`0..2` and `12.foo()`) if self.curr_is('.') && !self.nextch_is('.') && !self.nextch().unwrap_or('\0') - .is_XID_start() { + .is_xid_start() { // might have stuff after the ., and if it does, it needs to start // with a number self.bump(); - if self.curr.unwrap_or('\0').is_digit_radix(10) { + if self.curr.unwrap_or('\0').is_digit(10) { self.scan_digits(10); self.scan_float_exponent(); } @@ -1385,7 +1385,7 @@ fn ident_start(c: Option<char>) -> bool { (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_' - || (c > '\x7f' && char::is_XID_start(c)) + || (c > '\x7f' && c.is_xid_start()) } fn ident_continue(c: Option<char>) -> bool { @@ -1395,7 +1395,7 @@ fn ident_continue(c: Option<char>) -> bool { || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '_' - || (c > '\x7f' && char::is_XID_continue(c)) + || (c > '\x7f' && c.is_xid_continue()) } #[cfg(test)] |
