about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-06-28 12:05:12 -0700
committerbors <bors@rust-lang.org>2013-06-28 12:05:12 -0700
commitf44b951a1ea40b61508b2d0abb3f239797f885c5 (patch)
tree326ffc88eb48938b5c57daad927cf6e7462a13e1 /src/libstd
parent4e4e2f70c90f01b5be22a192c883b9dcb34df7ff (diff)
parent4f044891a5457acb06338c78f9aa58d8b4c9d53f (diff)
downloadrust-f44b951a1ea40b61508b2d0abb3f239797f885c5.tar.gz
rust-f44b951a1ea40b61508b2d0abb3f239797f885c5.zip
auto merge of #7451 : cmr/rust/rewrite-each-path, r=pcwalton
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/char.rs1
-rw-r--r--src/libstd/clone.rs14
-rw-r--r--src/libstd/comm.rs100
-rw-r--r--src/libstd/hash.rs7
-rw-r--r--src/libstd/io.rs7
-rw-r--r--src/libstd/kinds.rs27
-rw-r--r--src/libstd/num/int_macros.rs3
-rw-r--r--src/libstd/num/num.rs2
-rw-r--r--src/libstd/num/uint_macros.rs3
-rw-r--r--src/libstd/os.rs8
-rw-r--r--src/libstd/path.rs80
-rw-r--r--src/libstd/pipes.rs34
-rw-r--r--src/libstd/prelude.rs3
-rw-r--r--src/libstd/rand.rs4
-rw-r--r--src/libstd/rand/distributions.rs3
-rw-r--r--src/libstd/rt/comm.rs10
-rw-r--r--src/libstd/rt/io/extensions.rs7
-rw-r--r--src/libstd/rt/message_queue.rs4
-rw-r--r--src/libstd/rt/work_queue.rs4
-rw-r--r--src/libstd/str.rs103
-rw-r--r--src/libstd/task/mod.rs8
-rw-r--r--src/libstd/task/spawn.rs3
-rw-r--r--src/libstd/to_str.rs15
-rw-r--r--src/libstd/unstable/extfmt.rs1
-rw-r--r--src/libstd/unstable/global.rs14
-rw-r--r--src/libstd/unstable/sync.rs12
-rw-r--r--src/libstd/vec.rs9
27 files changed, 326 insertions, 160 deletions
diff --git a/src/libstd/char.rs b/src/libstd/char.rs
index 797fd9e8c02..8f0870af513 100644
--- a/src/libstd/char.rs
+++ b/src/libstd/char.rs
@@ -10,6 +10,7 @@
 
 //! Utilities for manipulating the char type
 
+use container::Container;
 use option::{None, Option, Some};
 use str;
 use str::{StrSlice, OwnedStr};
diff --git a/src/libstd/clone.rs b/src/libstd/clone.rs
index 046693632c6..947aa5708c2 100644
--- a/src/libstd/clone.rs
+++ b/src/libstd/clone.rs
@@ -22,7 +22,7 @@ by convention implementing the `Clone` trait and calling the
 
 */
 
-use core::kinds::Const;
+use core::kinds::Freeze;
 
 /// A common trait for cloning an object.
 pub trait Clone {
@@ -112,17 +112,17 @@ impl<T: DeepClone> DeepClone for ~T {
     fn deep_clone(&self) -> ~T { ~(**self).deep_clone() }
 }
 
-// FIXME: #6525: should also be implemented for `T: Owned + DeepClone`
-impl<T: Const + DeepClone> DeepClone for @T {
-    /// Return a deep copy of the managed box. The `Const` trait is required to prevent performing
+// FIXME: #6525: should also be implemented for `T: Send + DeepClone`
+impl<T: Freeze + DeepClone> DeepClone for @T {
+    /// Return a deep copy of the managed box. The `Freeze` trait is required to prevent performing
     /// a deep clone of a potentially cyclical type.
     #[inline]
     fn deep_clone(&self) -> @T { @(**self).deep_clone() }
 }
 
-// FIXME: #6525: should also be implemented for `T: Owned + DeepClone`
-impl<T: Const + DeepClone> DeepClone for @mut T {
-    /// Return a deep copy of the managed box. The `Const` trait is required to prevent performing
+// FIXME: #6525: should also be implemented for `T: Send + DeepClone`
+impl<T: Freeze + DeepClone> DeepClone for @mut T {
+    /// Return a deep copy of the managed box. The `Freeze` trait is required to prevent performing
     /// a deep clone of a potentially cyclical type.
     #[inline]
     fn deep_clone(&self) -> @mut T { @mut (**self).deep_clone() }
diff --git a/src/libstd/comm.rs b/src/libstd/comm.rs
index 7918abe4ae6..8316a33ecf1 100644
--- a/src/libstd/comm.rs
+++ b/src/libstd/comm.rs
@@ -17,7 +17,7 @@ Message passing
 use cast::{transmute, transmute_mut};
 use container::Container;
 use either::{Either, Left, Right};
-use kinds::Owned;
+use kinds::Send;
 use option::{Option, Some, None};
 use uint;
 use vec::OwnedVector;
@@ -77,7 +77,7 @@ pub struct Port<T> {
 These allow sending or receiving an unlimited number of messages.
 
 */
-pub fn stream<T:Owned>() -> (Port<T>, Chan<T>) {
+pub fn stream<T:Send>() -> (Port<T>, Chan<T>) {
     let (port, chan) = match rt::context() {
         rt::OldTaskContext => match pipesy::stream() {
             (p, c) => (Left(p), Left(c))
@@ -91,7 +91,7 @@ pub fn stream<T:Owned>() -> (Port<T>, Chan<T>) {
     return (port, chan);
 }
 
-impl<T: Owned> GenericChan<T> for Chan<T> {
+impl<T: Send> GenericChan<T> for Chan<T> {
     fn send(&self, x: T) {
         match self.inner {
             Left(ref chan) => chan.send(x),
@@ -100,7 +100,7 @@ impl<T: Owned> GenericChan<T> for Chan<T> {
     }
 }
 
-impl<T: Owned> GenericSmartChan<T> for Chan<T> {
+impl<T: Send> GenericSmartChan<T> for Chan<T> {
     fn try_send(&self, x: T) -> bool {
         match self.inner {
             Left(ref chan) => chan.try_send(x),
@@ -109,7 +109,7 @@ impl<T: Owned> GenericSmartChan<T> for Chan<T> {
     }
 }
 
-impl<T: Owned> GenericPort<T> for Port<T> {
+impl<T: Send> GenericPort<T> for Port<T> {
     fn recv(&self) -> T {
         match self.inner {
             Left(ref port) => port.recv(),
@@ -125,7 +125,7 @@ impl<T: Owned> GenericPort<T> for Port<T> {
     }
 }
 
-impl<T: Owned> Peekable<T> for Port<T> {
+impl<T: Send> Peekable<T> for Port<T> {
     fn peek(&self) -> bool {
         match self.inner {
             Left(ref port) => port.peek(),
@@ -134,7 +134,7 @@ impl<T: Owned> Peekable<T> for Port<T> {
     }
 }
 
-impl<T: Owned> Selectable for Port<T> {
+impl<T: Send> Selectable for Port<T> {
     fn header(&mut self) -> *mut PacketHeader {
         match self.inner {
             Left(ref mut port) => port.header(),
@@ -149,7 +149,7 @@ pub struct PortSet<T> {
     ports: ~[pipesy::Port<T>],
 }
 
-impl<T: Owned> PortSet<T> {
+impl<T: Send> PortSet<T> {
     pub fn new() -> PortSet<T> {
         PortSet {
             ports: ~[]
@@ -175,7 +175,7 @@ impl<T: Owned> PortSet<T> {
     }
 }
 
-impl<T:Owned> GenericPort<T> for PortSet<T> {
+impl<T:Send> GenericPort<T> for PortSet<T> {
     fn try_recv(&self) -> Option<T> {
         unsafe {
             let self_ports = transmute_mut(&self.ports);
@@ -204,7 +204,7 @@ impl<T:Owned> GenericPort<T> for PortSet<T> {
     }
 }
 
-impl<T: Owned> Peekable<T> for PortSet<T> {
+impl<T: Send> Peekable<T> for PortSet<T> {
     fn peek(&self) -> bool {
         // It'd be nice to use self.port.each, but that version isn't
         // pure.
@@ -223,7 +223,7 @@ pub struct SharedChan<T> {
     ch: Exclusive<pipesy::Chan<T>>
 }
 
-impl<T: Owned> SharedChan<T> {
+impl<T: Send> SharedChan<T> {
     /// Converts a `chan` into a `shared_chan`.
     pub fn new(c: Chan<T>) -> SharedChan<T> {
         let Chan { inner } = c;
@@ -235,7 +235,7 @@ impl<T: Owned> SharedChan<T> {
     }
 }
 
-impl<T: Owned> GenericChan<T> for SharedChan<T> {
+impl<T: Send> GenericChan<T> for SharedChan<T> {
     fn send(&self, x: T) {
         unsafe {
             let mut xx = Some(x);
@@ -247,7 +247,7 @@ impl<T: Owned> GenericChan<T> for SharedChan<T> {
     }
 }
 
-impl<T: Owned> GenericSmartChan<T> for SharedChan<T> {
+impl<T: Send> GenericSmartChan<T> for SharedChan<T> {
     fn try_send(&self, x: T) -> bool {
         unsafe {
             let mut xx = Some(x);
@@ -259,7 +259,7 @@ impl<T: Owned> GenericSmartChan<T> for SharedChan<T> {
     }
 }
 
-impl<T: Owned> ::clone::Clone for SharedChan<T> {
+impl<T: Send> ::clone::Clone for SharedChan<T> {
     fn clone(&self) -> SharedChan<T> {
         SharedChan { ch: self.ch.clone() }
     }
@@ -273,7 +273,7 @@ pub struct ChanOne<T> {
     inner: Either<pipesy::ChanOne<T>, rtcomm::ChanOne<T>>
 }
 
-pub fn oneshot<T: Owned>() -> (PortOne<T>, ChanOne<T>) {
+pub fn oneshot<T: Send>() -> (PortOne<T>, ChanOne<T>) {
     let (port, chan) = match rt::context() {
         rt::OldTaskContext => match pipesy::oneshot() {
             (p, c) => (Left(p), Left(c)),
@@ -287,7 +287,7 @@ pub fn oneshot<T: Owned>() -> (PortOne<T>, ChanOne<T>) {
     return (port, chan);
 }
 
-impl<T: Owned> PortOne<T> {
+impl<T: Send> PortOne<T> {
     pub fn recv(self) -> T {
         let PortOne { inner } = self;
         match inner {
@@ -305,7 +305,7 @@ impl<T: Owned> PortOne<T> {
     }
 }
 
-impl<T: Owned> ChanOne<T> {
+impl<T: Send> ChanOne<T> {
     pub fn send(self, data: T) {
         let ChanOne { inner } = self;
         match inner {
@@ -323,7 +323,7 @@ impl<T: Owned> ChanOne<T> {
     }
 }
 
-pub fn recv_one<T: Owned>(port: PortOne<T>) -> T {
+pub fn recv_one<T: Send>(port: PortOne<T>) -> T {
     let PortOne { inner } = port;
     match inner {
         Left(p) => pipesy::recv_one(p),
@@ -331,7 +331,7 @@ pub fn recv_one<T: Owned>(port: PortOne<T>) -> T {
     }
 }
 
-pub fn try_recv_one<T: Owned>(port: PortOne<T>) -> Option<T> {
+pub fn try_recv_one<T: Send>(port: PortOne<T>) -> Option<T> {
     let PortOne { inner } = port;
     match inner {
         Left(p) => pipesy::try_recv_one(p),
@@ -339,7 +339,7 @@ pub fn try_recv_one<T: Owned>(port: PortOne<T>) -> Option<T> {
     }
 }
 
-pub fn send_one<T: Owned>(chan: ChanOne<T>, data: T) {
+pub fn send_one<T: Send>(chan: ChanOne<T>, data: T) {
     let ChanOne { inner } = chan;
     match inner {
         Left(c) => pipesy::send_one(c, data),
@@ -347,7 +347,7 @@ pub fn send_one<T: Owned>(chan: ChanOne<T>, data: T) {
     }
 }
 
-pub fn try_send_one<T: Owned>(chan: ChanOne<T>, data: T) -> bool {
+pub fn try_send_one<T: Send>(chan: ChanOne<T>, data: T) -> bool {
     let ChanOne { inner } = chan;
     match inner {
         Left(c) => pipesy::try_send_one(c, data),
@@ -357,7 +357,7 @@ pub fn try_send_one<T: Owned>(chan: ChanOne<T>, data: T) -> bool {
 
 mod pipesy {
 
-    use kinds::Owned;
+    use kinds::Send;
     use option::{Option, Some, None};
     use pipes::{recv, try_recv, peek, PacketHeader};
     use super::{GenericChan, GenericSmartChan, GenericPort, Peekable, Selectable};
@@ -365,17 +365,17 @@ mod pipesy {
     use util::replace;
 
     /*proto! oneshot (
-        Oneshot:send<T:Owned> {
+        Oneshot:send<T:Send> {
             send(T) -> !
         }
     )*/
 
     #[allow(non_camel_case_types)]
     pub mod oneshot {
-        priv use core::kinds::Owned;
+        priv use core::kinds::Send;
         use ptr::to_mut_unsafe_ptr;
 
-        pub fn init<T: Owned>() -> (server::Oneshot<T>, client::Oneshot<T>) {
+        pub fn init<T: Send>() -> (server::Oneshot<T>, client::Oneshot<T>) {
             pub use core::pipes::HasBuffer;
 
             let buffer = ~::core::pipes::Buffer {
@@ -399,10 +399,10 @@ mod pipesy {
         #[allow(non_camel_case_types)]
         pub mod client {
 
-            priv use core::kinds::Owned;
+            priv use core::kinds::Send;
 
             #[allow(non_camel_case_types)]
-            pub fn try_send<T: Owned>(pipe: Oneshot<T>, x_0: T) ->
+            pub fn try_send<T: Send>(pipe: Oneshot<T>, x_0: T) ->
                 ::core::option::Option<()> {
                 {
                     use super::send;
@@ -414,7 +414,7 @@ mod pipesy {
             }
 
             #[allow(non_camel_case_types)]
-            pub fn send<T: Owned>(pipe: Oneshot<T>, x_0: T) {
+            pub fn send<T: Send>(pipe: Oneshot<T>, x_0: T) {
                 {
                     use super::send;
                     let message = send(x_0);
@@ -464,12 +464,12 @@ mod pipesy {
     }
 
     /// Initialiase a (send-endpoint, recv-endpoint) oneshot pipe pair.
-    pub fn oneshot<T: Owned>() -> (PortOne<T>, ChanOne<T>) {
+    pub fn oneshot<T: Send>() -> (PortOne<T>, ChanOne<T>) {
         let (port, chan) = oneshot::init();
         (PortOne::new(port), ChanOne::new(chan))
     }
 
-    impl<T: Owned> PortOne<T> {
+    impl<T: Send> PortOne<T> {
         pub fn recv(self) -> T { recv_one(self) }
         pub fn try_recv(self) -> Option<T> { try_recv_one(self) }
         pub fn unwrap(self) -> oneshot::server::Oneshot<T> {
@@ -479,7 +479,7 @@ mod pipesy {
         }
     }
 
-    impl<T: Owned> ChanOne<T> {
+    impl<T: Send> ChanOne<T> {
         pub fn send(self, data: T) { send_one(self, data) }
         pub fn try_send(self, data: T) -> bool { try_send_one(self, data) }
         pub fn unwrap(self) -> oneshot::client::Oneshot<T> {
@@ -493,7 +493,7 @@ mod pipesy {
     * Receive a message from a oneshot pipe, failing if the connection was
     * closed.
     */
-    pub fn recv_one<T: Owned>(port: PortOne<T>) -> T {
+    pub fn recv_one<T: Send>(port: PortOne<T>) -> T {
         match port {
             PortOne { contents: port } => {
                 let oneshot::send(message) = recv(port);
@@ -503,7 +503,7 @@ mod pipesy {
     }
 
     /// Receive a message from a oneshot pipe unless the connection was closed.
-    pub fn try_recv_one<T: Owned> (port: PortOne<T>) -> Option<T> {
+    pub fn try_recv_one<T: Send> (port: PortOne<T>) -> Option<T> {
         match port {
             PortOne { contents: port } => {
                 let message = try_recv(port);
@@ -519,7 +519,7 @@ mod pipesy {
     }
 
     /// Send a message on a oneshot pipe, failing if the connection was closed.
-    pub fn send_one<T: Owned>(chan: ChanOne<T>, data: T) {
+    pub fn send_one<T: Send>(chan: ChanOne<T>, data: T) {
         match chan {
             ChanOne { contents: chan } => oneshot::client::send(chan, data),
         }
@@ -529,7 +529,7 @@ mod pipesy {
     * Send a message on a oneshot pipe, or return false if the connection was
     * closed.
     */
-    pub fn try_send_one<T: Owned>(chan: ChanOne<T>, data: T) -> bool {
+    pub fn try_send_one<T: Send>(chan: ChanOne<T>, data: T) -> bool {
         match chan {
             ChanOne { contents: chan } => {
                 oneshot::client::try_send(chan, data).is_some()
@@ -540,16 +540,16 @@ mod pipesy {
     // Streams - Make pipes a little easier in general.
 
     /*proto! streamp (
-        Open:send<T: Owned> {
+        Open:send<T: Send> {
             data(T) -> Open<T>
         }
     )*/
 
     #[allow(non_camel_case_types)]
     pub mod streamp {
-        priv use core::kinds::Owned;
+        priv use core::kinds::Send;
 
-        pub fn init<T: Owned>() -> (server::Open<T>, client::Open<T>) {
+        pub fn init<T: Send>() -> (server::Open<T>, client::Open<T>) {
             pub use core::pipes::HasBuffer;
             ::core::pipes::entangle()
         }
@@ -559,10 +559,10 @@ mod pipesy {
 
         #[allow(non_camel_case_types)]
         pub mod client {
-            priv use core::kinds::Owned;
+            priv use core::kinds::Send;
 
             #[allow(non_camel_case_types)]
-            pub fn try_data<T: Owned>(pipe: Open<T>, x_0: T) ->
+            pub fn try_data<T: Send>(pipe: Open<T>, x_0: T) ->
                 ::core::option::Option<Open<T>> {
                 {
                     use super::data;
@@ -575,7 +575,7 @@ mod pipesy {
             }
 
             #[allow(non_camel_case_types)]
-            pub fn data<T: Owned>(pipe: Open<T>, x_0: T) -> Open<T> {
+            pub fn data<T: Send>(pipe: Open<T>, x_0: T) -> Open<T> {
                 {
                     use super::data;
                     let (s, c) = ::core::pipes::entangle();
@@ -613,7 +613,7 @@ mod pipesy {
     These allow sending or receiving an unlimited number of messages.
 
     */
-    pub fn stream<T:Owned>() -> (Port<T>, Chan<T>) {
+    pub fn stream<T:Send>() -> (Port<T>, Chan<T>) {
         let (s, c) = streamp::init();
 
         (Port {
@@ -623,7 +623,7 @@ mod pipesy {
         })
     }
 
-    impl<T: Owned> GenericChan<T> for Chan<T> {
+    impl<T: Send> GenericChan<T> for Chan<T> {
         #[inline]
         fn send(&self, x: T) {
             unsafe {
@@ -634,7 +634,7 @@ mod pipesy {
         }
     }
 
-    impl<T: Owned> GenericSmartChan<T> for Chan<T> {
+    impl<T: Send> GenericSmartChan<T> for Chan<T> {
         #[inline]
         fn try_send(&self, x: T) -> bool {
             unsafe {
@@ -651,7 +651,7 @@ mod pipesy {
         }
     }
 
-    impl<T: Owned> GenericPort<T> for Port<T> {
+    impl<T: Send> GenericPort<T> for Port<T> {
         #[inline]
         fn recv(&self) -> T {
             unsafe {
@@ -679,7 +679,7 @@ mod pipesy {
         }
     }
 
-    impl<T: Owned> Peekable<T> for Port<T> {
+    impl<T: Send> Peekable<T> for Port<T> {
         #[inline]
         fn peek(&self) -> bool {
             unsafe {
@@ -695,7 +695,7 @@ mod pipesy {
         }
     }
 
-    impl<T: Owned> Selectable for Port<T> {
+    impl<T: Send> Selectable for Port<T> {
         fn header(&mut self) -> *mut PacketHeader {
             match self.endp {
                 Some(ref mut endp) => endp.header(),
@@ -723,15 +723,15 @@ pub fn select2i<A:Selectable, B:Selectable>(a: &mut A, b: &mut B)
 }
 
 /// Receive a message from one of two endpoints.
-pub trait Select2<T: Owned, U: Owned> {
+pub trait Select2<T: Send, U: Send> {
     /// Receive a message or return `None` if a connection closes.
     fn try_select(&mut self) -> Either<Option<T>, Option<U>>;
     /// Receive a message or fail if a connection closes.
     fn select(&mut self) -> Either<T, U>;
 }
 
-impl<T:Owned,
-     U:Owned,
+impl<T:Send,
+     U:Send,
      Left:Selectable + GenericPort<T>,
      Right:Selectable + GenericPort<U>>
      Select2<T, U>
diff --git a/src/libstd/hash.rs b/src/libstd/hash.rs
index 8e88bfb4632..6c3fcd41ed3 100644
--- a/src/libstd/hash.rs
+++ b/src/libstd/hash.rs
@@ -24,6 +24,7 @@
 use container::Container;
 use iterator::IteratorUtil;
 use rt::io::Writer;
+use str::OwnedStr;
 use to_bytes::IterBytes;
 use uint;
 use vec::ImmutableVector;
@@ -369,7 +370,7 @@ impl Streaming for SipState {
         let r = self.result_bytes();
         let mut s = ~"";
         for r.iter().advance |b| {
-            s += uint::to_str_radix(*b as uint, 16u);
+            s.push_str(uint::to_str_radix(*b as uint, 16u));
         }
         s
     }
@@ -471,7 +472,7 @@ mod tests {
         fn to_hex_str(r: &[u8, ..8]) -> ~str {
             let mut s = ~"";
             for r.iter().advance |b| {
-                s += uint::to_str_radix(*b as uint, 16u);
+                s.push_str(uint::to_str_radix(*b as uint, 16u));
             }
             s
         }
@@ -492,7 +493,7 @@ mod tests {
 
             assert!(f == i && f == v);
 
-            buf += [t as u8];
+            buf.push(t as u8);
             stream_inc.input([t as u8]);
 
             t += 1;
diff --git a/src/libstd/io.rs b/src/libstd/io.rs
index 36920bd2488..59ac58a514f 100644
--- a/src/libstd/io.rs
+++ b/src/libstd/io.rs
@@ -771,7 +771,9 @@ impl<T:Reader> ReaderUtil for T {
     fn read_le_uint_n(&self, nbytes: uint) -> u64 {
         assert!(nbytes > 0 && nbytes <= 8);
 
-        let mut (val, pos, i) = (0u64, 0, nbytes);
+        let mut val = 0u64;
+        let mut pos = 0;
+        let mut i = nbytes;
         while i > 0 {
             val += (self.read_u8() as u64) << pos;
             pos += 8;
@@ -787,7 +789,8 @@ impl<T:Reader> ReaderUtil for T {
     fn read_be_uint_n(&self, nbytes: uint) -> u64 {
         assert!(nbytes > 0 && nbytes <= 8);
 
-        let mut (val, i) = (0u64, nbytes);
+        let mut val = 0u64;
+        let mut i = nbytes;
         while i > 0 {
             i -= 1;
             val += (self.read_u8() as u64) << i * 8;
diff --git a/src/libstd/kinds.rs b/src/libstd/kinds.rs
index 05c963a32cc..f350e106168 100644
--- a/src/libstd/kinds.rs
+++ b/src/libstd/kinds.rs
@@ -24,11 +24,10 @@ The 4 kinds are
   scalar types and managed pointers, and exludes owned pointers. It
   also excludes types that implement `Drop`.
 
-* Owned - owned types and types containing owned types.  These types
+* Send - owned types and types containing owned types.  These types
   may be transferred across task boundaries.
 
-* Const - types that are deeply immutable. Const types are used for
-  freezable data structures.
+* Freeze - types that are deeply immutable.
 
 `Copy` types include both implicitly copyable types that the compiler
 will copy automatically and non-implicitly copyable types that require
@@ -44,14 +43,28 @@ pub trait Copy {
     // Empty.
 }
 
+#[cfg(stage0)]
 #[lang="owned"]
-pub trait Owned {
-    // Empty.
+pub trait Send {
+    // empty.
+}
+
+#[cfg(not(stage0))]
+#[lang="send"]
+pub trait Send {
+    // empty.
 }
 
+#[cfg(stage0)]
 #[lang="const"]
-pub trait Const {
-    // Empty.
+pub trait Freeze {
+    // empty.
+}
+
+#[cfg(not(stage0))]
+#[lang="freeze"]
+pub trait Freeze {
+    // empty.
 }
 
 #[lang="sized"]
diff --git a/src/libstd/num/int_macros.rs b/src/libstd/num/int_macros.rs
index 74ec46ccfcd..845152f8552 100644
--- a/src/libstd/num/int_macros.rs
+++ b/src/libstd/num/int_macros.rs
@@ -400,7 +400,8 @@ impl Integer for $T {
     #[inline]
     fn gcd(&self, other: &$T) -> $T {
         // Use Euclid's algorithm
-        let mut (m, n) = (*self, *other);
+        let mut m = *self;
+        let mut n = *other;
         while m != 0 {
             let temp = m;
             m = n % temp;
diff --git a/src/libstd/num/num.rs b/src/libstd/num/num.rs
index 30a18a0587b..b856c3c65ea 100644
--- a/src/libstd/num/num.rs
+++ b/src/libstd/num/num.rs
@@ -412,7 +412,7 @@ pub fn pow_with_uint<T:NumCast+One+Zero+Copy+Div<T,T>+Mul<T,T>>(radix: uint, pow
         if my_pow % 2u == 1u {
             total = total * multiplier;
         }
-        my_pow     = my_pow / 2u;
+        my_pow = my_pow / 2u;
         multiplier = multiplier * multiplier;
     }
     total
diff --git a/src/libstd/num/uint_macros.rs b/src/libstd/num/uint_macros.rs
index 52f620f97ce..0dabe7fafa8 100644
--- a/src/libstd/num/uint_macros.rs
+++ b/src/libstd/num/uint_macros.rs
@@ -237,7 +237,8 @@ impl Integer for $T {
     #[inline]
     fn gcd(&self, other: &$T) -> $T {
         // Use Euclid's algorithm
-        let mut (m, n) = (*self, *other);
+        let mut m = *self;
+        let mut n = *other;
         while m != 0 {
             let temp = m;
             m = n % temp;
diff --git a/src/libstd/os.rs b/src/libstd/os.rs
index 7d848184493..400a93ee28f 100644
--- a/src/libstd/os.rs
+++ b/src/libstd/os.rs
@@ -29,6 +29,7 @@
 #[allow(missing_doc)];
 
 use cast;
+use container::Container;
 use io;
 use iterator::IteratorUtil;
 use libc;
@@ -145,7 +146,7 @@ pub mod win32 {
     pub fn as_utf16_p<T>(s: &str, f: &fn(*u16) -> T) -> T {
         let mut t = s.to_utf16();
         // Null terminate before passing on.
-        t += [0u16];
+        t.push(0u16);
         vec::as_imm_buf(t, |buf, _len| f(buf))
     }
 }
@@ -1500,7 +1501,10 @@ mod tests {
     fn test_getenv_big() {
         let mut s = ~"";
         let mut i = 0;
-        while i < 100 { s += "aaaaaaaaaa"; i += 1; }
+        while i < 100 {
+            s = s + "aaaaaaaaaa";
+            i += 1;
+        }
         let n = make_rand_name();
         setenv(n, s);
         debug!(copy s);
diff --git a/src/libstd/path.rs b/src/libstd/path.rs
index 89792694011..a5e82c31d79 100644
--- a/src/libstd/path.rs
+++ b/src/libstd/path.rs
@@ -21,8 +21,8 @@ use cmp::Eq;
 use iterator::IteratorUtil;
 use libc;
 use option::{None, Option, Some};
+use str::{OwnedStr, Str, StrSlice, StrVector};
 use str;
-use str::{Str, StrSlice, StrVector};
 use to_str::ToStr;
 use ascii::{AsciiCast, AsciiStr};
 use vec::{OwnedVector, ImmutableVector};
@@ -335,8 +335,8 @@ mod stat {
     }
 }
 
-
-impl Path {
+#[cfg(target_os = "win32")]
+impl WindowsPath {
     pub fn stat(&self) -> Option<libc::stat> {
         unsafe {
              do str::as_c_str(self.to_str()) |buf| {
@@ -349,12 +349,35 @@ impl Path {
         }
     }
 
-    #[cfg(unix)]
-    pub fn lstat(&self) -> Option<libc::stat> {
+    pub fn exists(&self) -> bool {
+        match self.stat() {
+            None => false,
+            Some(_) => true,
+        }
+    }
+
+    pub fn get_size(&self) -> Option<i64> {
+        match self.stat() {
+            None => None,
+            Some(ref st) => Some(st.st_size as i64),
+        }
+    }
+
+    pub fn get_mode(&self) -> Option<uint> {
+        match self.stat() {
+            None => None,
+            Some(ref st) => Some(st.st_mode as uint),
+        }
+    }
+}
+
+#[cfg(not(target_os = "win32"))]
+impl PosixPath {
+    pub fn stat(&self) -> Option<libc::stat> {
         unsafe {
-            do str::as_c_str(self.to_str()) |buf| {
+             do str::as_c_str(self.to_str()) |buf| {
                 let mut st = stat::arch::default_stat();
-                match libc::lstat(buf, &mut st) {
+                match libc::stat(buf, &mut st) {
                     0 => Some(st),
                     _ => None,
                 }
@@ -396,7 +419,7 @@ impl Path {
 #[cfg(target_os = "freebsd")]
 #[cfg(target_os = "linux")]
 #[cfg(target_os = "macos")]
-impl Path {
+impl PosixPath {
     pub fn get_atime(&self) -> Option<(i64, int)> {
         match self.stat() {
             None => None,
@@ -428,9 +451,24 @@ impl Path {
     }
 }
 
+#[cfg(unix)]
+impl PosixPath {
+    pub fn lstat(&self) -> Option<libc::stat> {
+        unsafe {
+            do str::as_c_str(self.to_str()) |buf| {
+                let mut st = stat::arch::default_stat();
+                match libc::lstat(buf, &mut st) {
+                    0 => Some(st),
+                    _ => None,
+                }
+            }
+        }
+    }
+}
+
 #[cfg(target_os = "freebsd")]
 #[cfg(target_os = "macos")]
-impl Path {
+impl PosixPath {
     pub fn get_birthtime(&self) -> Option<(i64, int)> {
         match self.stat() {
             None => None,
@@ -443,7 +481,7 @@ impl Path {
 }
 
 #[cfg(target_os = "win32")]
-impl Path {
+impl WindowsPath {
     pub fn get_atime(&self) -> Option<(i64, int)> {
         match self.stat() {
             None => None,
@@ -470,13 +508,21 @@ impl Path {
             }
         }
     }
+
+    /// Execute a function on p as well as all of its ancestors
+    pub fn each_parent(&self, f: &fn(&Path)) {
+        if !self.components.is_empty() {
+            f(self);
+            self.pop().each_parent(f);
+        }
+    }
 }
 
 impl ToStr for PosixPath {
     fn to_str(&self) -> ~str {
         let mut s = ~"";
         if self.is_absolute {
-            s += "/";
+            s.push_str("/");
         }
         s + self.components.connect("/")
     }
@@ -655,15 +701,21 @@ impl ToStr for WindowsPath {
     fn to_str(&self) -> ~str {
         let mut s = ~"";
         match self.host {
-          Some(ref h) => { s += "\\\\"; s += *h; }
+          Some(ref h) => {
+            s.push_str("\\\\");
+            s.push_str(*h);
+          }
           None => { }
         }
         match self.device {
-          Some(ref d) => { s += *d; s += ":"; }
+          Some(ref d) => {
+            s.push_str(*d);
+            s.push_str(":");
+          }
           None => { }
         }
         if self.is_absolute {
-            s += "\\";
+            s.push_str("\\");
         }
         s + self.components.connect("\\")
     }
diff --git a/src/libstd/pipes.rs b/src/libstd/pipes.rs
index 661dc2a659f..49713a3a23b 100644
--- a/src/libstd/pipes.rs
+++ b/src/libstd/pipes.rs
@@ -88,7 +88,7 @@ use container::Container;
 use cast::{forget, transmute, transmute_copy, transmute_mut};
 use either::{Either, Left, Right};
 use iterator::IteratorUtil;
-use kinds::Owned;
+use kinds::Send;
 use libc;
 use ops::Drop;
 use option::{None, Option, Some};
@@ -177,7 +177,7 @@ impl PacketHeader {
         transmute_copy(&self.buffer)
     }
 
-    pub fn set_buffer<T:Owned>(&mut self, b: ~Buffer<T>) {
+    pub fn set_buffer<T:Send>(&mut self, b: ~Buffer<T>) {
         unsafe {
             self.buffer = transmute_copy(&b);
         }
@@ -193,13 +193,13 @@ pub trait HasBuffer {
     fn set_buffer(&mut self, b: *libc::c_void);
 }
 
-impl<T:Owned> HasBuffer for Packet<T> {
+impl<T:Send> HasBuffer for Packet<T> {
     fn set_buffer(&mut self, b: *libc::c_void) {
         self.header.buffer = b;
     }
 }
 
-pub fn mk_packet<T:Owned>() -> Packet<T> {
+pub fn mk_packet<T:Send>() -> Packet<T> {
     Packet {
         header: PacketHeader(),
         payload: None,
@@ -230,7 +230,7 @@ pub fn packet<T>() -> *mut Packet<T> {
     p
 }
 
-pub fn entangle_buffer<T:Owned,Tstart:Owned>(
+pub fn entangle_buffer<T:Send,Tstart:Send>(
     mut buffer: ~Buffer<T>,
     init: &fn(*libc::c_void, x: &mut T) -> *mut Packet<Tstart>)
     -> (RecvPacketBuffered<Tstart, T>, SendPacketBuffered<Tstart, T>) {
@@ -396,7 +396,7 @@ pub fn send<T,Tbuffer>(mut p: SendPacketBuffered<T,Tbuffer>,
 Fails if the sender closes the connection.
 
 */
-pub fn recv<T:Owned,Tbuffer:Owned>(
+pub fn recv<T:Send,Tbuffer:Send>(
     p: RecvPacketBuffered<T, Tbuffer>) -> T {
     try_recv(p).expect("connection closed")
 }
@@ -407,7 +407,7 @@ Returns `None` if the sender has closed the connection without sending
 a message, or `Some(T)` if a message was received.
 
 */
-pub fn try_recv<T:Owned,Tbuffer:Owned>(mut p: RecvPacketBuffered<T, Tbuffer>)
+pub fn try_recv<T:Send,Tbuffer:Send>(mut p: RecvPacketBuffered<T, Tbuffer>)
                                        -> Option<T> {
     let p_ = p.unwrap();
     let p = unsafe { &mut *p_ };
@@ -427,7 +427,7 @@ pub fn try_recv<T:Owned,Tbuffer:Owned>(mut p: RecvPacketBuffered<T, Tbuffer>)
     }
 }
 
-fn try_recv_<T:Owned>(p: &mut Packet<T>) -> Option<T> {
+fn try_recv_<T:Send>(p: &mut Packet<T>) -> Option<T> {
     // optimistic path
     match p.header.state {
       Full => {
@@ -511,7 +511,7 @@ fn try_recv_<T:Owned>(p: &mut Packet<T>) -> Option<T> {
 }
 
 /// Returns true if messages are available.
-pub fn peek<T:Owned,Tb:Owned>(p: &mut RecvPacketBuffered<T, Tb>) -> bool {
+pub fn peek<T:Send,Tb:Send>(p: &mut RecvPacketBuffered<T, Tb>) -> bool {
     unsafe {
         match (*p.header()).state {
             Empty | Terminated => false,
@@ -521,7 +521,7 @@ pub fn peek<T:Owned,Tb:Owned>(p: &mut RecvPacketBuffered<T, Tb>) -> bool {
     }
 }
 
-fn sender_terminate<T:Owned>(p: *mut Packet<T>) {
+fn sender_terminate<T:Send>(p: *mut Packet<T>) {
     let p = unsafe {
         &mut *p
     };
@@ -553,7 +553,7 @@ fn sender_terminate<T:Owned>(p: *mut Packet<T>) {
     }
 }
 
-fn receiver_terminate<T:Owned>(p: *mut Packet<T>) {
+fn receiver_terminate<T:Send>(p: *mut Packet<T>) {
     let p = unsafe {
         &mut *p
     };
@@ -671,7 +671,7 @@ pub struct SendPacketBuffered<T, Tbuffer> {
 }
 
 #[unsafe_destructor]
-impl<T:Owned,Tbuffer:Owned> Drop for SendPacketBuffered<T,Tbuffer> {
+impl<T:Send,Tbuffer:Send> Drop for SendPacketBuffered<T,Tbuffer> {
     fn drop(&self) {
         unsafe {
             let this: &mut SendPacketBuffered<T,Tbuffer> = transmute(self);
@@ -729,7 +729,7 @@ pub struct RecvPacketBuffered<T, Tbuffer> {
 }
 
 #[unsafe_destructor]
-impl<T:Owned,Tbuffer:Owned> Drop for RecvPacketBuffered<T,Tbuffer> {
+impl<T:Send,Tbuffer:Send> Drop for RecvPacketBuffered<T,Tbuffer> {
     fn drop(&self) {
         unsafe {
             let this: &mut RecvPacketBuffered<T,Tbuffer> = transmute(self);
@@ -741,7 +741,7 @@ impl<T:Owned,Tbuffer:Owned> Drop for RecvPacketBuffered<T,Tbuffer> {
     }
 }
 
-impl<T:Owned,Tbuffer:Owned> RecvPacketBuffered<T, Tbuffer> {
+impl<T:Send,Tbuffer:Send> RecvPacketBuffered<T, Tbuffer> {
     pub fn unwrap(&mut self) -> *mut Packet<T> {
         replace(&mut self.p, None).unwrap()
     }
@@ -751,7 +751,7 @@ impl<T:Owned,Tbuffer:Owned> RecvPacketBuffered<T, Tbuffer> {
     }
 }
 
-impl<T:Owned,Tbuffer:Owned> Selectable for RecvPacketBuffered<T, Tbuffer> {
+impl<T:Send,Tbuffer:Send> Selectable for RecvPacketBuffered<T, Tbuffer> {
     fn header(&mut self) -> *mut PacketHeader {
         match self.p {
             Some(packet) => unsafe {
@@ -807,7 +807,7 @@ Sometimes messages will be available on both endpoints at once. In
 this case, `select2` may return either `left` or `right`.
 
 */
-pub fn select2<A:Owned,Ab:Owned,B:Owned,Bb:Owned>(
+pub fn select2<A:Send,Ab:Send,B:Send,Bb:Send>(
     mut a: RecvPacketBuffered<A, Ab>,
     mut b: RecvPacketBuffered<B, Bb>)
     -> Either<(Option<A>, RecvPacketBuffered<B, Bb>),
@@ -847,7 +847,7 @@ pub fn select2i<A:Selectable,B:Selectable>(a: &mut A, b: &mut B)
 
 /// Waits on a set of endpoints. Returns a message, its index, and a
 /// list of the remaining endpoints.
-pub fn select<T:Owned,Tb:Owned>(mut endpoints: ~[RecvPacketBuffered<T, Tb>])
+pub fn select<T:Send,Tb:Send>(mut endpoints: ~[RecvPacketBuffered<T, Tb>])
                                 -> (uint,
                                     Option<T>,
                                     ~[RecvPacketBuffered<T, Tb>]) {
diff --git a/src/libstd/prelude.rs b/src/libstd/prelude.rs
index 6d7cb2a28a8..13d19b276f5 100644
--- a/src/libstd/prelude.rs
+++ b/src/libstd/prelude.rs
@@ -29,7 +29,8 @@ Rust's prelude has three main parts:
 
 // Reexported core operators
 pub use either::{Either, Left, Right};
-pub use kinds::{Const, Copy, Owned, Sized};
+pub use kinds::{Copy, Sized};
+pub use kinds::{Freeze, Send};
 pub use ops::{Add, Sub, Mul, Div, Rem, Neg, Not};
 pub use ops::{BitAnd, BitOr, BitXor};
 pub use ops::{Drop};
diff --git a/src/libstd/rand.rs b/src/libstd/rand.rs
index ea4a9059e72..5baff8aee68 100644
--- a/src/libstd/rand.rs
+++ b/src/libstd/rand.rs
@@ -42,6 +42,7 @@ fn main () {
 
 use cast;
 use cmp;
+use container::Container;
 use int;
 use iterator::IteratorUtil;
 use local_data;
@@ -720,7 +721,8 @@ impl IsaacRng {
     fn isaac(&mut self) {
         self.c += 1;
         // abbreviations
-        let mut (a, b) = (self.a, self.b + self.c);
+        let mut a = self.a;
+        let mut b = self.b + self.c;
 
         static midpoint: uint = RAND_SIZE as uint / 2;
 
diff --git a/src/libstd/rand/distributions.rs b/src/libstd/rand/distributions.rs
index 6f4f1a34977..e8dad2fc5e8 100644
--- a/src/libstd/rand/distributions.rs
+++ b/src/libstd/rand/distributions.rs
@@ -89,7 +89,8 @@ impl Rand for StandardNormal {
             // do-while, so the condition should be true on the first
             // run, they get overwritten anyway (0 < 1, so these are
             // good).
-            let mut (x, y) = (1.0, 0.0);
+            let mut x = 1.0;
+            let mut y = 0.0;
 
             // XXX infinities?
             while -2.0*y < x * x {
diff --git a/src/libstd/rt/comm.rs b/src/libstd/rt/comm.rs
index 75b1d8f3810..72907f40a07 100644
--- a/src/libstd/rt/comm.rs
+++ b/src/libstd/rt/comm.rs
@@ -19,7 +19,7 @@ use option::*;
 use cast;
 use util;
 use ops::Drop;
-use kinds::Owned;
+use kinds::Send;
 use rt::sched::{Scheduler, Coroutine};
 use rt::local::Local;
 use unstable::intrinsics::{atomic_xchg, atomic_load};
@@ -68,7 +68,7 @@ pub struct PortOneHack<T> {
     suppress_finalize: bool
 }
 
-pub fn oneshot<T: Owned>() -> (PortOne<T>, ChanOne<T>) {
+pub fn oneshot<T: Send>() -> (PortOne<T>, ChanOne<T>) {
     let packet: ~Packet<T> = ~Packet {
         state: STATE_BOTH,
         payload: None
@@ -307,20 +307,20 @@ pub struct Port<T> {
     next: Cell<PortOne<StreamPayload<T>>>
 }
 
-pub fn stream<T: Owned>() -> (Port<T>, Chan<T>) {
+pub fn stream<T: Send>() -> (Port<T>, Chan<T>) {
     let (pone, cone) = oneshot();
     let port = Port { next: Cell::new(pone) };
     let chan = Chan { next: Cell::new(cone) };
     return (port, chan);
 }
 
-impl<T: Owned> GenericChan<T> for Chan<T> {
+impl<T: Send> GenericChan<T> for Chan<T> {
     fn send(&self, val: T) {
         self.try_send(val);
     }
 }
 
-impl<T: Owned> GenericSmartChan<T> for Chan<T> {
+impl<T: Send> GenericSmartChan<T> for Chan<T> {
     fn try_send(&self, val: T) -> bool {
         let (next_pone, next_cone) = oneshot();
         let cone = self.next.take();
diff --git a/src/libstd/rt/io/extensions.rs b/src/libstd/rt/io/extensions.rs
index 1f82a9cd963..c6654e9dabe 100644
--- a/src/libstd/rt/io/extensions.rs
+++ b/src/libstd/rt/io/extensions.rs
@@ -343,7 +343,9 @@ impl<T: Reader> ReaderByteConversions for T {
     fn read_le_uint_n(&mut self, nbytes: uint) -> u64 {
         assert!(nbytes > 0 && nbytes <= 8);
 
-        let mut (val, pos, i) = (0u64, 0, nbytes);
+        let mut val = 0u64;
+        let mut pos = 0;
+        let mut i = nbytes;
         while i > 0 {
             val += (self.read_u8() as u64) << pos;
             pos += 8;
@@ -359,7 +361,8 @@ impl<T: Reader> ReaderByteConversions for T {
     fn read_be_uint_n(&mut self, nbytes: uint) -> u64 {
         assert!(nbytes > 0 && nbytes <= 8);
 
-        let mut (val, i) = (0u64, nbytes);
+        let mut val = 0u64;
+        let mut i = nbytes;
         while i > 0 {
             i -= 1;
             val += (self.read_u8() as u64) << i * 8;
diff --git a/src/libstd/rt/message_queue.rs b/src/libstd/rt/message_queue.rs
index 5b60543344d..d561e81d032 100644
--- a/src/libstd/rt/message_queue.rs
+++ b/src/libstd/rt/message_queue.rs
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 use container::Container;
-use kinds::Owned;
+use kinds::Send;
 use vec::OwnedVector;
 use cell::Cell;
 use option::*;
@@ -21,7 +21,7 @@ pub struct MessageQueue<T> {
     priv queue: ~Exclusive<~[T]>
 }
 
-impl<T: Owned> MessageQueue<T> {
+impl<T: Send> MessageQueue<T> {
     pub fn new() -> MessageQueue<T> {
         MessageQueue {
             queue: ~exclusive(~[])
diff --git a/src/libstd/rt/work_queue.rs b/src/libstd/rt/work_queue.rs
index cfffc55a58c..00d27744268 100644
--- a/src/libstd/rt/work_queue.rs
+++ b/src/libstd/rt/work_queue.rs
@@ -13,7 +13,7 @@ use option::*;
 use vec::OwnedVector;
 use unstable::sync::{Exclusive, exclusive};
 use cell::Cell;
-use kinds::Owned;
+use kinds::Send;
 use clone::Clone;
 
 pub struct WorkQueue<T> {
@@ -21,7 +21,7 @@ pub struct WorkQueue<T> {
     priv queue: ~Exclusive<~[T]>
 }
 
-impl<T: Owned> WorkQueue<T> {
+impl<T: Send> WorkQueue<T> {
     pub fn new() -> WorkQueue<T> {
         WorkQueue {
             queue: ~exclusive(~[])
diff --git a/src/libstd/str.rs b/src/libstd/str.rs
index f8c8ffdbe35..2144afc0fbd 100644
--- a/src/libstd/str.rs
+++ b/src/libstd/str.rs
@@ -357,7 +357,8 @@ impl<'self> Iterator<(uint, uint)> for StrMatchesIndexIterator<'self> {
     fn next(&mut self) -> Option<(uint, uint)> {
         // See Issue #1932 for why this is a naive search
         let (h_len, n_len) = (self.haystack.len(), self.needle.len());
-        let mut (match_start, match_i) = (0, 0);
+        let mut match_start = 0;
+        let mut match_i = 0;
 
         while self.position < h_len {
             if self.haystack[self.position] == self.needle[match_i] {
@@ -473,6 +474,31 @@ pub fn each_split_within<'a>(ss: &'a str,
     return cont;
 }
 
+/**
+ * Replace all occurrences of one string with another
+ *
+ * # Arguments
+ *
+ * * s - The string containing substrings to replace
+ * * from - The string to replace
+ * * to - The replacement string
+ *
+ * # Return value
+ *
+ * The original string with all occurances of `from` replaced with `to`
+ */
+pub fn replace(s: &str, from: &str, to: &str) -> ~str {
+    let mut result = ~"";
+    let mut last_end = 0;
+    for s.matches_index_iter(from).advance |(start, end)| {
+        result.push_str(unsafe{raw::slice_bytes(s, last_end, start)});
+        result.push_str(to);
+        last_end = end;
+    }
+    result.push_str(unsafe{raw::slice_bytes(s, last_end, s.len())});
+    result
+}
+
 /*
 Section: Comparing strings
 */
@@ -631,6 +657,48 @@ pub fn with_capacity(capacity: uint) -> ~str {
     buf
 }
 
+/**
+ * As char_len but for a slice of a string
+ *
+ * # Arguments
+ *
+ * * s - A valid string
+ * * start - The position inside `s` where to start counting in bytes
+ * * end - The position where to stop counting
+ *
+ * # Return value
+ *
+ * The number of Unicode characters in `s` between the given indices.
+ */
+pub fn count_chars(s: &str, start: uint, end: uint) -> uint {
+    assert!(s.is_char_boundary(start));
+    assert!(s.is_char_boundary(end));
+    let mut i = start;
+    let mut len = 0u;
+    while i < end {
+        let next = s.char_range_at(i).next;
+        len += 1u;
+        i = next;
+    }
+    return len;
+}
+
+/// Counts the number of bytes taken by the first `n` chars in `s`
+/// starting from `start`.
+pub fn count_bytes<'b>(s: &'b str, start: uint, n: uint) -> uint {
+    assert!(s.is_char_boundary(start));
+    let mut end = start;
+    let mut cnt = n;
+    let l = s.len();
+    while cnt > 0u {
+        assert!(end < l);
+        let next = s.char_range_at(end).next;
+        cnt -= 1u;
+        end = next;
+    }
+    end - start
+}
+
 /// Given a first byte, determine how many bytes are in this UTF-8 character
 pub fn utf8_char_width(b: u8) -> uint {
     let byte: uint = b as uint;
@@ -737,7 +805,8 @@ pub mod raw {
 
     /// Create a Rust string from a null-terminated *u8 buffer
     pub unsafe fn from_buf(buf: *u8) -> ~str {
-        let mut (curr, i) = (buf, 0u);
+        let mut curr = buf;
+        let mut i = 0u;
         while *curr != 0u8 {
             i += 1u;
             curr = ptr::offset(buf, i);
@@ -790,7 +859,8 @@ pub mod raw {
     /// invalidated later.
     pub unsafe fn c_str_to_static_slice(s: *libc::c_char) -> &'static str {
         let s = s as *u8;
-        let mut (curr, len) = (s, 0u);
+        let mut curr = s;
+        let mut len = 0u;
         while *curr != 0u8 {
             len += 1u;
             curr = ptr::offset(s, len);
@@ -1070,6 +1140,17 @@ impl<'self> Str for @str {
     }
 }
 
+impl<'self> Container for &'self str {
+    #[inline]
+    fn len(&self) -> uint {
+        do as_buf(*self) |_p, n| { n - 1u }
+    }
+    #[inline]
+    fn is_empty(&self) -> bool {
+        self.len() == 0
+    }
+}
+
 #[allow(missing_doc)]
 pub trait StrSlice<'self> {
     fn contains<'a>(&self, needle: &'a str) -> bool;
@@ -1088,10 +1169,8 @@ pub trait StrSlice<'self> {
     fn any_line_iter(&self) -> AnyLineIterator<'self>;
     fn word_iter(&self) -> WordIterator<'self>;
     fn ends_with(&self, needle: &str) -> bool;
-    fn is_empty(&self) -> bool;
     fn is_whitespace(&self) -> bool;
     fn is_alphanumeric(&self) -> bool;
-    fn len(&self) -> uint;
     fn char_len(&self) -> uint;
 
     fn slice(&self, begin: uint, end: uint) -> &'self str;
@@ -1292,9 +1371,6 @@ impl<'self> StrSlice<'self> for &'self str {
         self.split_iter(char::is_whitespace).filter(|s| !s.is_empty())
     }
 
-    /// Returns true if the string has length 0
-    #[inline]
-    fn is_empty(&self) -> bool { self.len() == 0 }
     /**
      * Returns true if the string contains only whitespace
      *
@@ -1309,11 +1385,6 @@ impl<'self> StrSlice<'self> for &'self str {
      */
     #[inline]
     fn is_alphanumeric(&self) -> bool { self.iter().all(char::is_alphanumeric) }
-    /// Returns the size in bytes not counting the null terminator
-    #[inline]
-    fn len(&self) -> uint {
-        do as_buf(*self) |_p, n| { n - 1u }
-    }
     /// Returns the number of characters that a string holds
     #[inline]
     fn char_len(&self) -> uint { self.iter().len_() }
@@ -1357,7 +1428,8 @@ impl<'self> StrSlice<'self> for &'self str {
     fn slice_chars(&self, begin: uint, end: uint) -> &'self str {
         assert!(begin <= end);
         // not sure how to use the iterators for this nicely.
-        let mut (position, count) = (0, 0);
+        let mut position = 0;
+        let mut count = 0;
         let l = self.len();
         while count < begin && position < l {
             position = self.char_range_at(position).next;
@@ -1505,7 +1577,8 @@ impl<'self> StrSlice<'self> for &'self str {
      * The original string with all occurances of `from` replaced with `to`
      */
     pub fn replace(&self, from: &str, to: &str) -> ~str {
-        let mut (result, last_end) = (~"", 0);
+        let mut result = ~"";
+        let mut last_end = 0;
         for self.matches_index_iter(from).advance |(start, end)| {
             result.push_str(unsafe{raw::slice_bytes(*self, last_end, start)});
             result.push_str(to);
diff --git a/src/libstd/task/mod.rs b/src/libstd/task/mod.rs
index b558b9d53a3..a8e8cfd163a 100644
--- a/src/libstd/task/mod.rs
+++ b/src/libstd/task/mod.rs
@@ -353,7 +353,7 @@ impl TaskBuilder {
     }
 
     /// Runs a task, while transfering ownership of one argument to the child.
-    pub fn spawn_with<A:Owned>(&mut self, arg: A, f: ~fn(v: A)) {
+    pub fn spawn_with<A:Send>(&mut self, arg: A, f: ~fn(v: A)) {
         let arg = Cell::new(arg);
         do self.spawn {
             f(arg.take());
@@ -373,7 +373,7 @@ impl TaskBuilder {
      * # Failure
      * Fails if a future_result was already set for this task.
      */
-    pub fn try<T:Owned>(&mut self, f: ~fn() -> T) -> Result<T,()> {
+    pub fn try<T:Send>(&mut self, f: ~fn() -> T) -> Result<T,()> {
         let (po, ch) = stream::<T>();
         let mut result = None;
 
@@ -445,7 +445,7 @@ pub fn spawn_supervised(f: ~fn()) {
     task.spawn(f)
 }
 
-pub fn spawn_with<A:Owned>(arg: A, f: ~fn(v: A)) {
+pub fn spawn_with<A:Send>(arg: A, f: ~fn(v: A)) {
     /*!
      * Runs a task, while transfering ownership of one argument to the
      * child.
@@ -478,7 +478,7 @@ pub fn spawn_sched(mode: SchedMode, f: ~fn()) {
     task.spawn(f)
 }
 
-pub fn try<T:Owned>(f: ~fn() -> T) -> Result<T,()> {
+pub fn try<T:Send>(f: ~fn() -> T) -> Result<T,()> {
     /*!
      * Execute a function in another task and return either the return value
      * of the function or result::err.
diff --git a/src/libstd/task/spawn.rs b/src/libstd/task/spawn.rs
index 95fc53c1b55..8f06fede057 100644
--- a/src/libstd/task/spawn.rs
+++ b/src/libstd/task/spawn.rs
@@ -636,7 +636,8 @@ fn spawn_raw_oldsched(mut opts: TaskOpts, f: ~fn()) {
         let child_data = Cell::new((notify_chan, child_arc, ancestors));
         let result: ~fn() = || {
             // Agh. Get move-mode items into the closure. FIXME (#2829)
-            let mut (notify_chan, child_arc, ancestors) = child_data.take();
+            let (notify_chan, child_arc, ancestors) = child_data.take();
+            let mut ancestors = ancestors;
             // Child task runs this code.
 
             // Even if the below code fails to kick the child off, we must
diff --git a/src/libstd/to_str.rs b/src/libstd/to_str.rs
index ea0e212b14f..77701acd33e 100644
--- a/src/libstd/to_str.rs
+++ b/src/libstd/to_str.rs
@@ -53,7 +53,8 @@ impl<A:ToStr> ToStr for (A,) {
 impl<A:ToStr+Hash+Eq, B:ToStr+Hash+Eq> ToStr for HashMap<A, B> {
     #[inline]
     fn to_str(&self) -> ~str {
-        let mut (acc, first) = (~"{", true);
+        let mut acc = ~"{";
+        let mut first = true;
         for self.iter().advance |(key, value)| {
             if first {
                 first = false;
@@ -73,7 +74,8 @@ impl<A:ToStr+Hash+Eq, B:ToStr+Hash+Eq> ToStr for HashMap<A, B> {
 impl<A:ToStr+Hash+Eq> ToStr for HashSet<A> {
     #[inline]
     fn to_str(&self) -> ~str {
-        let mut (acc, first) = (~"{", true);
+        let mut acc = ~"{";
+        let mut first = true;
         for self.iter().advance |element| {
             if first {
                 first = false;
@@ -121,7 +123,8 @@ impl<A:ToStr,B:ToStr,C:ToStr> ToStr for (A, B, C) {
 impl<'self,A:ToStr> ToStr for &'self [A] {
     #[inline]
     fn to_str(&self) -> ~str {
-        let mut (acc, first) = (~"[", true);
+        let mut acc = ~"[";
+        let mut first = true;
         for self.iter().advance |elt| {
             if first {
                 first = false;
@@ -139,7 +142,8 @@ impl<'self,A:ToStr> ToStr for &'self [A] {
 impl<A:ToStr> ToStr for ~[A] {
     #[inline]
     fn to_str(&self) -> ~str {
-        let mut (acc, first) = (~"[", true);
+        let mut acc = ~"[";
+        let mut first = true;
         for self.iter().advance |elt| {
             if first {
                 first = false;
@@ -157,7 +161,8 @@ impl<A:ToStr> ToStr for ~[A] {
 impl<A:ToStr> ToStr for @[A] {
     #[inline]
     fn to_str(&self) -> ~str {
-        let mut (acc, first) = (~"[", true);
+        let mut acc = ~"[";
+        let mut first = true;
         for self.iter().advance |elt| {
             if first {
                 first = false;
diff --git a/src/libstd/unstable/extfmt.rs b/src/libstd/unstable/extfmt.rs
index 87bd25bdad3..624062a7ec4 100644
--- a/src/libstd/unstable/extfmt.rs
+++ b/src/libstd/unstable/extfmt.rs
@@ -94,6 +94,7 @@ use iterator::IteratorUtil;
 #[doc(hidden)]
 pub mod ct {
     use char;
+    use container::Container;
     use prelude::*;
     use str;
 
diff --git a/src/libstd/unstable/global.rs b/src/libstd/unstable/global.rs
index 4fde8f704b9..285a8114cc2 100644
--- a/src/libstd/unstable/global.rs
+++ b/src/libstd/unstable/global.rs
@@ -27,7 +27,7 @@ avoid hitting the mutex.
 
 use cast::{transmute};
 use clone::Clone;
-use kinds::Owned;
+use kinds::Send;
 use libc::{c_void};
 use option::{Option, Some, None};
 use ops::Drop;
@@ -43,7 +43,7 @@ use sys::Closure;
 
 pub type GlobalDataKey<'self,T> = &'self fn(v: T);
 
-pub unsafe fn global_data_clone_create<T:Owned + Clone>(
+pub unsafe fn global_data_clone_create<T:Send + Clone>(
     key: GlobalDataKey<T>, create: &fn() -> ~T) -> T {
     /*!
      * Clone a global value or, if it has not been created,
@@ -59,7 +59,7 @@ pub unsafe fn global_data_clone_create<T:Owned + Clone>(
     global_data_clone_create_(key_ptr(key), create)
 }
 
-unsafe fn global_data_clone_create_<T:Owned + Clone>(
+unsafe fn global_data_clone_create_<T:Send + Clone>(
     key: uint, create: &fn() -> ~T) -> T {
 
     let mut clone_value: Option<T> = None;
@@ -79,13 +79,13 @@ unsafe fn global_data_clone_create_<T:Owned + Clone>(
     return clone_value.unwrap();
 }
 
-unsafe fn global_data_modify<T:Owned>(
+unsafe fn global_data_modify<T:Send>(
     key: GlobalDataKey<T>, op: &fn(Option<~T>) -> Option<~T>) {
 
     global_data_modify_(key_ptr(key), op)
 }
 
-unsafe fn global_data_modify_<T:Owned>(
+unsafe fn global_data_modify_<T:Send>(
     key: uint, op: &fn(Option<~T>) -> Option<~T>) {
 
     let mut old_dtor = None;
@@ -124,7 +124,7 @@ unsafe fn global_data_modify_<T:Owned>(
     }
 }
 
-pub unsafe fn global_data_clone<T:Owned + Clone>(
+pub unsafe fn global_data_clone<T:Send + Clone>(
     key: GlobalDataKey<T>) -> Option<T> {
     let mut maybe_clone: Option<T> = None;
     do global_data_modify(key) |current| {
@@ -220,7 +220,7 @@ fn get_global_state() -> Exclusive<GlobalState> {
     }
 }
 
-fn key_ptr<T:Owned>(key: GlobalDataKey<T>) -> uint {
+fn key_ptr<T:Send>(key: GlobalDataKey<T>) -> uint {
     unsafe {
         let closure: Closure = transmute(key);
         return transmute(closure.code);
diff --git a/src/libstd/unstable/sync.rs b/src/libstd/unstable/sync.rs
index 0f9298595ee..06c3ecb8147 100644
--- a/src/libstd/unstable/sync.rs
+++ b/src/libstd/unstable/sync.rs
@@ -17,7 +17,7 @@ use unstable::finally::Finally;
 use unstable::intrinsics;
 use ops::Drop;
 use clone::Clone;
-use kinds::Owned;
+use kinds::Send;
 
 /// An atomically reference counted pointer.
 ///
@@ -31,7 +31,7 @@ struct AtomicRcBoxData<T> {
     data: Option<T>,
 }
 
-impl<T: Owned> UnsafeAtomicRcBox<T> {
+impl<T: Send> UnsafeAtomicRcBox<T> {
     pub fn new(data: T) -> UnsafeAtomicRcBox<T> {
         unsafe {
             let data = ~AtomicRcBoxData { count: 1, data: Some(data) };
@@ -61,7 +61,7 @@ impl<T: Owned> UnsafeAtomicRcBox<T> {
     }
 }
 
-impl<T: Owned> Clone for UnsafeAtomicRcBox<T> {
+impl<T: Send> Clone for UnsafeAtomicRcBox<T> {
     fn clone(&self) -> UnsafeAtomicRcBox<T> {
         unsafe {
             let mut data: ~AtomicRcBoxData<T> = cast::transmute(self.data);
@@ -144,7 +144,7 @@ pub struct Exclusive<T> {
     x: UnsafeAtomicRcBox<ExData<T>>
 }
 
-pub fn exclusive<T:Owned>(user_data: T) -> Exclusive<T> {
+pub fn exclusive<T:Send>(user_data: T) -> Exclusive<T> {
     let data = ExData {
         lock: LittleLock(),
         failed: false,
@@ -155,14 +155,14 @@ pub fn exclusive<T:Owned>(user_data: T) -> Exclusive<T> {
     }
 }
 
-impl<T:Owned> Clone for Exclusive<T> {
+impl<T:Send> Clone for Exclusive<T> {
     // Duplicate an exclusive ARC, as std::arc::clone.
     fn clone(&self) -> Exclusive<T> {
         Exclusive { x: self.x.clone() }
     }
 }
 
-impl<T:Owned> Exclusive<T> {
+impl<T:Send> Exclusive<T> {
     // Exactly like std::arc::mutex_arc,access(), but with the little_lock
     // instead of a proper mutex. Same reason for being unsafe.
     //
diff --git a/src/libstd/vec.rs b/src/libstd/vec.rs
index 8cbd9309cc6..aa4d632a482 100644
--- a/src/libstd/vec.rs
+++ b/src/libstd/vec.rs
@@ -348,7 +348,8 @@ pub fn consume_reverse<T>(mut v: ~[T], f: &fn(uint, v: T)) {
 pub fn dedup<T:Eq>(v: &mut ~[T]) {
     unsafe {
         if v.len() < 1 { return; }
-        let mut (last_written, next_to_read) = (0, 1);
+        let mut last_written = 0;
+        let mut next_to_read = 1;
         do as_const_buf(*v) |p, ln| {
             // We have a mutable reference to v, so we can make arbitrary
             // changes. (cf. push and pop)
@@ -798,7 +799,8 @@ pub fn bsearch_elem<T:TotalOrd>(v: &[T], x: &T) -> Option<uint> {
  * Convert a vector of pairs into a pair of vectors, by reference. As unzip().
  */
 pub fn unzip_slice<T:Copy,U:Copy>(v: &[(T, U)]) -> (~[T], ~[U]) {
-    let mut (ts, us) = (~[], ~[]);
+    let mut ts = ~[];
+    let mut us = ~[];
     for v.iter().advance |p| {
         let (t, u) = copy *p;
         ts.push(t);
@@ -816,7 +818,8 @@ pub fn unzip_slice<T:Copy,U:Copy>(v: &[(T, U)]) -> (~[T], ~[U]) {
  * of the i-th tuple of the input vector.
  */
 pub fn unzip<T,U>(v: ~[(T, U)]) -> (~[T], ~[U]) {
-    let mut (ts, us) = (~[], ~[]);
+    let mut ts = ~[];
+    let mut us = ~[];
     do consume(v) |_i, p| {
         let (t, u) = p;
         ts.push(t);