From 6bb35746b72f5168008a539d8f56e428ae4a06a8 Mon Sep 17 00:00:00 2001 From: Benjamin Woodruff Date: Mon, 29 Jul 2024 10:53:48 -0700 Subject: [PATCH] Document unchecked_sidecast_triomphe_arc --- crates/turbo-tasks/src/triomphe_utils.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/crates/turbo-tasks/src/triomphe_utils.rs b/crates/turbo-tasks/src/triomphe_utils.rs index b298e6922a3de9..f186e26c793d75 100644 --- a/crates/turbo-tasks/src/triomphe_utils.rs +++ b/crates/turbo-tasks/src/triomphe_utils.rs @@ -5,6 +5,8 @@ use unsize::Coercion; /// Attempt to downcast a [`triomphe::Arc`][`triomphe::Arc`] to a concrete type. /// +/// Checks that the downcast is safe using [`Any::is`]. +/// /// Ported from [`std::sync::Arc::downcast`] to [`triomphe::Arc`]. pub fn downcast_triomphe_arc( this: triomphe::Arc, @@ -16,6 +18,16 @@ pub fn downcast_triomphe_arc( } } +/// Transmutes the contents of `Arc` to `Arc`. Updates the `Arc`'s fat +/// pointer metadata. +/// +/// Unlike [`downcast_triomphe_arc`] this make no checks the transmute is safe. +/// +/// # Safety +/// +/// It must be [safe to transmute][transmutes] from `T` to `U`. +/// +/// [transmutes]: https://doc.rust-lang.org/nomicon/transmutes.html pub unsafe fn unchecked_sidecast_triomphe_arc(this: triomphe::Arc) -> triomphe::Arc where T: ?Sized,