Skip to content

Commit 5037513

Browse files
committed
Deal with the fallout of string stabilization
1 parent 31be331 commit 5037513

File tree

13 files changed

+88
-74
lines changed

13 files changed

+88
-74
lines changed

src/compiletest/runtest.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,8 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
444444
"-nx".to_string(),
445445
format!("-command={}", debugger_script.as_str().unwrap()));
446446

447-
let gdb_path = tool_path.append("/bin/arm-linux-androideabi-gdb");
447+
let mut gdb_path = tool_path;
448+
gdb_path.push_str("/bin/arm-linux-androideabi-gdb");
448449
let procsrv::Result {
449450
out,
450451
err,

src/libcollections/str.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ pub trait StrAllocating: Str {
698698
let me = self.as_slice();
699699
let mut out = String::with_capacity(me.len());
700700
for c in me.chars() {
701-
c.escape_default(|c| out.push_char(c));
701+
c.escape_default(|c| out.push(c));
702702
}
703703
out
704704
}
@@ -708,7 +708,7 @@ pub trait StrAllocating: Str {
708708
let me = self.as_slice();
709709
let mut out = String::with_capacity(me.len());
710710
for c in me.chars() {
711-
c.escape_unicode(|c| out.push_char(c));
711+
c.escape_unicode(|c| out.push(c));
712712
}
713713
out
714714
}

src/libcollections/string.rs

+34-25
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ impl String {
159159

160160
if i > 0 {
161161
unsafe {
162-
res.push_bytes(v.slice_to(i))
162+
res.as_mut_vec().push_all(v.slice_to(i))
163163
};
164164
}
165165

@@ -176,10 +176,10 @@ impl String {
176176
macro_rules! error(() => ({
177177
unsafe {
178178
if subseqidx != i_ {
179-
res.push_bytes(v.slice(subseqidx, i_));
179+
res.as_mut_vec().push_all(v.slice(subseqidx, i_));
180180
}
181181
subseqidx = i;
182-
res.push_bytes(REPLACEMENT);
182+
res.as_mut_vec().push_all(REPLACEMENT);
183183
}
184184
}))
185185

@@ -245,7 +245,7 @@ impl String {
245245
}
246246
if subseqidx < total {
247247
unsafe {
248-
res.push_bytes(v.slice(subseqidx, total))
248+
res.as_mut_vec().push_all(v.slice(subseqidx, total))
249249
};
250250
}
251251
Owned(res.into_string())
@@ -271,7 +271,7 @@ impl String {
271271
let mut s = String::with_capacity(v.len() / 2);
272272
for c in str::utf16_items(v) {
273273
match c {
274-
str::ScalarValue(c) => s.push_char(c),
274+
str::ScalarValue(c) => s.push(c),
275275
str::LoneSurrogate(_) => return None
276276
}
277277
}
@@ -332,6 +332,7 @@ impl String {
332332
/// # Example
333333
///
334334
/// ```
335+
/// # #![allow(deprecated)]
335336
/// let s = String::from_str("hello");
336337
/// let big = s.append(" ").append("world").append("!");
337338
/// // s has now been moved and cannot be used
@@ -362,11 +363,11 @@ impl String {
362363
}
363364

364365
let mut buf = String::new();
365-
buf.push_char(ch);
366+
buf.push(ch);
366367
let size = buf.len() * length;
367368
buf.reserve(size);
368369
for _ in range(1, length) {
369-
buf.push_char(ch)
370+
buf.push(ch)
370371
}
371372
buf
372373
}
@@ -380,6 +381,7 @@ impl String {
380381
/// # Example
381382
///
382383
/// ```rust
384+
/// # #![allow(deprecated)]
383385
/// let s = String::from_byte(104);
384386
/// assert_eq!(s.as_slice(), "h");
385387
/// ```
@@ -417,7 +419,7 @@ impl String {
417419
#[unstable = "duplicate of iterator-based functionality"]
418420
pub fn grow(&mut self, count: uint, ch: char) {
419421
for _ in range(0, count) {
420-
self.push_char(ch)
422+
self.push(ch)
421423
}
422424
}
423425

@@ -426,6 +428,7 @@ impl String {
426428
/// # Example
427429
///
428430
/// ```
431+
/// # #![allow(deprecated)]
429432
/// let s = String::with_capacity(10);
430433
/// assert!(s.byte_capacity() >= 10);
431434
/// ```
@@ -441,7 +444,7 @@ impl String {
441444
///
442445
/// ```
443446
/// let s = String::with_capacity(10);
444-
/// assert!(s.byte_capacity() >= 10);
447+
/// assert!(s.capacity() >= 10);
445448
/// ```
446449
#[inline]
447450
#[unstable = "just implemented, needs to prove itself"]
@@ -455,9 +458,9 @@ impl String {
455458
///
456459
/// ```
457460
/// let mut s = String::with_capacity(10);
458-
/// let before = s.byte_capacity();
461+
/// let before = s.capacity();
459462
/// s.reserve_additional(100);
460-
/// assert!(s.byte_capacity() - before >= 100);
463+
/// assert!(s.capacity() - before >= 100);
461464
/// ```
462465
#[inline]
463466
pub fn reserve_additional(&mut self, extra: uint) {
@@ -471,7 +474,7 @@ impl String {
471474
/// ```
472475
/// let mut s = String::new();
473476
/// s.reserve(10);
474-
/// assert!(s.byte_capacity() >= 10);
477+
/// assert!(s.capacity() >= 10);
475478
/// ```
476479
#[inline]
477480
pub fn reserve(&mut self, capacity: uint) {
@@ -485,7 +488,7 @@ impl String {
485488
/// ```
486489
/// let mut s = String::new();
487490
/// s.reserve_exact(10);
488-
/// assert_eq!(s.byte_capacity(), 10);
491+
/// assert_eq!(s.capacity(), 10);
489492
/// ```
490493
#[inline]
491494
pub fn reserve_exact(&mut self, capacity: uint) {
@@ -499,9 +502,9 @@ impl String {
499502
/// ```
500503
/// let mut s = String::from_str("foo");
501504
/// s.reserve(100);
502-
/// assert!(s.byte_capacity() >= 100);
505+
/// assert!(s.capacity() >= 100);
503506
/// s.shrink_to_fit();
504-
/// assert_eq!(s.byte_capacity(), 3);
507+
/// assert_eq!(s.capacity(), 3);
505508
/// ```
506509
#[inline]
507510
pub fn shrink_to_fit(&mut self) {
@@ -527,7 +530,7 @@ impl String {
527530
/// assert_eq!(s.as_slice(), "abc123");
528531
/// ```
529532
#[inline]
530-
#[stable = "function just renamed from push_char"]
533+
#[stable = "function just renamed from push"]
531534
pub fn push(&mut self, ch: char) {
532535
let cur_len = self.len();
533536
// This may use up to 4 bytes.
@@ -552,6 +555,7 @@ impl String {
552555
/// # Example
553556
///
554557
/// ```
558+
/// # #![allow(deprecated)]
555559
/// let mut s = String::new();
556560
/// unsafe {
557561
/// s.push_bytes([104, 101, 108, 108, 111]);
@@ -587,6 +591,7 @@ impl String {
587591
/// # Example
588592
///
589593
/// ```
594+
/// # #![allow(deprecated)]
590595
/// let mut s = String::from_str("hello");
591596
/// unsafe {
592597
/// let bytes = s.as_mut_bytes();
@@ -598,7 +603,7 @@ impl String {
598603
/// assert_eq!(s.as_slice(), "h3ll0")
599604
/// ```
600605
#[inline]
601-
#[deprecated = "call .as_mut_vec().as_slice() instead"]
606+
#[deprecated = "call .as_mut_vec().as_mut_slice() instead"]
602607
pub unsafe fn as_mut_bytes<'a>(&'a mut self) -> &'a mut [u8] {
603608
self.vec.as_mut_slice()
604609
}
@@ -631,6 +636,7 @@ impl String {
631636
/// # Example
632637
///
633638
/// ```
639+
/// # #![allow(deprecated)]
634640
/// let mut s = String::from_str("hell");
635641
/// unsafe {
636642
/// s.push_byte(111);
@@ -652,6 +658,7 @@ impl String {
652658
/// # Example
653659
///
654660
/// ```
661+
/// # #![allow(deprecated)]
655662
/// let mut s = String::from_str("foo");
656663
/// unsafe {
657664
/// assert_eq!(s.pop_byte(), Some(111));
@@ -714,6 +721,7 @@ impl String {
714721
/// # Example
715722
///
716723
/// ```
724+
/// # #![allow(deprecated)]
717725
/// let mut s = String::from_str("foo");
718726
/// unsafe {
719727
/// assert_eq!(s.shift_byte(), Some(102));
@@ -722,7 +730,7 @@ impl String {
722730
/// assert_eq!(s.shift_byte(), None);
723731
/// }
724732
/// ```
725-
#[deprecated = "call .as_mut_rev().remove(0)"]
733+
#[deprecated = "call .as_mut_vec().remove(0)"]
726734
pub unsafe fn shift_byte(&mut self) -> Option<u8> {
727735
self.vec.remove(0)
728736
}
@@ -782,6 +790,7 @@ impl String {
782790
///
783791
/// If `idx` does not lie on a character boundary or is out of bounds, then
784792
/// this function will fail.
793+
#[unstable = "the failure semantics of this function are uncertain"]
785794
pub fn insert(&mut self, idx: uint, ch: char) {
786795
let len = self.len();
787796
assert!(idx <= len);
@@ -854,7 +863,7 @@ impl FromIterator<char> for String {
854863
impl Extendable<char> for String {
855864
fn extend<I:Iterator<char>>(&mut self, mut iterator: I) {
856865
for ch in iterator {
857-
self.push_char(ch)
866+
self.push(ch)
858867
}
859868
}
860869
}
@@ -1171,13 +1180,13 @@ mod tests {
11711180
}
11721181

11731182
#[test]
1174-
fn test_push_char() {
1183+
fn test_push() {
11751184
let mut data = String::from_str("ประเทศไทย中");
1176-
data.push_char('华');
1177-
data.push_char('b'); // 1 byte
1178-
data.push_char('¢'); // 2 byte
1179-
data.push_char('€'); // 3 byte
1180-
data.push_char('𤭢'); // 4 byte
1185+
data.push('华');
1186+
data.push('b'); // 1 byte
1187+
data.push('¢'); // 2 byte
1188+
data.push('€'); // 3 byte
1189+
data.push('𤭢'); // 4 byte
11811190
assert_eq!(data.as_slice(), "ประเทศไทย中华b¢€𤭢");
11821191
}
11831192

src/libgetopts/lib.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -685,9 +685,9 @@ pub fn usage(brief: &str, opts: &[OptGroup]) -> String {
685685
match short_name.len() {
686686
0 => {}
687687
1 => {
688-
row.push_char('-');
688+
row.push('-');
689689
row.push_str(short_name.as_slice());
690-
row.push_char(' ');
690+
row.push(' ');
691691
}
692692
_ => fail!("the short name should only be 1 ascii char long"),
693693
}
@@ -698,7 +698,7 @@ pub fn usage(brief: &str, opts: &[OptGroup]) -> String {
698698
_ => {
699699
row.push_str("--");
700700
row.push_str(long_name.as_slice());
701-
row.push_char(' ');
701+
row.push(' ');
702702
}
703703
}
704704

@@ -707,9 +707,9 @@ pub fn usage(brief: &str, opts: &[OptGroup]) -> String {
707707
No => {}
708708
Yes => row.push_str(hint.as_slice()),
709709
Maybe => {
710-
row.push_char('[');
710+
row.push('[');
711711
row.push_str(hint.as_slice());
712-
row.push_char(']');
712+
row.push(']');
713713
}
714714
}
715715

@@ -718,7 +718,7 @@ pub fn usage(brief: &str, opts: &[OptGroup]) -> String {
718718
let rowlen = row.as_slice().char_len();
719719
if rowlen < 24 {
720720
for _ in range(0, 24 - rowlen) {
721-
row.push_char(' ');
721+
row.push(' ');
722722
}
723723
} else {
724724
row.push_str(desc_sep.as_slice())
@@ -728,7 +728,7 @@ pub fn usage(brief: &str, opts: &[OptGroup]) -> String {
728728
let mut desc_normalized_whitespace = String::new();
729729
for word in desc.as_slice().words() {
730730
desc_normalized_whitespace.push_str(word);
731-
desc_normalized_whitespace.push_char(' ');
731+
desc_normalized_whitespace.push(' ');
732732
}
733733

734734
// FIXME: #5516 should be graphemes not codepoints
@@ -755,31 +755,31 @@ fn format_option(opt: &OptGroup) -> String {
755755
let mut line = String::new();
756756

757757
if opt.occur != Req {
758-
line.push_char('[');
758+
line.push('[');
759759
}
760760

761761
// Use short_name is possible, but fallback to long_name.
762762
if opt.short_name.len() > 0 {
763-
line.push_char('-');
763+
line.push('-');
764764
line.push_str(opt.short_name.as_slice());
765765
} else {
766766
line.push_str("--");
767767
line.push_str(opt.long_name.as_slice());
768768
}
769769

770770
if opt.hasarg != No {
771-
line.push_char(' ');
771+
line.push(' ');
772772
if opt.hasarg == Maybe {
773-
line.push_char('[');
773+
line.push('[');
774774
}
775775
line.push_str(opt.hint.as_slice());
776776
if opt.hasarg == Maybe {
777-
line.push_char(']');
777+
line.push(']');
778778
}
779779
}
780780

781781
if opt.occur != Req {
782-
line.push_char(']');
782+
line.push(']');
783783
}
784784
if opt.occur == Multi {
785785
line.push_str("..");

src/libgraphviz/lib.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ impl<'a> LabelText<'a> {
426426
fn escape_str(s: &str) -> String {
427427
let mut out = String::with_capacity(s.len());
428428
for c in s.chars() {
429-
LabelText::escape_char(c, |c| out.push_char(c));
429+
LabelText::escape_char(c, |c| out.push(c));
430430
}
431431
out
432432
}
@@ -461,9 +461,11 @@ impl<'a> LabelText<'a> {
461461

462462
/// Puts `suffix` on a line below this label, with a blank line separator.
463463
pub fn suffix_line(self, suffix: LabelText) -> LabelText<'static> {
464-
let prefix = self.pre_escaped_content().into_string();
464+
let mut prefix = self.pre_escaped_content().into_string();
465465
let suffix = suffix.pre_escaped_content();
466-
EscStr(str::Owned(prefix.append(r"\n\n").append(suffix.as_slice())))
466+
prefix.push_str(r"\n\n");
467+
prefix.push_str(suffix.as_slice());
468+
EscStr(str::Owned(prefix))
467469
}
468470
}
469471

src/libregex/compile.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ impl Program {
105105
let mut pre = String::with_capacity(5);
106106
for inst in c.insts.slice_from(1).iter() {
107107
match *inst {
108-
OneChar(c, FLAG_EMPTY) => pre.push_char(c),
108+
OneChar(c, FLAG_EMPTY) => pre.push(c),
109109
_ => break
110110
}
111111
}

0 commit comments

Comments
 (0)