Skip to content

Commit

Permalink
style(maitake): fix dead code warnings with loom (#188)
Browse files Browse the repository at this point in the history
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
  • Loading branch information
hawkw authored Jun 3, 2022
1 parent a0809c5 commit 0029a1b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions maitake/src/scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ pub trait Schedule: Sized + Clone {
/// [`StaticScheduler`]: crate::scheduler::StaticScheduler
/// [`new_with_static_stub()`]: crate::scheduler::StaticScheduler::new_with_static_stub
#[repr(transparent)]
#[cfg_attr(loom, allow(dead_code))]
pub struct TaskStub {
hdr: Header,
}
Expand Down
14 changes: 7 additions & 7 deletions maitake/src/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,6 @@ enum Cell<F: Future> {
Finished(F::Output),
}

unsafe fn nop(_ptr: NonNull<Header>) -> Poll<()> {
#[cfg(debug_assertions)]
unreachable!("stub task ({_ptr:p}) should never be polled!");
#[cfg(not(debug_assertions))]
Poll::Pending
}

#[derive(Debug)]
struct Vtable {
/// Poll the future.
Expand Down Expand Up @@ -447,6 +440,13 @@ unsafe impl Sync for TaskRef {}
impl Header {
#[cfg(not(loom))]
pub(crate) const fn new_stub() -> Self {
unsafe fn nop(_ptr: NonNull<Header>) -> Poll<()> {
#[cfg(debug_assertions)]
unreachable!("stub task ({_ptr:p}) should never be polled!");
#[cfg(not(debug_assertions))]
Poll::Pending
}

Self {
run_queue: mpsc_queue::Links::new_stub(),
state: StateCell::new(),
Expand Down

0 comments on commit 0029a1b

Please sign in to comment.