Rollup merge of #128882 - RalfJung:local-waker-will-wake, r=cuviper · patricklam/verify-rust-std@f48facf (original) (raw)

Original file line number Diff line number Diff line change
@@ -502,6 +502,8 @@ impl Waker {
502 502 #[must_use]
503 503 #[stable(feature = "futures_api", since = "1.36.0")]
504 504 pub fn will_wake(&self, other: &Waker) -> bool {
505 +// We optimize this by comparing vtable addresses instead of vtable contents.
506 +// This is permitted since the function is documented as best-effort.
505 507 let RawWaker { data: a_data, vtable: a_vtable } = self.waker;
506 508 let RawWaker { data: b_data, vtable: b_vtable } = other.waker;
507 509 a_data == b_data && ptr::eq(a_vtable, b_vtable)
@@ -761,7 +763,11 @@ impl LocalWaker {
761 763 #[must_use]
762 764 #[unstable(feature = "local_waker", issue = "118959")]
763 765 pub fn will_wake(&self, other: &LocalWaker) -> bool {
764 -self.waker == other.waker
766 +// We optimize this by comparing vtable addresses instead of vtable contents.
767 +// This is permitted since the function is documented as best-effort.
768 +let RawWaker { data: a_data, vtable: a_vtable } = self.waker;
769 +let RawWaker { data: b_data, vtable: b_vtable } = other.waker;
770 + a_data == b_data && ptr::eq(a_vtable, b_vtable)
765 771 }
766 772
767 773 /// Creates a new `LocalWaker` from [`RawWaker`].