Skip to content

Commit 94a9506

Browse files
committed
Auto merge of #23473 - Manishearth:rollup, r=Manishearth
2 parents 46f649c + 2a106d6 commit 94a9506

File tree

22 files changed

+362
-117
lines changed

22 files changed

+362
-117
lines changed

src/compiletest/runtest.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -1052,22 +1052,22 @@ fn scan_char(haystack: &str, needle: char, idx: &mut uint) -> bool {
10521052
if *idx >= haystack.len() {
10531053
return false;
10541054
}
1055-
let range = haystack.char_range_at(*idx);
1056-
if range.ch != needle {
1055+
let ch = haystack.char_at(*idx);
1056+
if ch != needle {
10571057
return false;
10581058
}
1059-
*idx = range.next;
1059+
*idx += ch.len_utf8();
10601060
return true;
10611061
}
10621062

10631063
fn scan_integer(haystack: &str, idx: &mut uint) -> bool {
10641064
let mut i = *idx;
10651065
while i < haystack.len() {
1066-
let range = haystack.char_range_at(i);
1067-
if range.ch < '0' || '9' < range.ch {
1066+
let ch = haystack.char_at(i);
1067+
if ch < '0' || '9' < ch {
10681068
break;
10691069
}
1070-
i = range.next;
1070+
i += ch.len_utf8();
10711071
}
10721072
if i == *idx {
10731073
return false;
@@ -1083,9 +1083,9 @@ fn scan_string(haystack: &str, needle: &str, idx: &mut uint) -> bool {
10831083
if haystack_i >= haystack.len() {
10841084
return false;
10851085
}
1086-
let range = haystack.char_range_at(haystack_i);
1087-
haystack_i = range.next;
1088-
if !scan_char(needle, range.ch, &mut needle_i) {
1086+
let ch = haystack.char_at(haystack_i);
1087+
haystack_i += ch.len_utf8();
1088+
if !scan_char(needle, ch, &mut needle_i) {
10891089
return false;
10901090
}
10911091
}

src/libcollections/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#![feature(unique)]
3636
#![feature(unsafe_no_drop_flag)]
3737
#![feature(step_by)]
38+
#![feature(str_char)]
3839
#![cfg_attr(test, feature(rand, rustc_private, test))]
3940
#![cfg_attr(test, allow(deprecated))] // rand
4041

src/libcollections/str.rs

+104-58
Large diffs are not rendered by default.

src/libcollections/string.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use unicode::str as unicode_str;
2929
use unicode::str::Utf16Item;
3030

3131
use borrow::{Cow, IntoCow};
32-
use str::{self, CharRange, FromStr, Utf8Error};
32+
use str::{self, FromStr, Utf8Error};
3333
use vec::{DerefVec, Vec, as_vec};
3434

3535
/// A growable string stored as a UTF-8 encoded buffer.
@@ -561,9 +561,9 @@ impl String {
561561
return None
562562
}
563563

564-
let CharRange {ch, next} = self.char_range_at_reverse(len);
564+
let ch = self.char_at_reverse(len);
565565
unsafe {
566-
self.vec.set_len(next);
566+
self.vec.set_len(len - ch.len_utf8());
567567
}
568568
Some(ch)
569569
}
@@ -595,7 +595,8 @@ impl String {
595595
let len = self.len();
596596
assert!(idx <= len);
597597

598-
let CharRange { ch, next } = self.char_range_at(idx);
598+
let ch = self.char_at(idx);
599+
let next = idx + ch.len_utf8();
599600
unsafe {
600601
ptr::copy(self.vec.as_mut_ptr().offset(idx as isize),
601602
self.vec.as_ptr().offset(next as isize),

src/libcore/str/mod.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

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

21+
use char::CharExt;
2122
use clone::Clone;
2223
use cmp::{self, Eq};
2324
use default::Default;
@@ -1112,8 +1113,10 @@ static UTF8_CHAR_WIDTH: [u8; 256] = [
11121113
/// the next `char` in a string. This can be used as a data structure
11131114
/// for iterating over the UTF-8 bytes of a string.
11141115
#[derive(Copy)]
1115-
#[unstable(feature = "core",
1116-
reason = "naming is uncertain with container conventions")]
1116+
#[unstable(feature = "str_char",
1117+
reason = "existence of this struct is uncertain as it is frequently \
1118+
able to be replaced with char.len_utf8() and/or \
1119+
char/char_indices iterators")]
11171120
pub struct CharRange {
11181121
/// Current `char`
11191122
pub ch: char,
@@ -1646,8 +1649,8 @@ impl StrExt for str {
16461649
if self.is_empty() {
16471650
None
16481651
} else {
1649-
let CharRange {ch, next} = self.char_range_at(0);
1650-
let next_s = unsafe { self.slice_unchecked(next, self.len()) };
1652+
let ch = self.char_at(0);
1653+
let next_s = unsafe { self.slice_unchecked(ch.len_utf8(), self.len()) };
16511654
Some((ch, next_s))
16521655
}
16531656
}

src/libgetopts/lib.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,10 @@
9292
html_playground_url = "http://play.rust-lang.org/")]
9393

9494
#![deny(missing_docs)]
95-
#![feature(collections)]
9695
#![feature(int_uint)]
9796
#![feature(staged_api)]
98-
#![feature(core)]
9997
#![feature(str_words)]
98+
#![feature(str_char)]
10099
#![cfg_attr(test, feature(rustc_private))]
101100

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

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

645-
if arg_follows && range.next < curlen {
646-
i_arg = Some((&cur[range.next..curlen]).to_string());
644+
let next = j + ch.len_utf8();
645+
if arg_follows && next < curlen {
646+
i_arg = Some((&cur[next..curlen]).to_string());
647647
break;
648648
}
649649

650-
j = range.next;
650+
j = next;
651651
}
652652
}
653653
let mut name_pos = 0;

src/liblibc/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,8 @@ pub mod types {
269269
#[repr(C)]
270270
#[derive(Copy)] pub struct sockaddr_storage {
271271
pub ss_family: sa_family_t,
272-
pub __ss_align: i64,
273-
pub __ss_pad2: [u8; 112],
272+
pub __ss_align: isize,
273+
pub __ss_pad2: [u8; 128 - 2 * (::core::isize::BYTES as usize)],
274274
}
275275
#[repr(C)]
276276
#[derive(Copy)] pub struct sockaddr_in {

src/librustc/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
#![feature(io)]
4343
#![feature(path_ext)]
4444
#![feature(str_words)]
45+
#![feature(str_char)]
4546
#![cfg_attr(test, feature(test))]
4647

4748
extern crate arena;

src/librustc_driver/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#![feature(exit_status)]
3939
#![feature(io)]
4040
#![feature(set_stdio)]
41+
#![feature(unicode)]
4142

4243
extern crate arena;
4344
extern crate flate;

src/librustc_lint/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#![feature(unsafe_destructor)]
4242
#![feature(staged_api)]
4343
#![feature(std_misc)]
44+
#![feature(str_char)]
4445
#![cfg_attr(test, feature(test))]
4546

4647
extern crate syntax;

src/librustc_typeck/check/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5240,7 +5240,7 @@ pub fn may_break(cx: &ty::ctxt, id: ast::NodeId, b: &ast::Block) -> bool {
52405240
// inside the loop?
52415241
(loop_query(&*b, |e| {
52425242
match *e {
5243-
ast::ExprBreak(_) => true,
5243+
ast::ExprBreak(None) => true,
52445244
_ => false
52455245
}
52465246
})) ||

src/libserialize/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ Core encoding and decoding interfaces.
3737
#![feature(staged_api)]
3838
#![feature(std_misc)]
3939
#![feature(unicode)]
40+
#![feature(str_char)]
4041
#![cfg_attr(test, feature(test))]
4142

4243
// test harness access

src/libstd/lib.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@
7373
//!
7474
//! ## Concurrency, I/O, and the runtime
7575
//!
76-
//! The [`thread`](thread/index.html) module contains Rust's threading abstractions,
77-
//! while [`comm`](comm/index.html) contains the channel types for message
78-
//! passing. [`sync`](sync/index.html) contains further, primitive, shared
79-
//! memory types, including [`atomic`](sync/atomic/index.html).
76+
//! The [`thread`](thread/index.html) module contains Rust's threading abstractions.
77+
//! [`sync`](sync/index.html) contains further, primitive, shared memory types,
78+
//! including [`atomic`](sync/atomic/index.html), and [`mpsc`](sync/mpmc/index.html),
79+
//! which contains the channel types for message passing.
8080
//!
8181
//! Common types of I/O, including files, TCP, UDP, pipes, Unix domain sockets,
8282
//! timers, and process spawning, are defined in the
@@ -127,6 +127,7 @@
127127
#![feature(int_uint)]
128128
#![feature(unique)]
129129
#![feature(allow_internal_unstable)]
130+
#![feature(str_char)]
130131
#![cfg_attr(test, feature(test, rustc_private))]
131132

132133
// Don't link to std. We are std.

src/libstd/net/ip.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ impl FromInner<libc::in_addr> for Ipv4Addr {
202202
impl Ipv6Addr {
203203
/// Create a new IPv6 address from eight 16-bit segments.
204204
///
205-
/// The result will represent the IP address a:b:c:d:e:f
205+
/// The result will represent the IP address a:b:c:d:e:f:g:h
206206
#[stable(feature = "rust1", since = "1.0.0")]
207207
pub fn new(a: u16, b: u16, c: u16, d: u16, e: u16, f: u16, g: u16,
208208
h: u16) -> Ipv6Addr {

0 commit comments

Comments
 (0)