about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJorge Aparicio <japaricious@gmail.com>2015-01-01 01:13:08 -0500
committerJorge Aparicio <japaricious@gmail.com>2015-01-03 23:01:33 -0500
commit5172b8046ac6e23c6f106df79dd8c887516896b6 (patch)
treea0fb81f7f922875312334637380a7d599bf99bb0
parentc6c786671d692d7b13c2e5c68a53001327b4b125 (diff)
downloadrust-5172b8046ac6e23c6f106df79dd8c887516896b6.tar.gz
rust-5172b8046ac6e23c6f106df79dd8c887516896b6.zip
remove `Any[Mut]RefExt` traits in favor of `impl Any`
-rw-r--r--src/liballoc/boxed.rs2
-rw-r--r--src/libcore/any.rs36
-rw-r--r--src/librustc_driver/lib.rs1
-rw-r--r--src/libstd/failure.rs2
-rw-r--r--src/libstd/thread.rs2
-rw-r--r--src/libtest/lib.rs2
-rw-r--r--src/test/compile-fail/kindck-inherited-copy-bound.rs1
-rw-r--r--src/test/run-pass/object-one-type-two-traits.rs1
8 files changed, 12 insertions, 35 deletions
diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs
index e836b08459b..ca010ac986a 100644
--- a/src/liballoc/boxed.rs
+++ b/src/liballoc/boxed.rs
@@ -12,7 +12,7 @@
 
 #![stable]
 
-use core::any::{Any, AnyRefExt};
+use core::any::Any;
 use core::clone::Clone;
 use core::cmp::{PartialEq, PartialOrd, Eq, Ord, Ordering};
 use core::default::Default;
diff --git a/src/libcore/any.rs b/src/libcore/any.rs
index 75feb4d8828..33cb335d756 100644
--- a/src/libcore/any.rs
+++ b/src/libcore/any.rs
@@ -35,7 +35,7 @@
 //!
 //! ```rust
 //! use std::fmt::Show;
-//! use std::any::{Any, AnyRefExt};
+//! use std::any::Any;
 //!
 //! // Logger function for any type that implements Show.
 //! fn log<T: Any+Show>(value: &T) {
@@ -102,24 +102,11 @@ impl<T: 'static> Any for T {
 // Implemented as three extension traits so that the methods can be generic.
 ///////////////////////////////////////////////////////////////////////////////
 
-/// Extension methods for a referenced `Any` trait object
-#[unstable = "this trait will not be necessary once DST lands, it will be a \
-              part of `impl Any`"]
-pub trait AnyRefExt<'a> {
+impl Any {
     /// Returns true if the boxed type is the same as `T`
     #[stable]
-    fn is<T: 'static>(self) -> bool;
-
-    /// Returns some reference to the boxed value if it is of type `T`, or
-    /// `None` if it isn't.
-    #[unstable = "naming conventions around acquiring references may change"]
-    fn downcast_ref<T: 'static>(self) -> Option<&'a T>;
-}
-
-#[stable]
-impl<'a> AnyRefExt<'a> for &'a Any {
     #[inline]
-    fn is<T: 'static>(self) -> bool {
+    pub fn is<T: 'static>(&self) -> bool {
         // Get TypeId of the type this function is instantiated with
         let t = TypeId::of::<T>();
 
@@ -130,8 +117,11 @@ impl<'a> AnyRefExt<'a> for &'a Any {
         t == boxed
     }
 
+    /// Returns some reference to the boxed value if it is of type `T`, or
+    /// `None` if it isn't.
+    #[unstable = "naming conventions around acquiring references may change"]
     #[inline]
-    fn downcast_ref<T: 'static>(self) -> Option<&'a T> {
+    pub fn downcast_ref<'a, T: 'static>(&'a self) -> Option<&'a T> {
         if self.is::<T>() {
             unsafe {
                 // Get the raw representation of the trait object
@@ -144,22 +134,12 @@ impl<'a> AnyRefExt<'a> for &'a Any {
             None
         }
     }
-}
 
-/// Extension methods for a mutable referenced `Any` trait object
-#[unstable = "this trait will not be necessary once DST lands, it will be a \
-              part of `impl Any`"]
-pub trait AnyMutRefExt<'a> {
     /// Returns some mutable reference to the boxed value if it is of type `T`, or
     /// `None` if it isn't.
     #[unstable = "naming conventions around acquiring references may change"]
-    fn downcast_mut<T: 'static>(self) -> Option<&'a mut T>;
-}
-
-#[stable]
-impl<'a> AnyMutRefExt<'a> for &'a mut Any {
     #[inline]
-    fn downcast_mut<T: 'static>(self) -> Option<&'a mut T> {
+    pub fn downcast_mut<'a, T: 'static>(&'a mut self) -> Option<&'a mut T> {
         if self.is::<T>() {
             unsafe {
                 // Get the raw representation of the trait object
diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs
index 9a993de098e..983188c7090 100644
--- a/src/librustc_driver/lib.rs
+++ b/src/librustc_driver/lib.rs
@@ -54,7 +54,6 @@ use rustc::lint;
 use rustc::metadata;
 use rustc::DIAGNOSTICS;
 
-use std::any::AnyRefExt;
 use std::cmp::Ordering::Equal;
 use std::io;
 use std::iter::repeat;
diff --git a/src/libstd/failure.rs b/src/libstd/failure.rs
index d3bcdbf1a53..e48137047b0 100644
--- a/src/libstd/failure.rs
+++ b/src/libstd/failure.rs
@@ -12,7 +12,7 @@
 
 use prelude::v1::*;
 
-use any::{Any, AnyRefExt};
+use any::Any;
 use cell::RefCell;
 use io::IoResult;
 use rt::{backtrace, unwind};
diff --git a/src/libstd/thread.rs b/src/libstd/thread.rs
index 3c87309dabc..371cf8b3b5a 100644
--- a/src/libstd/thread.rs
+++ b/src/libstd/thread.rs
@@ -442,7 +442,7 @@ impl<T: Send> Drop for JoinGuard<T> {
 mod test {
     use prelude::v1::*;
 
-    use any::{Any, AnyRefExt};
+    use any::Any;
     use sync::mpsc::{channel, Sender};
     use boxed::BoxAny;
     use result;
diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs
index b2d3611fc64..e8d6b6f1ff6 100644
--- a/src/libtest/lib.rs
+++ b/src/libtest/lib.rs
@@ -58,7 +58,7 @@ use serialize::{json, Decodable, Encodable};
 use term::Terminal;
 use term::color::{Color, RED, YELLOW, GREEN, CYAN};
 
-use std::any::{Any, AnyRefExt};
+use std::any::Any;
 use std::cmp;
 use std::collections::BTreeMap;
 use std::f64;
diff --git a/src/test/compile-fail/kindck-inherited-copy-bound.rs b/src/test/compile-fail/kindck-inherited-copy-bound.rs
index f5740992af4..d66fd0d77d6 100644
--- a/src/test/compile-fail/kindck-inherited-copy-bound.rs
+++ b/src/test/compile-fail/kindck-inherited-copy-bound.rs
@@ -11,7 +11,6 @@
 // Test that Copy bounds inherited by trait are checked.
 
 use std::any::Any;
-use std::any::AnyRefExt;
 
 trait Foo : Copy {
 }
diff --git a/src/test/run-pass/object-one-type-two-traits.rs b/src/test/run-pass/object-one-type-two-traits.rs
index f8bc0929bfa..4964b3f6728 100644
--- a/src/test/run-pass/object-one-type-two-traits.rs
+++ b/src/test/run-pass/object-one-type-two-traits.rs
@@ -12,7 +12,6 @@
 // traits.
 
 use std::any::Any;
-use std::any::AnyRefExt;
 
 trait Wrap {
     fn get(&self) -> int;