From 366d4d59667a0683ce1245428d7174ce77ee9740 Mon Sep 17 00:00:00 2001 From: Eliza Weisman Date: Sat, 27 Aug 2022 12:31:22 -0700 Subject: [PATCH] fix(maitake): dead code warning with `cfg(loom)` (#300) The `Header::STUB_VTABLE` constant is not used when the `loom` cfg is set, so it was emitting a dead code warning. I fixed this by moving it into the only function that actually references it, so it's not present with `--cfg loom`. --- maitake/src/task.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/maitake/src/task.rs b/maitake/src/task.rs index aebac478..4b489d3e 100644 --- a/maitake/src/task.rs +++ b/maitake/src/task.rs @@ -1029,18 +1029,18 @@ unsafe fn _maitake_header_nop_poll_join( } impl Header { - const STUB_VTABLE: Vtable = Vtable { - poll: _maitake_header_nop, - poll_join: _maitake_header_nop_poll_join, - deallocate: _maitake_header_nop_deallocate, - }; - #[cfg(not(loom))] pub(crate) const fn new_stub() -> Self { + const STUB_VTABLE: Vtable = Vtable { + poll: _maitake_header_nop, + poll_join: _maitake_header_nop_poll_join, + deallocate: _maitake_header_nop_deallocate, + }; + Self { run_queue: mpsc_queue::Links::new_stub(), state: StateCell::new(), - vtable: &Self::STUB_VTABLE, + vtable: &STUB_VTABLE, span: trace::Span::none(), id: TaskId::stub(), }