Skip to content

Commit 6ce56ff

Browse files
authored
Unrolled build for rust-lang#122244
Rollup merge of rust-lang#122244 - tvallotton:local_waker_leak_fix, r=Nilstrieb fix: LocalWaker memory leak and some stability attributes fixes rust-lang#122180.
2 parents 3521a2f + 092a1ab commit 6ce56ff

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

library/core/src/task/wake.rs

+16-5
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ impl LocalWaker {
622622
///
623623
/// [`poll()`]: crate::future::Future::poll
624624
#[inline]
625-
#[stable(feature = "futures_api", since = "1.36.0")]
625+
#[unstable(feature = "local_waker", issue = "118959")]
626626
pub fn wake(self) {
627627
// The actual wakeup call is delegated through a virtual function call
628628
// to the implementation which is defined by the executor.
@@ -644,7 +644,7 @@ impl LocalWaker {
644644
/// the case where an owned `Waker` is available. This method should be preferred to
645645
/// calling `waker.clone().wake()`.
646646
#[inline]
647-
#[stable(feature = "futures_api", since = "1.36.0")]
647+
#[unstable(feature = "local_waker", issue = "118959")]
648648
pub fn wake_by_ref(&self) {
649649
// The actual wakeup call is delegated through a virtual function call
650650
// to the implementation which is defined by the executor.
@@ -664,7 +664,7 @@ impl LocalWaker {
664664
/// avoid cloning the waker when they would wake the same task anyway.
665665
#[inline]
666666
#[must_use]
667-
#[stable(feature = "futures_api", since = "1.36.0")]
667+
#[unstable(feature = "local_waker", issue = "118959")]
668668
pub fn will_wake(&self, other: &LocalWaker) -> bool {
669669
self.waker == other.waker
670670
}
@@ -676,7 +676,7 @@ impl LocalWaker {
676676
/// Therefore this method is unsafe.
677677
#[inline]
678678
#[must_use]
679-
#[stable(feature = "futures_api", since = "1.36.0")]
679+
#[unstable(feature = "local_waker", issue = "118959")]
680680
#[rustc_const_unstable(feature = "const_waker", issue = "102012")]
681681
pub const unsafe fn from_raw(waker: RawWaker) -> LocalWaker {
682682
Self { waker }
@@ -748,7 +748,18 @@ impl AsRef<LocalWaker> for Waker {
748748
}
749749
}
750750

751-
#[stable(feature = "futures_api", since = "1.36.0")]
751+
#[unstable(feature = "local_waker", issue = "118959")]
752+
impl Drop for LocalWaker {
753+
#[inline]
754+
fn drop(&mut self) {
755+
// SAFETY: This is safe because `LocalWaker::from_raw` is the only way
756+
// to initialize `drop` and `data` requiring the user to acknowledge
757+
// that the contract of `RawWaker` is upheld.
758+
unsafe { (self.waker.vtable.drop)(self.waker.data) }
759+
}
760+
}
761+
762+
#[unstable(feature = "local_waker", issue = "118959")]
752763
impl fmt::Debug for LocalWaker {
753764
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
754765
let vtable_ptr = self.waker.vtable as *const RawWakerVTable;

0 commit comments

Comments
 (0)