From 207c52d534f048a06ed4e654451502aa86575040 Mon Sep 17 00:00:00 2001 From: CAD97 Date: Sat, 4 Jul 2020 01:42:44 -0400 Subject: [PATCH] Relax bounds of rc::Weak::as_ptr and friends ....to allow use with unsized T. This is a follow-up to #73845, which did the impl work required to be able to relax these bounds. --- src/liballoc/rc.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index fccdfa0dca92a..c026746e33d7f 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -1675,7 +1675,14 @@ impl Weak { pub fn new() -> Weak { Weak { ptr: NonNull::new(usize::MAX as *mut RcBox).expect("MAX is not 0") } } +} +pub(crate) fn is_dangling(ptr: NonNull) -> bool { + let address = ptr.as_ptr() as *mut () as usize; + address == usize::MAX +} + +impl Weak { /// Returns a raw pointer to the object `T` pointed to by this `Weak`. /// /// The pointer is valid only if there are some strong references. The pointer may be dangling, @@ -1808,14 +1815,7 @@ impl Weak { } } } -} -pub(crate) fn is_dangling(ptr: NonNull) -> bool { - let address = ptr.as_ptr() as *mut () as usize; - address == usize::MAX -} - -impl Weak { /// Attempts to upgrade the `Weak` pointer to an [`Rc`], delaying /// dropping of the inner value if successful. ///