Skip to content

Commit 7052188

Browse files
committed
Document why Waker::noop()'s implementation is the shape it is.
1 parent 219b00d commit 7052188

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

library/core/src/task/wake.rs

+5
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,11 @@ impl Waker {
354354
#[must_use]
355355
#[unstable(feature = "noop_waker", issue = "98286")]
356356
pub const fn noop() -> &'static Waker {
357+
// Ideally all this data would be explicitly `static` because it is used by reference and
358+
// only ever needs one copy. But `const fn`s (and `const` items) cannot refer to statics,
359+
// even though their values can be promoted to static. (That might change; see #119618.)
360+
// An alternative would be a `pub static NOOP: &Waker`, but associated static items are not
361+
// currently allowed either, and making it non-associated would be unergonomic.
357362
const VTABLE: RawWakerVTable = RawWakerVTable::new(
358363
// Cloning just returns a new no-op raw waker
359364
|_| RAW,

0 commit comments

Comments
 (0)