Revert "std: convert {vec,str}::to_owned to methods."

This fixes the strange random crashes in compile-fail tests.

This reverts commit 96cd61ad03.

Conflicts:
	src/librustc/driver/driver.rs
	src/libstd/str.rs
	src/libsyntax/ext/quote.rs
This commit is contained in:
Brian Anderson
2013-06-13 19:06:47 -07:00
parent b417bc8511
commit 7755018074
30 changed files with 104 additions and 90 deletions

View File

@@ -107,17 +107,23 @@ pub fn from_bytes_slice<'a>(vector: &'a [u8]) -> &'a str {
}
}
/// Copy a slice into a new unique str
#[inline(always)]
pub fn to_owned(s: &str) -> ~str {
unsafe { raw::slice_bytes_owned(s, 0, s.len()) }
}
impl ToStr for ~str {
#[inline(always)]
fn to_str(&self) -> ~str { self.to_owned() }
fn to_str(&self) -> ~str { to_owned(*self) }
}
impl<'self> ToStr for &'self str {
#[inline(always)]
fn to_str(&self) -> ~str { self.to_owned() }
fn to_str(&self) -> ~str { to_owned(*self) }
}
impl ToStr for @str {
#[inline(always)]
fn to_str(&self) -> ~str { self.to_owned() }
fn to_str(&self) -> ~str { to_owned(*self) }
}
/**
@@ -950,7 +956,7 @@ impl<'self> StrUtil for &'self str {
// NB: len includes the trailing null.
assert!(len > 0);
if unsafe { *(ptr::offset(buf,len-1)) != 0 } {
self.to_owned().as_c_str(f)
to_owned(self).as_c_str(f)
} else {
f(buf as *libc::c_char)
}
@@ -1204,9 +1210,7 @@ pub mod traits {
impl<'self> Add<&'self str,~str> for ~str {
#[inline(always)]
fn add(&self, rhs: & &'self str) -> ~str {
let mut s = self.to_owned();
s.push_str(*rhs);
s
self.append((*rhs))
}
}
}
@@ -1665,11 +1669,8 @@ impl<'self> StrSlice<'self> for &'self str {
/// Copy a slice into a new unique str
#[inline]
fn to_owned(&self) -> ~str {
unsafe { raw::slice_bytes_owned(*self, 0, self.len()) }
}
fn to_owned(&self) -> ~str { to_owned(*self) }
/// Copy a slice into a new @str
#[inline]
fn to_managed(&self) -> @str {
let v = at_vec::from_fn(self.len() + 1, |i| {
@@ -2180,7 +2181,7 @@ impl OwnedStr for ~str {
impl Clone for ~str {
#[inline(always)]
fn clone(&self) -> ~str {
self.to_owned()
to_owned(*self)
}
}
@@ -3172,11 +3173,6 @@ mod tests {
assert_eq!("abc".to_managed(), @"abc");
assert_eq!("abcdef".slice(1, 5).to_managed(), @"bcde");
}
#[test]
fn test_to_owned() {
assert_eq!("abc".to_owned(), ~"abc");
assert_eq!("abcdef".slice(1, 5).to_owned(), ~"bcde");
}
#[test]
fn test_total_ord() {