From 5dbb2eba5298e49470689dd4cc9d9dd5ab383b82 Mon Sep 17 00:00:00 2001 From: Konrad Borowski Date: Sat, 23 Jul 2022 07:18:26 +0200 Subject: [PATCH] Inline WakerRef functions (#2626) Those functions are trivial and non-generic. It's necessary to use `#[inline]` to enable cross-crate inlining for non-generic functions when LTO is disabled. --- futures-task/src/waker_ref.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/futures-task/src/waker_ref.rs b/futures-task/src/waker_ref.rs index 7fb552fcfd..aac4109577 100644 --- a/futures-task/src/waker_ref.rs +++ b/futures-task/src/waker_ref.rs @@ -18,6 +18,7 @@ pub struct WakerRef<'a> { impl<'a> WakerRef<'a> { /// Create a new [`WakerRef`] from a [`Waker`] reference. + #[inline] pub fn new(waker: &'a Waker) -> Self { // copy the underlying (raw) waker without calling a clone, // as we won't call Waker::drop either. @@ -31,6 +32,7 @@ impl<'a> WakerRef<'a> { /// an unsafe way (that will be valid only for a lifetime to be determined /// by the caller), and the [`Waker`] doesn't need to or must not be /// destroyed. + #[inline] pub fn new_unowned(waker: ManuallyDrop) -> Self { Self { waker, _marker: PhantomData } } @@ -39,6 +41,7 @@ impl<'a> WakerRef<'a> { impl Deref for WakerRef<'_> { type Target = Waker; + #[inline] fn deref(&self) -> &Waker { &self.waker }