]> git.lizzy.rs Git - rust.git/commitdiff
rollup merge of #22210: aturon/stab-final-borrow
authorAlex Crichton <alex@alexcrichton.com>
Wed, 18 Feb 2015 23:34:32 +0000 (15:34 -0800)
committerAlex Crichton <alex@alexcrichton.com>
Wed, 18 Feb 2015 23:34:48 +0000 (15:34 -0800)
Conflicts:
src/libcollections/btree/map.rs
src/libcollections/str.rs
src/libcollections/vec.rs
src/libcore/borrow.rs
src/libcore/hash/mod.rs
src/libstd/collections/hash/map.rs
src/libstd/collections/hash/set.rs

18 files changed:
1  2 
src/liballoc/arc.rs
src/liballoc/rc.rs
src/libcollections/borrow.rs
src/libcollections/btree/map.rs
src/libcollections/btree/set.rs
src/libcollections/lib.rs
src/libcollections/str.rs
src/libcollections/string.rs
src/libcollections/vec.rs
src/libcore/hash/mod.rs
src/librustc/middle/ty.rs
src/libstd/collections/hash/map.rs
src/libstd/collections/hash/set.rs
src/libstd/ffi/os_str.rs
src/libstd/path.rs
src/libsyntax/util/interner.rs
src/test/run-make/save-analysis/foo.rs
src/test/run-pass/const-polymorphic-paths.rs

Simple merge
Simple merge
index 0000000000000000000000000000000000000000,62e6f347df3987e5a072395e04599b9b03e28bce..901d7a73b51ed27bbc051ccc09a261fc3b5e3353
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,306 +1,316 @@@
+ // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+ // file at the top-level directory of this distribution and at
+ // http://rust-lang.org/COPYRIGHT.
+ //
+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+ // option. This file may not be copied, modified, or distributed
+ // except according to those terms.
+ //! A module for working with borrowed data.
+ #![stable(feature = "rust1", since = "1.0.0")]
+ use core::clone::Clone;
+ use core::cmp::{Eq, Ord, Ordering, PartialEq, PartialOrd};
+ use core::hash::{Hash, Hasher};
+ use core::marker::Sized;
+ use core::ops::Deref;
+ use core::option::Option;
+ use fmt;
+ use alloc::{rc, arc};
+ use self::Cow::*;
+ /// A trait for borrowing data.
+ ///
+ /// In general, there may be several ways to "borrow" a piece of data.  The
+ /// typical ways of borrowing a type `T` are `&T` (a shared borrow) and `&mut T`
+ /// (a mutable borrow). But types like `Vec<T>` provide additional kinds of
+ /// borrows: the borrowed slices `&[T]` and `&mut [T]`.
+ ///
+ /// When writing generic code, it is often desirable to abstract over all ways
+ /// of borrowing data from a given type. That is the role of the `Borrow`
+ /// trait: if `T: Borrow<U>`, then `&U` can be borrowed from `&T`.  A given
+ /// type can be borrowed as multiple different types. In particular, `Vec<T>:
+ /// Borrow<Vec<T>>` and `Vec<T>: Borrow<[T]>`.
+ #[stable(feature = "rust1", since = "1.0.0")]
+ pub trait Borrow<Borrowed: ?Sized> {
+     /// Immutably borrow from an owned value.
+     #[stable(feature = "rust1", since = "1.0.0")]
+     fn borrow(&self) -> &Borrowed;
+ }
+ /// A trait for mutably borrowing data.
+ ///
+ /// Similar to `Borrow`, but for mutable borrows.
+ #[stable(feature = "rust1", since = "1.0.0")]
+ pub trait BorrowMut<Borrowed: ?Sized> : Borrow<Borrowed> {
+     /// Mutably borrow from an owned value.
+     #[stable(feature = "rust1", since = "1.0.0")]
+     fn borrow_mut(&mut self) -> &mut Borrowed;
+ }
+ #[stable(feature = "rust1", since = "1.0.0")]
+ impl<T: ?Sized> Borrow<T> for T {
+     fn borrow(&self) -> &T { self }
+ }
+ #[stable(feature = "rust1", since = "1.0.0")]
+ impl<T: ?Sized> BorrowMut<T> for T {
+     fn borrow_mut(&mut self) -> &mut T { self }
+ }
+ #[stable(feature = "rust1", since = "1.0.0")]
+ impl<'a, T: ?Sized> Borrow<T> for &'a T {
+     fn borrow(&self) -> &T { &**self }
+ }
+ #[stable(feature = "rust1", since = "1.0.0")]
+ impl<'a, T: ?Sized> Borrow<T> for &'a mut T {
+     fn borrow(&self) -> &T { &**self }
+ }
+ #[stable(feature = "rust1", since = "1.0.0")]
+ impl<'a, T: ?Sized> BorrowMut<T> for &'a mut T {
+     fn borrow_mut(&mut self) -> &mut T { &mut **self }
+ }
+ impl<T> Borrow<T> for rc::Rc<T> {
+     fn borrow(&self) -> &T { &**self }
+ }
+ impl<T> Borrow<T> for arc::Arc<T> {
+     fn borrow(&self) -> &T { &**self }
+ }
+ #[stable(feature = "rust1", since = "1.0.0")]
+ impl<'a, B: ?Sized> Borrow<B> for Cow<'a, B> where B: ToOwned, <B as ToOwned>::Owned: 'a {
+     fn borrow(&self) -> &B {
+         &**self
+     }
+ }
+ /// A generalization of Clone to borrowed data.
+ ///
+ /// Some types make it possible to go from borrowed to owned, usually by
+ /// implementing the `Clone` trait. But `Clone` works only for going from `&T`
+ /// to `T`. The `ToOwned` trait generalizes `Clone` to construct owned data
+ /// from any borrow of a given type.
+ #[stable(feature = "rust1", since = "1.0.0")]
+ pub trait ToOwned {
+     #[stable(feature = "rust1", since = "1.0.0")]
+     type Owned: Borrow<Self>;
+     /// Create owned data from borrowed data, usually by copying.
+     #[stable(feature = "rust1", since = "1.0.0")]
+     fn to_owned(&self) -> Self::Owned;
+ }
+ #[stable(feature = "rust1", since = "1.0.0")]
+ impl<T> ToOwned for T where T: Clone {
+     type Owned = T;
+     fn to_owned(&self) -> T { self.clone() }
+ }
+ /// A clone-on-write smart pointer.
+ ///
+ /// The type `Cow` is a smart pointer providing clone-on-write functionality: it
+ /// can enclose and provide immutable access to borrowed data, and clone the
+ /// data lazily when mutation or ownership is required. The type is designed to
+ /// work with general borrowed data via the `Borrow` trait.
+ ///
+ /// `Cow` implements both `Deref`, which means that you can call
+ /// non-mutating methods directly on the data it encloses. If mutation
+ /// is desired, `to_mut` will obtain a mutable references to an owned
+ /// value, cloning if necessary.
+ ///
+ /// # Example
+ ///
+ /// ```rust
+ /// use std::borrow::Cow;
+ ///
+ /// fn abs_all(input: &mut Cow<[int]>) {
+ ///     for i in 0..input.len() {
+ ///         let v = input[i];
+ ///         if v < 0 {
+ ///             // clones into a vector the first time (if not already owned)
+ ///             input.to_mut()[i] = -v;
+ ///         }
+ ///     }
+ /// }
+ /// ```
+ #[stable(feature = "rust1", since = "1.0.0")]
+ pub enum Cow<'a, B: ?Sized + 'a> where B: ToOwned {
+     /// Borrowed data.
+     #[stable(feature = "rust1", since = "1.0.0")]
+     Borrowed(&'a B),
+     /// Owned data.
+     #[stable(feature = "rust1", since = "1.0.0")]
+     Owned(<B as ToOwned>::Owned)
+ }
+ #[stable(feature = "rust1", since = "1.0.0")]
+ impl<'a, B: ?Sized> Clone for Cow<'a, B> where B: ToOwned {
+     fn clone(&self) -> Cow<'a, B> {
+         match *self {
+             Borrowed(b) => Borrowed(b),
+             Owned(ref o) => {
+                 let b: &B = o.borrow();
+                 Owned(b.to_owned())
+             },
+         }
+     }
+ }
+ impl<'a, B: ?Sized> Cow<'a, B> where B: ToOwned {
+     /// Acquire a mutable reference to the owned form of the data.
+     ///
+     /// Copies the data if it is not already owned.
+     #[stable(feature = "rust1", since = "1.0.0")]
+     pub fn to_mut(&mut self) -> &mut <B as ToOwned>::Owned {
+         match *self {
+             Borrowed(borrowed) => {
+                 *self = Owned(borrowed.to_owned());
+                 self.to_mut()
+             }
+             Owned(ref mut owned) => owned
+         }
+     }
+     /// Extract the owned data.
+     ///
+     /// Copies the data if it is not already owned.
+     #[stable(feature = "rust1", since = "1.0.0")]
+     pub fn into_owned(self) -> <B as ToOwned>::Owned {
+         match self {
+             Borrowed(borrowed) => borrowed.to_owned(),
+             Owned(owned) => owned
+         }
+     }
+     /// Returns true if this `Cow` wraps a borrowed value
+     #[deprecated(since = "1.0.0", reason = "match on the enum instead")]
+     #[unstable(feature = "std_misc")]
+     pub fn is_borrowed(&self) -> bool {
+         match *self {
+             Borrowed(_) => true,
+             _ => false,
+         }
+     }
+     /// Returns true if this `Cow` wraps an owned value
+     #[deprecated(since = "1.0.0", reason = "match on the enum instead")]
+     #[unstable(feature = "std_misc")]
+     pub fn is_owned(&self) -> bool {
+         match *self {
+             Owned(_) => true,
+             _ => false,
+         }
+     }
+ }
+ #[stable(feature = "rust1", since = "1.0.0")]
+ impl<'a, B: ?Sized> Deref for Cow<'a, B> where B: ToOwned {
+     type Target = B;
+     fn deref(&self) -> &B {
+         match *self {
+             Borrowed(borrowed) => borrowed,
+             Owned(ref owned) => owned.borrow()
+         }
+     }
+ }
+ #[stable(feature = "rust1", since = "1.0.0")]
+ impl<'a, B: ?Sized> Eq for Cow<'a, B> where B: Eq + ToOwned {}
+ #[stable(feature = "rust1", since = "1.0.0")]
+ impl<'a, B: ?Sized> Ord for Cow<'a, B> where B: Ord + ToOwned {
+     #[inline]
+     fn cmp(&self, other: &Cow<'a, B>) -> Ordering {
+         Ord::cmp(&**self, &**other)
+     }
+ }
+ #[stable(feature = "rust1", since = "1.0.0")]
+ impl<'a, 'b, B: ?Sized, C: ?Sized> PartialEq<Cow<'b, C>> for Cow<'a, B> where
+     B: PartialEq<C> + ToOwned, C: ToOwned,
+ {
+     #[inline]
+     fn eq(&self, other: &Cow<'b, C>) -> bool {
+         PartialEq::eq(&**self, &**other)
+     }
+ }
+ #[stable(feature = "rust1", since = "1.0.0")]
+ impl<'a, B: ?Sized> PartialOrd for Cow<'a, B> where B: PartialOrd + ToOwned,
+ {
+     #[inline]
+     fn partial_cmp(&self, other: &Cow<'a, B>) -> Option<Ordering> {
+         PartialOrd::partial_cmp(&**self, &**other)
+     }
+ }
+ #[stable(feature = "rust1", since = "1.0.0")]
+ impl<'a, B: ?Sized> fmt::Debug for Cow<'a, B> where
+     B: fmt::Debug + ToOwned,
+     <B as ToOwned>::Owned: fmt::Debug,
+ {
+     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+         match *self {
+             Borrowed(ref b) => fmt::Debug::fmt(b, f),
+             Owned(ref o) => fmt::Debug::fmt(o, f),
+         }
+     }
+ }
+ #[stable(feature = "rust1", since = "1.0.0")]
+ impl<'a, B: ?Sized> fmt::Display for Cow<'a, B> where
+     B: fmt::Display + ToOwned,
+     <B as ToOwned>::Owned: fmt::Display,
+ {
+     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+         match *self {
+             Borrowed(ref b) => fmt::Display::fmt(b, f),
+             Owned(ref o) => fmt::Display::fmt(o, f),
+         }
+     }
+ }
+ #[stable(feature = "rust1", since = "1.0.0")]
++#[cfg(stage0)]
+ impl<'a, B: ?Sized, S: Hasher> Hash<S> for Cow<'a, B> where B: Hash<S> + ToOwned
+ {
+     #[inline]
+     fn hash(&self, state: &mut S) {
+         Hash::hash(&**self, state)
+     }
+ }
++#[stable(feature = "rust1", since = "1.0.0")]
++#[cfg(not(stage0))]
++impl<'a, B: ?Sized> Hash for Cow<'a, B> where B: Hash + ToOwned
++{
++    #[inline]
++    fn hash<H: Hasher>(&self, state: &mut H) {
++        Hash::hash(&**self, state)
++    }
++}
+ /// Trait for moving into a `Cow`
+ #[stable(feature = "rust1", since = "1.0.0")]
+ pub trait IntoCow<'a, B: ?Sized> where B: ToOwned {
+     /// Moves `self` into `Cow`
+     #[stable(feature = "rust1", since = "1.0.0")]
+     fn into_cow(self) -> Cow<'a, B>;
+ }
+ #[stable(feature = "rust1", since = "1.0.0")]
+ impl<'a,  B: ?Sized> IntoCow<'a, B> for Cow<'a, B> where B: ToOwned {
+     fn into_cow(self) -> Cow<'a, B> {
+         self
+     }
+ }
index a985a24f7aee714beb1662f741982c8273ac76ce,6b980d473b590f35c1b9b3cbf7b3732005c1efae..c6cd68957288351fe722042af5d156f8f9374367
@@@ -29,7 -28,8 +28,8 @@@ use core::ops::{Index, IndexMut}
  use core::{iter, fmt, mem};
  use Bound::{self, Included, Excluded, Unbounded};
  
 -use ring_buf::RingBuf;
+ use borrow::Borrow;
 +use vec_deque::VecDeque;
  
  use self::Continuation::{Continue, Finished};
  use self::StackOp::*;
Simple merge
index 335b15c434034b7541f68385e857e5b238a6a202,f5fbd10ceebfe47641791099e3c9942d90860b90..8fce626755ee35a309b15c257ef6a04dae214605
@@@ -96,14 -81,17 +96,21 @@@ pub mod string
  pub mod vec;
  pub mod vec_map;
  
+ #[cfg(stage0)]
+ #[path = "borrow_stage0.rs"]
+ pub mod borrow;
+ #[cfg(not(stage0))]
+ pub mod borrow;
  #[unstable(feature = "collections",
             reason = "RFC 509")]
 -pub mod bitv {
 -    pub use bit::{Bitv, Iter};
 +pub mod bit_vec {
 +    pub use bit::{BitVec, Iter};
 +
 +    #[deprecated(since = "1.0.0", reason = "renamed to BitVec")]
 +    #[unstable(feature = "collections")]
 +    pub use bit::BitVec as Bitv;
  }
  
  #[unstable(feature = "collections",
index 94d81c74cd36ac409dd8bb3e3727f95c21ded225,95fd233dc97eccc14673db47257737f20b466710..cdc503500d2a69bd2feee6b0e856896d5ce98484
@@@ -68,7 -67,8 +67,8 @@@ use core::slice::AsSlice
  use core::str as core_str;
  use unicode::str::{UnicodeStr, Utf16Encoder};
  
 -use ring_buf::RingBuf;
 +use vec_deque::VecDeque;
+ use borrow::{Borrow, ToOwned};
  use slice::SliceExt;
  use string::String;
  use unicode;
Simple merge
index c77a6b9e8e50203cdccb0bc1906039690f05e230,df6aa560257b6d757823a9c710cc67d231a695a0..e303d7760034f5354351630977b02b7d9d4b3c5c
@@@ -1659,14 -1643,14 +1659,14 @@@ impl<T: fmt::Debug> fmt::Debug for Vec<
  // Clone-on-write
  ////////////////////////////////////////////////////////////////////////////////
  
- #[unstable(feature = "collections",
-            reason = "unclear how valuable this alias is")]
  /// A clone-on-write vector
- pub type CowVec<'a, T> = Cow<'a, Vec<T>, [T]>;
+ #[deprecated(since = "1.0.0", reason = "use Cow<'a, [T]> instead")]
+ #[unstable(feature = "collections")]
+ pub type CowVec<'a, T> = Cow<'a, [T]>;
  
  #[unstable(feature = "collections")]
- impl<'a, T> FromIterator<T> for CowVec<'a, T> where T: Clone {
-     fn from_iter<I: IntoIterator<Item=T>>(it: I) -> CowVec<'a, T> {
+ impl<'a, T> FromIterator<T> for Cow<'a, [T]> where T: Clone {
 -    fn from_iter<I: Iterator<Item=T>>(it: I) -> CowVec<'a, T> {
++    fn from_iter<I: IntoIterator<Item=T>>(it: I) -> Cow<'a, [T]> {
          Cow::Owned(FromIterator::from_iter(it))
      }
  }
index b9a5122dd9c00ecaad777d3f8c5e3268c72e6941,28e14836a04924269fa357e45faad5c7ddbd8420..3d0c9761dda77b122f94d3efa5a20413c1ea9336
  //! assert_eq!(hash::<_, SipHasher>(&person1), hash::<_, SipHasher>(&person2));
  //! ```
  
 -#![unstable(feature = "hash",
 -            reason = "module was recently redesigned")]
 +#![stable(feature = "rust1", since = "1.0.0")]
  
+ use prelude::*;
  use default::Default;
- use marker::Sized;
  use mem;
 -use num::Int;
  
  pub use self::sip::SipHasher;
  
@@@ -374,143 -234,11 +375,28 @@@ mod impls 
      }
  }
  
 -impl<S: Writer + Hasher, T> Hash<S> for *mut T {
 -    #[inline]
 -    fn hash(&self, state: &mut S) {
 -        // NB: raw-pointer Hash does _not_ dereference
 -        // to the target; it just gives you the pointer-bytes.
 -        (*self as uint).hash(state);
 +#[cfg(not(stage0))]
 +mod impls {
 +    use prelude::*;
 +
 +    use borrow::{Cow, ToOwned};
 +    use slice;
 +    use super::*;
 +
 +    macro_rules! impl_write {
 +        ($(($ty:ident, $meth:ident),)*) => {$(
 +            #[stable(feature = "rust1", since = "1.0.0")]
 +            impl Hash for $ty {
 +                fn hash<H: Hasher>(&self, state: &mut H) {
 +                    state.$meth(*self)
 +                }
 +
 +                fn hash_slice<H: Hasher>(data: &[$ty], state: &mut H) {
 +                    let newlen = data.len() * ::$ty::BYTES;
 +                    let ptr = data.as_ptr() as *const u8;
 +                    state.write(unsafe { slice::from_raw_parts(ptr, newlen) })
 +                }
 +            }
 +        )*}
      }
-     impl_write! {
-         (u8, write_u8),
-         (u16, write_u16),
-         (u32, write_u32),
-         (u64, write_u64),
-         (usize, write_usize),
-         (i8, write_i8),
-         (i16, write_i16),
-         (i32, write_i32),
-         (i64, write_i64),
-         (isize, write_isize),
-     }
-     #[stable(feature = "rust1", since = "1.0.0")]
-     impl Hash for bool {
-         fn hash<H: Hasher>(&self, state: &mut H) {
-             state.write_u8(*self as u8)
-         }
-     }
-     #[stable(feature = "rust1", since = "1.0.0")]
-     impl Hash for char {
-         fn hash<H: Hasher>(&self, state: &mut H) {
-             state.write_u32(*self as u32)
-         }
-     }
-     #[stable(feature = "rust1", since = "1.0.0")]
-     impl Hash for str {
-         fn hash<H: Hasher>(&self, state: &mut H) {
-             state.write(self.as_bytes());
-             state.write_u8(0xff)
-         }
-     }
-     macro_rules! impl_hash_tuple {
-         () => (
-             #[stable(feature = "rust1", since = "1.0.0")]
-             impl Hash for () {
-                 fn hash<H: Hasher>(&self, _state: &mut H) {}
-             }
-         );
-         ( $($name:ident)+) => (
-             #[stable(feature = "rust1", since = "1.0.0")]
-             impl<$($name: Hash),*> Hash for ($($name,)*) {
-                 #[allow(non_snake_case)]
-                 fn hash<S: Hasher>(&self, state: &mut S) {
-                     let ($(ref $name,)*) = *self;
-                     $($name.hash(state);)*
-                 }
-             }
-         );
-     }
-     impl_hash_tuple! {}
-     impl_hash_tuple! { A }
-     impl_hash_tuple! { A B }
-     impl_hash_tuple! { A B C }
-     impl_hash_tuple! { A B C D }
-     impl_hash_tuple! { A B C D E }
-     impl_hash_tuple! { A B C D E F }
-     impl_hash_tuple! { A B C D E F G }
-     impl_hash_tuple! { A B C D E F G H }
-     impl_hash_tuple! { A B C D E F G H I }
-     impl_hash_tuple! { A B C D E F G H I J }
-     impl_hash_tuple! { A B C D E F G H I J K }
-     impl_hash_tuple! { A B C D E F G H I J K L }
-     #[stable(feature = "rust1", since = "1.0.0")]
-     impl<T: Hash> Hash for [T] {
-         fn hash<H: Hasher>(&self, state: &mut H) {
-             self.len().hash(state);
-             Hash::hash_slice(self, state)
-         }
-     }
-     #[stable(feature = "rust1", since = "1.0.0")]
-     impl<'a, T: ?Sized + Hash> Hash for &'a T {
-         fn hash<H: Hasher>(&self, state: &mut H) {
-             (**self).hash(state);
-         }
-     }
-     #[stable(feature = "rust1", since = "1.0.0")]
-     impl<'a, T: ?Sized + Hash> Hash for &'a mut T {
-         fn hash<H: Hasher>(&self, state: &mut H) {
-             (**self).hash(state);
-         }
-     }
-     #[stable(feature = "rust1", since = "1.0.0")]
-     impl<T> Hash for *const T {
-         fn hash<H: Hasher>(&self, state: &mut H) {
-             state.write_usize(*self as usize)
-         }
-     }
-     #[stable(feature = "rust1", since = "1.0.0")]
-     impl<T> Hash for *mut T {
-         fn hash<H: Hasher>(&self, state: &mut H) {
-             state.write_usize(*self as usize)
-         }
-     }
-     #[stable(feature = "rust1", since = "1.0.0")]
-     impl<'a, T, B: ?Sized> Hash for Cow<'a, T, B>
-         where B: Hash + ToOwned<T>
-     {
-         fn hash<H: Hasher>(&self, state: &mut H) {
-             Hash::hash(&**self, state)
-         }
-     }
  }
index f70c5554c6ee9010b2e09e1f606cc9bc76e7232b,60ae646e2c799cd98a0698b39762d92ea14e774b..f6d523cda8500ff54915fa4bf5f0cbbfa2aee91c
@@@ -994,16 -985,10 +994,16 @@@ impl<'tcx, S: Writer + Hasher> Hash<S> 
          self.ty.sty.hash(s)
      }
  }
 +#[cfg(not(stage0))]
 +impl<'tcx> Hash for InternedTy<'tcx> {
 +    fn hash<H: Hasher>(&self, s: &mut H) {
 +        self.ty.sty.hash(s)
 +    }
 +}
  
- impl<'tcx> BorrowFrom<InternedTy<'tcx>> for sty<'tcx> {
-     fn borrow_from<'a>(ty: &'a InternedTy<'tcx>) -> &'a sty<'tcx> {
-         &ty.ty.sty
+ impl<'tcx> Borrow<sty<'tcx>> for InternedTy<'tcx> {
+     fn borrow<'a>(&'a self) -> &'a sty<'tcx> {
+         &self.ty.sty
      }
  }
  
index 04f8bb0b0db649bed4dd7df08560336a4e546633,9d3ffb114c121fbb12cc6aac9f7eabc0265217af..ade4f1f0533ee73abdb388bab488ac4a9a2d0452
@@@ -451,18 -453,18 +451,18 @@@ impl<K, V, S> HashMap<K, V, S
      /// If you already have the hash for the key lying around, use
      /// search_hashed.
      fn search<'a, Q: ?Sized>(&'a self, q: &Q) -> Option<FullBucketImm<'a, K, V>>
-         where Q: BorrowFrom<K> + Eq + Hash
 -        where K: Borrow<Q>, Q: Eq + Hash<H>
++        where K: Borrow<Q>, Q: Eq + Hash
      {
          let hash = self.make_hash(q);
-         search_hashed(&self.table, hash, |k| q.eq(BorrowFrom::borrow_from(k)))
+         search_hashed(&self.table, hash, |k| q.eq(k.borrow()))
              .into_option()
      }
  
      fn search_mut<'a, Q: ?Sized>(&'a mut self, q: &Q) -> Option<FullBucketMut<'a, K, V>>
-         where Q: BorrowFrom<K> + Eq + Hash
 -        where K: Borrow<Q>, Q: Eq + Hash<H>
++        where K: Borrow<Q>, Q: Eq + Hash
      {
          let hash = self.make_hash(q);
-         search_hashed(&mut self.table, hash, |k| q.eq(BorrowFrom::borrow_from(k)))
+         search_hashed(&mut self.table, hash, |k| q.eq(k.borrow()))
              .into_option()
      }
  
@@@ -1033,7 -1037,7 +1033,7 @@@ impl<K, V, S> HashMap<K, V, S
      /// ```
      #[stable(feature = "rust1", since = "1.0.0")]
      pub fn get<Q: ?Sized>(&self, k: &Q) -> Option<&V>
-         where Q: Hash + Eq + BorrowFrom<K>
 -        where K: Borrow<Q>, Q: Hash<H> + Eq
++        where K: Borrow<Q>, Q: Hash + Eq
      {
          self.search(k).map(|bucket| bucket.into_refs().1)
      }
      /// ```
      #[stable(feature = "rust1", since = "1.0.0")]
      pub fn contains_key<Q: ?Sized>(&self, k: &Q) -> bool
-         where Q: Hash + Eq + BorrowFrom<K>
 -        where K: Borrow<Q>, Q: Hash<H> + Eq
++        where K: Borrow<Q>, Q: Hash + Eq
      {
          self.search(k).is_some()
      }
      /// ```
      #[stable(feature = "rust1", since = "1.0.0")]
      pub fn get_mut<Q: ?Sized>(&mut self, k: &Q) -> Option<&mut V>
-         where Q: Hash + Eq + BorrowFrom<K>
 -        where K: Borrow<Q>, Q: Hash<H> + Eq
++        where K: Borrow<Q>, Q: Hash + Eq
      {
          self.search_mut(k).map(|bucket| bucket.into_mut_refs().1)
      }
      /// ```
      #[stable(feature = "rust1", since = "1.0.0")]
      pub fn remove<Q: ?Sized>(&mut self, k: &Q) -> Option<V>
-         where Q: Hash + Eq + BorrowFrom<K>
 -        where K: Borrow<Q>, Q: Hash<H> + Eq
++        where K: Borrow<Q>, Q: Hash + Eq
      {
          if self.table.size() == 0 {
              return None
@@@ -1235,10 -1246,11 +1235,10 @@@ impl<K, V, S> Default for HashMap<K, V
  }
  
  #[stable(feature = "rust1", since = "1.0.0")]
 -impl<K, Q: ?Sized, V, S, H> Index<Q> for HashMap<K, V, S>
 -    where K: Eq + Hash<H> + Borrow<Q>,
 -          Q: Eq + Hash<H>,
 -          S: HashState<Hasher=H>,
 -          H: hash::Hasher<Output=u64>
 +impl<K, Q: ?Sized, V, S> Index<Q> for HashMap<K, V, S>
-     where K: Eq + Hash,
-           Q: Eq + Hash + BorrowFrom<K>,
++    where K: Eq + Hash + Borrow<Q>,
++          Q: Eq + Hash,
 +          S: HashState,
  {
      type Output = V;
  
  }
  
  #[stable(feature = "rust1", since = "1.0.0")]
 -impl<K, V, S, H, Q: ?Sized> IndexMut<Q> for HashMap<K, V, S>
 -    where K: Eq + Hash<H> + Borrow<Q>,
 -          Q: Eq + Hash<H>,
 -          S: HashState<Hasher=H>,
 -          H: hash::Hasher<Output=u64>
 +impl<K, V, S, Q: ?Sized> IndexMut<Q> for HashMap<K, V, S>
-     where K: Eq + Hash,
-           Q: Eq + Hash + BorrowFrom<K>,
++    where K: Eq + Hash + Borrow<Q>,
++          Q: Eq + Hash,
 +          S: HashState,
  {
      #[inline]
      fn index_mut<'a>(&'a mut self, index: &Q) -> &'a mut V {
index 751dc86f533e845e5471a942513da2d9d8f0813c,7befaa8c368c6ee8fe70ef2c21a471d0d41f4192..e0631a64d44b127048402f0667195daed7e4ffc6
@@@ -460,7 -462,7 +460,7 @@@ impl<T, S> HashSet<T, S
      /// ```
      #[stable(feature = "rust1", since = "1.0.0")]
      pub fn contains<Q: ?Sized>(&self, value: &Q) -> bool
-         where Q: BorrowFrom<T> + Hash + Eq
 -        where T: Borrow<Q>, Q: Hash<H> + Eq
++        where T: Borrow<Q>, Q: Hash + Eq
      {
          self.map.contains_key(value)
      }
      /// ```
      #[stable(feature = "rust1", since = "1.0.0")]
      pub fn remove<Q: ?Sized>(&mut self, value: &Q) -> bool
-         where Q: BorrowFrom<T> + Hash + Eq
 -        where T: Borrow<Q>, Q: Hash<H> + Eq
++        where T: Borrow<Q>, Q: Hash + Eq
      {
          self.map.remove(value).is_some()
      }
Simple merge
index 2ad07462f20f71033973708f600787e713e2e746,1f7129bf361e2d99250a8d3057b42929cae9ccb5..3d95d0f19d1d9d1314fdd37adb0b3670b5044d63
  use core::prelude::*;
  
  use ascii::*;
- use borrow::BorrowFrom;
+ use borrow::{Borrow, ToOwned, Cow};
  use cmp;
 -use iter;
 +use iter::{self, IntoIterator};
  use mem;
  use ops::{self, Deref};
- use string::CowString;
  use vec::Vec;
  use fmt;
  
index 58b5c44c960753288e97bab7f5106345aa485f97,5236122f585e11b5f11a118cf56a3b4af58ddefb..2e8f43be120adbec1745049830746607584768cd
@@@ -275,9 -210,8 +275,9 @@@ impl StrInterner 
          self.vect.borrow().len()
      }
  
 +    #[cfg(stage0)]
      pub fn find<Q: ?Sized>(&self, val: &Q) -> Option<Name>
-     where Q: BorrowFrom<RcStr> + Eq + Hash<Hasher> {
+     where RcStr: Borrow<Q>, Q: Eq + Hash<Hasher> {
          match (*self.map.borrow()).get(val) {
              Some(v) => Some(*v),
              None => None,
index db70a2452326673144a0d9c1e9b8504870096e75,b393afeef39adf905cb7e8bee48ef6261bd7c2ad..fbbecfbf2a6267f6dc29d33c2670ef6710c49f50
@@@ -32,9 -32,9 +32,9 @@@ use std::num::{from_int,from_i8,from_i3
  use std::mem::size_of;
  
  static uni: &'static str = "Les Miséééééééérables";
 -static yy: usize = 25us;
 +static yy: usize = 25;
  
- static bob: Option<std::vec::CowVec<'static, isize>> = None;
+ static bob: Option<std::borrow::Cow<'static, [isize]>> = None;
  
  // buglink test - see issue #1337.