Skip to content

Commit f18bf79

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

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 non-associated `pub static NOOP: &Waker`, but associated
361+
// static items are not currently allowed either.
357362
const VTABLE: RawWakerVTable = RawWakerVTable::new(
358363
// Cloning just returns a new no-op raw waker
359364
|_| RAW,

0 commit comments

Comments
 (0)