Skip to content

Commit cd1fdd6

Browse files
committed
---
yaml --- r: 63219 b: refs/heads/snap-stage3 c: 3c23a0a h: refs/heads/master i: 63217: 7137237 63215: 9eb6b9d v: v3
1 parent 340869f commit cd1fdd6

File tree

3 files changed

+32
-12
lines changed

3 files changed

+32
-12
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 2d28d645422c1617be58c8ca7ad9a457264ca850
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 96cd61ad034cc9e88ab6a7845c3480dbc1ea62f3
4+
refs/heads/snap-stage3: 3c23a0a836164ed3ac1b94b526ff8f4e71571e8e
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/compiletest/runtest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ fn run_debuginfo_test(config: &config, props: &TestProps, testfile: &Path) {
254254
}
255255
256256
// write debugger script
257-
let script_str = str::append(cmds, "\nquit\n");
257+
let script_str = cmds.append("\nquit\n");
258258
debug!("script_str = %s", script_str);
259259
dump_output_file(config, testfile, script_str, "debugger.script");
260260

branches/snap-stage3/src/libstd/str.rs

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -154,14 +154,6 @@ pub fn push_str(lhs: &mut ~str, rhs: &str) {
154154
lhs.push_str(rhs)
155155
}
156156

157-
/// Concatenate two strings together
158-
#[inline(always)]
159-
pub fn append(lhs: ~str, rhs: &str) -> ~str {
160-
let mut v = lhs;
161-
v.push_str_no_overallocate(rhs);
162-
v
163-
}
164-
165157
#[allow(missing_doc)]
166158
pub trait StrVector {
167159
pub fn concat(&self) -> ~str;
@@ -1515,8 +1507,6 @@ pub mod raw {
15151507
#[cfg(not(test))]
15161508
pub mod traits {
15171509
use ops::Add;
1518-
use str::append;
1519-
15201510
impl<'self> Add<&'self str,~str> for ~str {
15211511
#[inline(always)]
15221512
fn add(&self, rhs: & &'self str) -> ~str {
@@ -2100,6 +2090,7 @@ pub trait OwnedStr {
21002090
fn push_str_no_overallocate(&mut self, rhs: &str);
21012091
fn push_str(&mut self, rhs: &str);
21022092
fn push_char(&mut self, c: char);
2093+
fn append(&self, rhs: &str) -> ~str; // FIXME #4850: this should consume self.
21032094
fn reserve(&mut self, n: uint);
21042095
fn reserve_at_least(&mut self, n: uint);
21052096
}
@@ -2197,6 +2188,14 @@ impl OwnedStr for ~str {
21972188
raw::set_len(self, new_len);
21982189
}
21992190
}
2191+
/// Concatenate two strings together.
2192+
#[inline]
2193+
fn append(&self, rhs: &str) -> ~str {
2194+
// FIXME #4850: this should consume self, but that causes segfaults
2195+
let mut v = self.clone();
2196+
v.push_str_no_overallocate(rhs);
2197+
v
2198+
}
22002199
22012200
/**
22022201
* Reserves capacity for exactly `n` bytes in the given string, not including
@@ -2396,6 +2395,27 @@ mod tests {
23962395
assert_eq!("ประเทศไทย中华Việt Nam".rfind(|c: char| c == '华'), Some(30u));
23972396
}
23982397

2398+
#[test]
2399+
fn test_push_str() {
2400+
let mut s = ~"";
2401+
s.push_str("");
2402+
assert_eq!(s.slice_from(0), "");
2403+
s.push_str("abc");
2404+
assert_eq!(s.slice_from(0), "abc");
2405+
s.push_str("ประเทศไทย中华Việt Nam");
2406+
assert_eq!(s.slice_from(0), "abcประเทศไทย中华Việt Nam");
2407+
}
2408+
#[test]
2409+
fn test_append() {
2410+
let mut s = ~"";
2411+
s = s.append("");
2412+
assert_eq!(s.slice_from(0), "");
2413+
s = s.append("abc");
2414+
assert_eq!(s.slice_from(0), "abc");
2415+
s = s.append("ประเทศไทย中华Việt Nam");
2416+
assert_eq!(s.slice_from(0), "abcประเทศไทย中华Việt Nam");
2417+
}
2418+
23992419
#[test]
24002420
fn test_pop_char() {
24012421
let mut data = ~"ประเทศไทย中华";

0 commit comments

Comments
 (0)