From aaa6d3bec2d08f425c844f5964782e1d6a1bbc88 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 11 Feb 2024 23:06:09 +0100 Subject: [PATCH] add comparison warning to RawWakerVTable as well --- library/core/src/task/wake.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/library/core/src/task/wake.rs b/library/core/src/task/wake.rs index 9ad71e394ea..09f3f2f02ea 100644 --- a/library/core/src/task/wake.rs +++ b/library/core/src/task/wake.rs @@ -99,6 +99,12 @@ pub fn vtable(&self) -> &'static RawWakerVTable { /// [`RawWaker`] implementation. Calling one of the contained functions using /// any other `data` pointer will cause undefined behavior. /// +/// Note that while this type implements `PartialEq`, comparing function pointers, and hence +/// comparing structs like this that contain function pointers, is unreliable: pointers to the same +/// function can compare inequal (because functions are duplicated in multiple codegen units), and +/// pointers to *different* functions can compare equal (since identical functions can be +/// deduplicated within a codegen unit). +/// /// # Thread safety /// If the [`RawWaker`] will be used to construct a [`Waker`] then /// these functions must all be thread-safe (even though [`RawWaker`] is