diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index f2b83fdeefa3a..88c5c38172aca 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -634,7 +634,18 @@ impl Default for Rc { } #[stable(feature = "rust1", since = "1.0.0")] +#[cfg(stage0)] impl PartialEq for Rc { + #[inline(always)] + fn eq(&self, other: &Rc) -> bool { **self == **other } + + #[inline(always)] + fn ne(&self, other: &Rc) -> bool { **self != **other } +} + +#[stable(feature = "rust1", since = "1.0.0")] +#[cfg(not(stage0))] +impl PartialEq for Rc { /// Equality for two `Rc`s. /// /// Two `Rc`s are equal if their inner value are equal. @@ -669,10 +680,35 @@ impl PartialEq for Rc { } #[stable(feature = "rust1", since = "1.0.0")] +#[cfg(stage0)] impl Eq for Rc {} +#[stable(feature = "rust1", since = "1.0.0")] +#[cfg(not(stage0))] +impl Eq for Rc {} #[stable(feature = "rust1", since = "1.0.0")] +#[cfg(stage0)] impl PartialOrd for Rc { + #[inline(always)] + fn partial_cmp(&self, other: &Rc) -> Option { + (**self).partial_cmp(&**other) + } + + #[inline(always)] + fn lt(&self, other: &Rc) -> bool { **self < **other } + + #[inline(always)] + fn le(&self, other: &Rc) -> bool { **self <= **other } + + #[inline(always)] + fn gt(&self, other: &Rc) -> bool { **self > **other } + + #[inline(always)] + fn ge(&self, other: &Rc) -> bool { **self >= **other } +} +#[stable(feature = "rust1", since = "1.0.0")] +#[cfg(not(stage0))] +impl PartialOrd for Rc { /// Partial comparison for two `Rc`s. /// /// The two are compared by calling `partial_cmp()` on their inner values. @@ -757,7 +793,14 @@ impl PartialOrd for Rc { } #[stable(feature = "rust1", since = "1.0.0")] +#[cfg(stage0)] impl Ord for Rc { + #[inline] + fn cmp(&self, other: &Rc) -> Ordering { (**self).cmp(&**other) } +} +#[stable(feature = "rust1", since = "1.0.0")] +#[cfg(not(stage0))] +impl Ord for Rc { /// Comparison for two `Rc`s. /// /// The two are compared by calling `cmp()` on their inner values. @@ -1399,4 +1442,9 @@ mod tests { assert_eq!(format!("{:?}", foo), "75"); } + #[test] + fn test_unsized() { + let foo: Rc<[i32]> = Rc::new([1, 2, 3]); + assert_eq!(foo, foo.clone()); + } } diff --git a/src/libcollections/borrow.rs b/src/libcollections/borrow.rs index a86a4b4215f23..08bd88cd861b1 100644 --- a/src/libcollections/borrow.rs +++ b/src/libcollections/borrow.rs @@ -116,10 +116,16 @@ impl<'a, T: ?Sized> BorrowMut for &'a mut T { fn borrow_mut(&mut self) -> &mut T { &mut **self } } +#[cfg(stage0)] impl Borrow for rc::Rc { fn borrow(&self) -> &T { &**self } } +#[cfg(not(stage0))] +impl Borrow for rc::Rc { + fn borrow(&self) -> &T { &**self } +} + impl Borrow for arc::Arc { fn borrow(&self) -> &T { &**self } }