From 5cfac942018b3f8e0b384c49d6564fcff25634e6 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Wed, 26 Nov 2014 23:50:12 -0500 Subject: [PATCH] Deprecate Equiv --- src/libcollections/str.rs | 1 + src/libcollections/string.rs | 3 ++- src/libcollections/vec.rs | 3 ++- src/libcore/cmp.rs | 2 +- src/libcore/ptr.rs | 4 ++++ src/libcore/slice.rs | 6 ++++-- src/libcore/str.rs | 2 ++ src/libgraphviz/maybe_owned_vec.rs | 1 + src/libstd/collections/hash/map.rs | 2 ++ src/libsyntax/parse/token.rs | 1 + 10 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/libcollections/str.rs b/src/libcollections/str.rs index c6fa1332186ec..ad0a5e7617646 100644 --- a/src/libcollections/str.rs +++ b/src/libcollections/str.rs @@ -563,6 +563,7 @@ impl<'a> Ord for MaybeOwned<'a> { } } +#[allow(deprecated)] #[deprecated = "use std::str::CowString"] impl<'a, S: Str> Equiv for MaybeOwned<'a> { #[inline] diff --git a/src/libcollections/string.rs b/src/libcollections/string.rs index 8917afa34b149..fbb0bb5c4ce86 100644 --- a/src/libcollections/string.rs +++ b/src/libcollections/string.rs @@ -822,7 +822,8 @@ impl hash::Hash for String { } } -#[experimental = "waiting on Equiv stabilization"] +#[allow(deprecated)] +#[deprecated = "Use overloaded `core::cmp::PartialEq`"] impl<'a, S: Str> Equiv for String { #[inline] fn equiv(&self, other: &S) -> bool { diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs index c40f0c19c09f8..2396cf8cec67c 100644 --- a/src/libcollections/vec.rs +++ b/src/libcollections/vec.rs @@ -609,7 +609,8 @@ impl PartialOrd for Vec { #[unstable = "waiting on Eq stability"] impl Eq for Vec {} -#[experimental] +#[allow(deprecated)] +#[deprecated = "Use overloaded `core::cmp::PartialEq`"] impl> Equiv for Vec { #[inline] fn equiv(&self, other: &V) -> bool { self.as_slice() == other.as_slice() } diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs index d5001a08b1dc5..df19256471ede 100644 --- a/src/libcore/cmp.rs +++ b/src/libcore/cmp.rs @@ -240,7 +240,7 @@ pub trait PartialOrd for Sized?: PartialEq { /// of different types. The most common use case for this relation is /// container types; e.g. it is often desirable to be able to use `&str` /// values to look up entries in a container with `String` keys. -#[experimental = "Better solutions may be discovered."] +#[deprecated = "Use overloaded core::cmp::PartialEq"] pub trait Equiv for Sized? { /// Implement this function to decide equivalent values. fn equiv(&self, other: &T) -> bool; diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index 5e2f5529e8d49..416bc4588b43c 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -321,12 +321,16 @@ impl PartialEq for *mut T { impl Eq for *mut T {} // Equivalence for pointers +#[allow(deprecated)] +#[deprecated = "Use overloaded `core::cmp::PartialEq`"] impl Equiv<*mut T> for *const T { fn equiv(&self, other: &*mut T) -> bool { self.to_uint() == other.to_uint() } } +#[allow(deprecated)] +#[deprecated = "Use overloaded `core::cmp::PartialEq`"] impl Equiv<*const T> for *mut T { fn equiv(&self, other: &*const T) -> bool { self.to_uint() == other.to_uint() diff --git a/src/libcore/slice.rs b/src/libcore/slice.rs index 12cd20584a180..85bd6adf8b8a6 100644 --- a/src/libcore/slice.rs +++ b/src/libcore/slice.rs @@ -1816,13 +1816,15 @@ impl PartialEq<[B]> for [A] where A: PartialEq { #[unstable = "waiting for DST"] impl Eq for [T] {} -#[unstable = "waiting for DST"] +#[allow(deprecated)] +#[deprecated = "Use overloaded `core::cmp::PartialEq`"] impl> Equiv for [T] { #[inline] fn equiv(&self, other: &V) -> bool { self.as_slice() == other.as_slice() } } -#[unstable = "waiting for DST"] +#[allow(deprecated)] +#[deprecated = "Use overloaded `core::cmp::PartialEq`"] impl<'a,T:PartialEq, Sized? V: AsSlice> Equiv for &'a mut [T] { #[inline] fn equiv(&self, other: &V) -> bool { self.as_slice() == other.as_slice() } diff --git a/src/libcore/str.rs b/src/libcore/str.rs index b9586399aec5d..4be628f0ac3b3 100644 --- a/src/libcore/str.rs +++ b/src/libcore/str.rs @@ -1248,6 +1248,8 @@ pub mod traits { } } + #[allow(deprecated)] + #[deprecated = "Use overloaded `core::cmp::PartialEq`"] impl Equiv for str { #[inline] fn equiv(&self, other: &S) -> bool { eq_slice(self, other.as_slice()) } diff --git a/src/libgraphviz/maybe_owned_vec.rs b/src/libgraphviz/maybe_owned_vec.rs index 6482a514115aa..05932db6632ff 100644 --- a/src/libgraphviz/maybe_owned_vec.rs +++ b/src/libgraphviz/maybe_owned_vec.rs @@ -96,6 +96,7 @@ impl<'a, T: Ord> Ord for MaybeOwnedVector<'a, T> { } } +#[allow(deprecated)] impl<'a, T: PartialEq, Sized? V: AsSlice> Equiv for MaybeOwnedVector<'a, T> { fn equiv(&self, other: &V) -> bool { self.as_slice() == other.as_slice() diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index 50a00714ea06c..bd07dbf5c9184 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -425,12 +425,14 @@ impl, V, S, H: Hasher> HashMap { table::make_hash(&self.hasher, x) } + #[allow(deprecated)] fn search_equiv<'a, Sized? Q: Hash + Equiv>(&'a self, q: &Q) -> Option> { let hash = self.make_hash(q); search_hashed(&self.table, &hash, |k| q.equiv(k)).into_option() } + #[allow(deprecated)] fn search_equiv_mut<'a, Sized? Q: Hash + Equiv>(&'a mut self, q: &Q) -> Option> { let hash = self.make_hash(q); diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index 1376f59d79fcf..52b54bc7f2d6d 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -623,6 +623,7 @@ impl fmt::Show for InternedString { } } +#[allow(deprecated)] impl<'a> Equiv<&'a str> for InternedString { fn equiv(&self, other: & &'a str) -> bool { (*other) == self.string.as_slice()