about summary refs log tree commit diff
diff options
context:
space:
mode:
authorCAD97 <cad97@cad97.com>2020-07-14 15:22:48 -0400
committerCAD97 <cad97@cad97.com>2020-09-12 10:38:33 -0500
commit9d9903c5a50bb1f5b5fc3045b86172279eff7d30 (patch)
tree63b30dcacb62a73c551c0e8d97623fb0eb9135a0
parent5e7406c9569dce75a042ce079918cf03cfca842a (diff)
downloadrust-9d9903c5a50bb1f5b5fc3045b86172279eff7d30.tar.gz
rust-9d9903c5a50bb1f5b5fc3045b86172279eff7d30.zip
Allow Weak::as_ptr and friends for unsized T
-rw-r--r--library/alloc/src/sync.rs18
1 files changed, 9 insertions, 9 deletions
diff --git a/library/alloc/src/sync.rs b/library/alloc/src/sync.rs
index 06dec6f01f8..f064881717d 100644
--- a/library/alloc/src/sync.rs
+++ b/library/alloc/src/sync.rs
@@ -1509,7 +1509,16 @@ impl<T> Weak<T> {
     pub fn new() -> Weak<T> {
         Weak { ptr: NonNull::new(usize::MAX as *mut ArcInner<T>).expect("MAX is not 0") }
     }
+}
 
+/// Helper type to allow accessing the reference counts without
+/// making any assertions about the data field.
+struct WeakInner<'a> {
+    weak: &'a atomic::AtomicUsize,
+    strong: &'a atomic::AtomicUsize,
+}
+
+impl<T: ?Sized> Weak<T> {
     /// Returns a raw pointer to the object `T` pointed to by this `Weak<T>`.
     ///
     /// The pointer is valid only if there are some strong references. The pointer may be dangling,
@@ -1642,16 +1651,7 @@ impl<T> Weak<T> {
         // SAFETY: we now have recovered the original Weak pointer, so can create the Weak.
         unsafe { Weak { ptr: NonNull::new_unchecked(ptr) } }
     }
-}
 
-/// Helper type to allow accessing the reference counts without
-/// making any assertions about the data field.
-struct WeakInner<'a> {
-    weak: &'a atomic::AtomicUsize,
-    strong: &'a atomic::AtomicUsize,
-}
-
-impl<T: ?Sized> Weak<T> {
     /// Attempts to upgrade the `Weak` pointer to an [`Arc`], delaying
     /// dropping of the inner value if successful.
     ///