about summary refs log tree commit diff
path: root/src/liballoc
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2015-07-02 09:19:27 +0000
committerbors <bors@rust-lang.org>2015-07-02 09:19:27 +0000
commitc4b4f0759297927248f2db0bed0a417e7f08ed1d (patch)
treeda4fdfcc209f46e499089873edd3f944e5e1c7be /src/liballoc
parentf635b2f0adb2c06162efeea41345a9c7b6ab62c4 (diff)
parent3278e793b2d0332c6659b732178892aab11654ee (diff)
downloadrust-c4b4f0759297927248f2db0bed0a417e7f08ed1d.tar.gz
rust-c4b4f0759297927248f2db0bed0a417e7f08ed1d.zip
Auto merge of #26727 - remram44:coerceunsized-weak, r=eddyb
This is a simple addition, shouldn't change behavior.

Fixes #26704

I don't know if the coercion for `Rc` is tested, if it is this probably needs the same test with `Weak`.
Diffstat (limited to 'src/liballoc')
-rw-r--r--src/liballoc/arc.rs2
-rw-r--r--src/liballoc/rc.rs2
2 files changed, 4 insertions, 0 deletions
diff --git a/src/liballoc/arc.rs b/src/liballoc/arc.rs
index dd9c1d1fd18..c84649f92e7 100644
--- a/src/liballoc/arc.rs
+++ b/src/liballoc/arc.rs
@@ -145,6 +145,8 @@ pub struct Weak<T: ?Sized> {
 unsafe impl<T: ?Sized + Sync + Send> Send for Weak<T> { }
 unsafe impl<T: ?Sized + Sync + Send> Sync for Weak<T> { }
 
+impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<Weak<U>> for Weak<T> {}
+
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<T: ?Sized + fmt::Debug> fmt::Debug for Weak<T> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs
index 3dfafd0a378..d461eeea0b7 100644
--- a/src/liballoc/rc.rs
+++ b/src/liballoc/rc.rs
@@ -734,6 +734,8 @@ pub struct Weak<T: ?Sized> {
 impl<T: ?Sized> !marker::Send for Weak<T> {}
 impl<T: ?Sized> !marker::Sync for Weak<T> {}
 
+impl<T: ?Sized+Unsize<U>, U: ?Sized> CoerceUnsized<Weak<U>> for Weak<T> {}
+
 #[unstable(feature = "rc_weak",
            reason = "Weak pointers may not belong in this module.")]
 impl<T: ?Sized> Weak<T> {