From 785067446a4abed3e64cb14ccdead2d7cd67487b Mon Sep 17 00:00:00 2001 From: Albert Larsan <74931857+albertlarsan68@users.noreply.github.com> Date: Tue, 27 Dec 2022 17:41:50 +0100 Subject: [PATCH] Allow Arc::from_raw to be used with a pointer from Arc::as_ptr See #106124 --- library/alloc/src/sync.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/library/alloc/src/sync.rs b/library/alloc/src/sync.rs index ddcd863aa3e33..de77fba655e3e 100644 --- a/library/alloc/src/sync.rs +++ b/library/alloc/src/sync.rs @@ -886,11 +886,11 @@ impl Arc { /// Constructs an `Arc` from a raw pointer. /// /// The raw pointer must have been previously returned by a call to - /// [`Arc::into_raw`][into_raw] where `U` must have the same size and - /// alignment as `T`. This is trivially true if `U` is `T`. - /// Note that if `U` is not `T` but has the same size and alignment, this is - /// basically like transmuting references of different types. See - /// [`mem::transmute`][transmute] for more information on what + /// [`Arc::into_raw`][into_raw] or [`Arc::::as_ptr`][as_ptr] where `U` + /// must have the same size and alignment as `T`. This is trivially true + /// if `U` is `T`. Note that if `U` is not `T` but has the same size and + /// alignment, this is basically like transmuting references of different + /// types. See [`mem::transmute`][transmute] for more information on what /// restrictions apply in this case. /// /// The user of `from_raw` has to make sure a specific value of `T` is only @@ -900,6 +900,7 @@ impl Arc { /// even if the returned `Arc` is never accessed. /// /// [into_raw]: Arc::into_raw + /// [as_ptr]: Arc::as_ptr /// [transmute]: core::mem::transmute /// /// # Examples