Skip to content

Commit

Permalink
Auto merge of #23473 - Manishearth:rollup, r=Manishearth
Browse files Browse the repository at this point in the history
  • Loading branch information
bors committed Mar 18, 2015
2 parents 46f649c + 2a106d6 commit 94a9506
Show file tree
Hide file tree
Showing 22 changed files with 362 additions and 117 deletions.
18 changes: 9 additions & 9 deletions src/compiletest/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1052,22 +1052,22 @@ fn scan_char(haystack: &str, needle: char, idx: &mut uint) -> bool {
if *idx >= haystack.len() {
return false;
}
let range = haystack.char_range_at(*idx);
if range.ch != needle {
let ch = haystack.char_at(*idx);
if ch != needle {
return false;
}
*idx = range.next;
*idx += ch.len_utf8();
return true;
}

fn scan_integer(haystack: &str, idx: &mut uint) -> bool {
let mut i = *idx;
while i < haystack.len() {
let range = haystack.char_range_at(i);
if range.ch < '0' || '9' < range.ch {
let ch = haystack.char_at(i);
if ch < '0' || '9' < ch {
break;
}
i = range.next;
i += ch.len_utf8();
}
if i == *idx {
return false;
Expand All @@ -1083,9 +1083,9 @@ fn scan_string(haystack: &str, needle: &str, idx: &mut uint) -> bool {
if haystack_i >= haystack.len() {
return false;
}
let range = haystack.char_range_at(haystack_i);
haystack_i = range.next;
if !scan_char(needle, range.ch, &mut needle_i) {
let ch = haystack.char_at(haystack_i);
haystack_i += ch.len_utf8();
if !scan_char(needle, ch, &mut needle_i) {
return false;
}
}
Expand Down
1 change: 1 addition & 0 deletions src/libcollections/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#![feature(unique)]
#![feature(unsafe_no_drop_flag)]
#![feature(step_by)]
#![feature(str_char)]
#![cfg_attr(test, feature(rand, rustc_private, test))]
#![cfg_attr(test, allow(deprecated))] // rand

Expand Down
162 changes: 104 additions & 58 deletions src/libcollections/str.rs

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions src/libcollections/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use unicode::str as unicode_str;
use unicode::str::Utf16Item;

use borrow::{Cow, IntoCow};
use str::{self, CharRange, FromStr, Utf8Error};
use str::{self, FromStr, Utf8Error};
use vec::{DerefVec, Vec, as_vec};

/// A growable string stored as a UTF-8 encoded buffer.
Expand Down Expand Up @@ -561,9 +561,9 @@ impl String {
return None
}

let CharRange {ch, next} = self.char_range_at_reverse(len);
let ch = self.char_at_reverse(len);
unsafe {
self.vec.set_len(next);
self.vec.set_len(len - ch.len_utf8());
}
Some(ch)
}
Expand Down Expand Up @@ -595,7 +595,8 @@ impl String {
let len = self.len();
assert!(idx <= len);

let CharRange { ch, next } = self.char_range_at(idx);
let ch = self.char_at(idx);
let next = idx + ch.len_utf8();
unsafe {
ptr::copy(self.vec.as_mut_ptr().offset(idx as isize),
self.vec.as_ptr().offset(next as isize),
Expand Down
11 changes: 7 additions & 4 deletions src/libcore/str/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

use self::OldSearcher::{TwoWay, TwoWayLong};

use char::CharExt;
use clone::Clone;
use cmp::{self, Eq};
use default::Default;
Expand Down Expand Up @@ -1112,8 +1113,10 @@ static UTF8_CHAR_WIDTH: [u8; 256] = [
/// the next `char` in a string. This can be used as a data structure
/// for iterating over the UTF-8 bytes of a string.
#[derive(Copy)]
#[unstable(feature = "core",
reason = "naming is uncertain with container conventions")]
#[unstable(feature = "str_char",
reason = "existence of this struct is uncertain as it is frequently \
able to be replaced with char.len_utf8() and/or \
char/char_indices iterators")]
pub struct CharRange {
/// Current `char`
pub ch: char,
Expand Down Expand Up @@ -1646,8 +1649,8 @@ impl StrExt for str {
if self.is_empty() {
None
} else {
let CharRange {ch, next} = self.char_range_at(0);
let next_s = unsafe { self.slice_unchecked(next, self.len()) };
let ch = self.char_at(0);
let next_s = unsafe { self.slice_unchecked(ch.len_utf8(), self.len()) };
Some((ch, next_s))
}
}
Expand Down
14 changes: 7 additions & 7 deletions src/libgetopts/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,10 @@
html_playground_url = "http://play.rust-lang.org/")]

#![deny(missing_docs)]
#![feature(collections)]
#![feature(int_uint)]
#![feature(staged_api)]
#![feature(core)]
#![feature(str_words)]
#![feature(str_char)]
#![cfg_attr(test, feature(rustc_private))]

#[cfg(test)] #[macro_use] extern crate log;
Expand Down Expand Up @@ -620,8 +619,8 @@ pub fn getopts(args: &[String], optgrps: &[OptGroup]) -> Result {
let mut j = 1;
names = Vec::new();
while j < curlen {
let range = cur.char_range_at(j);
let opt = Short(range.ch);
let ch = cur.char_at(j);
let opt = Short(ch);

/* In a series of potential options (eg. -aheJ), if we
see one which takes an argument, we assume all
Expand All @@ -642,12 +641,13 @@ pub fn getopts(args: &[String], optgrps: &[OptGroup]) -> Result {
No => false
};

if arg_follows && range.next < curlen {
i_arg = Some((&cur[range.next..curlen]).to_string());
let next = j + ch.len_utf8();
if arg_follows && next < curlen {
i_arg = Some((&cur[next..curlen]).to_string());
break;
}

j = range.next;
j = next;
}
}
let mut name_pos = 0;
Expand Down
4 changes: 2 additions & 2 deletions src/liblibc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,8 @@ pub mod types {
#[repr(C)]
#[derive(Copy)] pub struct sockaddr_storage {
pub ss_family: sa_family_t,
pub __ss_align: i64,
pub __ss_pad2: [u8; 112],
pub __ss_align: isize,
pub __ss_pad2: [u8; 128 - 2 * (::core::isize::BYTES as usize)],
}
#[repr(C)]
#[derive(Copy)] pub struct sockaddr_in {
Expand Down
1 change: 1 addition & 0 deletions src/librustc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#![feature(io)]
#![feature(path_ext)]
#![feature(str_words)]
#![feature(str_char)]
#![cfg_attr(test, feature(test))]

extern crate arena;
Expand Down
1 change: 1 addition & 0 deletions src/librustc_driver/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#![feature(exit_status)]
#![feature(io)]
#![feature(set_stdio)]
#![feature(unicode)]

extern crate arena;
extern crate flate;
Expand Down
1 change: 1 addition & 0 deletions src/librustc_lint/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#![feature(unsafe_destructor)]
#![feature(staged_api)]
#![feature(std_misc)]
#![feature(str_char)]
#![cfg_attr(test, feature(test))]

extern crate syntax;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_typeck/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5240,7 +5240,7 @@ pub fn may_break(cx: &ty::ctxt, id: ast::NodeId, b: &ast::Block) -> bool {
// inside the loop?
(loop_query(&*b, |e| {
match *e {
ast::ExprBreak(_) => true,
ast::ExprBreak(None) => true,
_ => false
}
})) ||
Expand Down
1 change: 1 addition & 0 deletions src/libserialize/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Core encoding and decoding interfaces.
#![feature(staged_api)]
#![feature(std_misc)]
#![feature(unicode)]
#![feature(str_char)]
#![cfg_attr(test, feature(test))]

// test harness access
Expand Down
9 changes: 5 additions & 4 deletions src/libstd/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@
//!
//! ## Concurrency, I/O, and the runtime
//!
//! The [`thread`](thread/index.html) module contains Rust's threading abstractions,
//! while [`comm`](comm/index.html) contains the channel types for message
//! passing. [`sync`](sync/index.html) contains further, primitive, shared
//! memory types, including [`atomic`](sync/atomic/index.html).
//! The [`thread`](thread/index.html) module contains Rust's threading abstractions.
//! [`sync`](sync/index.html) contains further, primitive, shared memory types,
//! including [`atomic`](sync/atomic/index.html), and [`mpsc`](sync/mpmc/index.html),
//! which contains the channel types for message passing.
//!
//! Common types of I/O, including files, TCP, UDP, pipes, Unix domain sockets,
//! timers, and process spawning, are defined in the
Expand Down Expand Up @@ -127,6 +127,7 @@
#![feature(int_uint)]
#![feature(unique)]
#![feature(allow_internal_unstable)]
#![feature(str_char)]
#![cfg_attr(test, feature(test, rustc_private))]

// Don't link to std. We are std.
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/net/ip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ impl FromInner<libc::in_addr> for Ipv4Addr {
impl Ipv6Addr {
/// Create a new IPv6 address from eight 16-bit segments.
///
/// The result will represent the IP address a:b:c:d:e:f
/// The result will represent the IP address a:b:c:d:e:f:g:h
#[stable(feature = "rust1", since = "1.0.0")]
pub fn new(a: u16, b: u16, c: u16, d: u16, e: u16, f: u16, g: u16,
h: u16) -> Ipv6Addr {
Expand Down
Loading

0 comments on commit 94a9506

Please sign in to comment.