From 570852b7e4ba38331d0dac8397833140f7377dd4 Mon Sep 17 00:00:00 2001 From: dullbananas Date: Mon, 10 Jul 2023 22:00:55 -0700 Subject: [PATCH 01/17] Reduce codegen for debug checks in `runtime::task::Cell::new` --- tokio/src/runtime/task/core.rs | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/tokio/src/runtime/task/core.rs b/tokio/src/runtime/task/core.rs index 110933e58f0..b0b55be250c 100644 --- a/tokio/src/runtime/task/core.rs +++ b/tokio/src/runtime/task/core.rs @@ -237,18 +237,24 @@ impl Cell { #[cfg(debug_assertions)] { - let trailer_addr = (&result.trailer) as *const Trailer as usize; - let trailer_ptr = unsafe { Header::get_trailer(NonNull::from(&result.header)) }; - assert_eq!(trailer_addr, trailer_ptr.as_ptr() as usize); - - let scheduler_addr = (&result.core.scheduler) as *const S as usize; - let scheduler_ptr = - unsafe { Header::get_scheduler::(NonNull::from(&result.header)) }; - assert_eq!(scheduler_addr, scheduler_ptr.as_ptr() as usize); - - let id_addr = (&result.core.task_id) as *const Id as usize; - let id_ptr = unsafe { Header::get_id_ptr(NonNull::from(&result.header)) }; - assert_eq!(id_addr, id_ptr.as_ptr() as usize); + // Using a separate function for this code avoids instantiating it separately for every `T`. + unsafe fn check(header: &Header, trailer: &Trailer, scheduler: &S, task_id: &Id) { + let trailer_addr = trailer as *const Trailer as usize; + let trailer_ptr = unsafe { Header::get_trailer(NonNull::from(header)) }; + assert_eq!(trailer_addr, trailer_ptr.as_ptr() as usize); + + let scheduler_addr = scheduler as *const S as usize; + let scheduler_ptr = + unsafe { Header::get_scheduler::(NonNull::from(header)) }; + assert_eq!(scheduler_addr, scheduler_ptr.as_ptr() as usize); + + let id_addr = task_id as *const Id as usize; + let id_ptr = unsafe { Header::get_id_ptr(NonNull::from(header)) }; + assert_eq!(id_addr, id_ptr.as_ptr() as usize); + } + unsafe { + check(&result.header, &result.trailer, &result.core.scheduler, &result.core.task_id); + } } result From d085c0244b129d3e0a5bdb0fc8e863f09b8206b1 Mon Sep 17 00:00:00 2001 From: dullbananas Date: Tue, 11 Jul 2023 17:41:37 -0700 Subject: [PATCH 02/17] Move `trace_span` macro invocation to separate function --- tokio/src/util/trace.rs | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/tokio/src/util/trace.rs b/tokio/src/util/trace.rs index 76e8a6cbf55..be5602dcba3 100644 --- a/tokio/src/util/trace.rs +++ b/tokio/src/util/trace.rs @@ -11,18 +11,22 @@ cfg_trace! { #[inline] #[track_caller] pub(crate) fn task(task: F, kind: &'static str, name: Option<&str>, id: u64) -> Instrumented { + #[track_caller] + fn get_span(kind: &'static str, name: Option<&str>, id: u64) -> tracing::Span { + let location = std::panic::Location::caller(); + tracing::trace_span!( + target: "tokio::task", + "runtime.spawn", + %kind, + task.name = %name.unwrap_or_default(), + task.id = id, + loc.file = location.file(), + loc.line = location.line(), + loc.col = location.column(), + ) + } use tracing::instrument::Instrument; - let location = std::panic::Location::caller(); - let span = tracing::trace_span!( - target: "tokio::task", - "runtime.spawn", - %kind, - task.name = %name.unwrap_or_default(), - task.id = id, - loc.file = location.file(), - loc.line = location.line(), - loc.col = location.column(), - ); + let span = get_span(kind, name, id); task.instrument(span) } From 09ce4c93b09992ce66ce99f44008e0891a7cb876 Mon Sep 17 00:00:00 2001 From: dullbananas Date: Tue, 11 Jul 2023 17:58:10 -0700 Subject: [PATCH 03/17] Reduce code generation for `OwnedTasks::bind` --- tokio/src/runtime/task/list.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tokio/src/runtime/task/list.rs b/tokio/src/runtime/task/list.rs index fb7dbdc1d95..5d75a840293 100644 --- a/tokio/src/runtime/task/list.rs +++ b/tokio/src/runtime/task/list.rs @@ -96,7 +96,14 @@ impl OwnedTasks { T::Output: Send + 'static, { let (task, notified, join) = super::new_task(task, scheduler, id); + let notified = unsafe { + self.bind_inner(task, notified) + }; + (join, notified) + } + /// The part of `bind` that's the same for every type of future. + unsafe fn bind_inner(&self, task: Task, notified: Notified) -> Option> { unsafe { // safety: We just created the task, so we have exclusive access // to the field. @@ -108,7 +115,7 @@ impl OwnedTasks { drop(lock); drop(notified); task.shutdown(); - (join, None) + None } else { lock.list.push_front(task); (join, Some(notified)) From 53df7ed823b87c6f705e66bc2004a275ab665382 Mon Sep 17 00:00:00 2001 From: dullbananas Date: Tue, 11 Jul 2023 18:27:30 -0700 Subject: [PATCH 04/17] Use separate function to handle panic in `task::harness::poll_future` --- tokio/src/runtime/task/harness.rs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/tokio/src/runtime/task/harness.rs b/tokio/src/runtime/task/harness.rs index 8e3c3d14fa0..df2f27d0a02 100644 --- a/tokio/src/runtime/task/harness.rs +++ b/tokio/src/runtime/task/harness.rs @@ -2,7 +2,7 @@ use crate::future::Future; use crate::runtime::task::core::{Cell, Core, Header, Trailer}; use crate::runtime::task::state::{Snapshot, State}; use crate::runtime::task::waker::waker_ref; -use crate::runtime::task::{JoinError, Notified, RawTask, Schedule, Task}; +use crate::runtime::task::{Id, JoinError, Notified, RawTask, Schedule, Task}; use std::mem; use std::mem::ManuallyDrop; @@ -482,10 +482,7 @@ fn poll_future(core: &Core, cx: Context<'_>) -> Po let output = match output { Ok(Poll::Pending) => return Poll::Pending, Ok(Poll::Ready(output)) => Ok(output), - Err(panic) => { - core.scheduler.unhandled_panic(); - Err(JoinError::panic(core.task_id, panic)) - } + Err(panic) => Err(panic_to_error(&core.scheduler, core.task_id, panic)), }; // Catch and ignore panics if the future panics on drop. @@ -499,3 +496,13 @@ fn poll_future(core: &Core, cx: Context<'_>) -> Po Poll::Ready(()) } + +#[cold] +fn panic_to_error( + scheduler: &S, + task_id: Id, + panic: Box JoinError { + scheduler.unhandled_panic(); + JoinError::panic(task_id, panic) +} From 02ad2bef07df9953ba8a16d160f19b6047b86352 Mon Sep 17 00:00:00 2001 From: dullbananas Date: Tue, 11 Jul 2023 19:00:24 -0700 Subject: [PATCH 05/17] Add `schedule_option_task_without_yield` --- tokio/src/runtime/scheduler/multi_thread/worker.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tokio/src/runtime/scheduler/multi_thread/worker.rs b/tokio/src/runtime/scheduler/multi_thread/worker.rs index 6ae11463373..577c0cc3d84 100644 --- a/tokio/src/runtime/scheduler/multi_thread/worker.rs +++ b/tokio/src/runtime/scheduler/multi_thread/worker.rs @@ -1024,6 +1024,12 @@ impl Handle { }) } + pub(super) fn schedule_option_task_without_yield(&self, task: Option) { + if let Some(task) = task { + self.schedule_task(task, false); + } + } + fn schedule_local(&self, core: &mut Core, task: Notified, is_yield: bool) { core.stats.inc_local_schedule_count(); From 4ad5fb19495494d1d79b5187303030a1e7dbfeef Mon Sep 17 00:00:00 2001 From: dullbananas Date: Tue, 11 Jul 2023 19:02:58 -0700 Subject: [PATCH 06/17] Use `schedule_option_task_without_yield` in `bind_new_task` --- tokio/src/runtime/scheduler/multi_thread/handle.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tokio/src/runtime/scheduler/multi_thread/handle.rs b/tokio/src/runtime/scheduler/multi_thread/handle.rs index 98e47658560..dfa186dda4f 100644 --- a/tokio/src/runtime/scheduler/multi_thread/handle.rs +++ b/tokio/src/runtime/scheduler/multi_thread/handle.rs @@ -53,9 +53,7 @@ impl Handle { { let (handle, notified) = me.shared.owned.bind(future, me.clone(), id); - if let Some(notified) = notified { - me.schedule_task(notified, false); - } + me.schedule_option_task_without_yield(notified); handle } From 4e8a50d9a24c5cf8a16971dbfff6304bd8886483 Mon Sep 17 00:00:00 2001 From: dullbananas Date: Tue, 11 Jul 2023 19:36:22 -0700 Subject: [PATCH 07/17] Move enum conversion in `poll_inner` to separate function --- tokio/src/runtime/task/harness.rs | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/tokio/src/runtime/task/harness.rs b/tokio/src/runtime/task/harness.rs index df2f27d0a02..aff9d733052 100644 --- a/tokio/src/runtime/task/harness.rs +++ b/tokio/src/runtime/task/harness.rs @@ -192,6 +192,15 @@ where match self.state().transition_to_running() { TransitionToRunning::Success => { + // Separated to reduce LLVM codegen + fn transition_result_to_poll_future(result: TransitionToIdle) -> PollFuture { + match result { + TransitionToIdle::Ok => PollFuture::Done, + TransitionToIdle::OkNotified => PollFuture::Notified, + TransitionToIdle::OkDealloc => PollFuture::Dealloc, + TransitionToIdle::Cancelled => PollFuture::Complete, + } + } let header_ptr = self.header_ptr(); let waker_ref = waker_ref::(&header_ptr); let cx = Context::from_waker(&waker_ref); @@ -202,17 +211,13 @@ where return PollFuture::Complete; } - match self.state().transition_to_idle() { - TransitionToIdle::Ok => PollFuture::Done, - TransitionToIdle::OkNotified => PollFuture::Notified, - TransitionToIdle::OkDealloc => PollFuture::Dealloc, - TransitionToIdle::Cancelled => { - // The transition to idle failed because the task was - // cancelled during the poll. - cancel_task(self.core()); - PollFuture::Complete - } + let transition_res = self.state().transition_to_idle(); + if let &TransitionToIdle::Cancelled = &transition_res { + // The transition to idle failed because the task was + // cancelled during the poll. + cancel_task(self.core()); } + transition_result_to_poll_future(transition_res) } TransitionToRunning::Cancelled => { cancel_task(self.core()); From 8c5af9c653074e2c79cd0c1b180c639bf9fc92f9 Mon Sep 17 00:00:00 2001 From: dullbananas Date: Tue, 11 Jul 2023 20:10:03 -0700 Subject: [PATCH 08/17] Reduce codegen for `Harness::cancel_task` --- tokio/src/runtime/task/harness.rs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/tokio/src/runtime/task/harness.rs b/tokio/src/runtime/task/harness.rs index aff9d733052..7ab5005a2d7 100644 --- a/tokio/src/runtime/task/harness.rs +++ b/tokio/src/runtime/task/harness.rs @@ -452,14 +452,15 @@ fn cancel_task(core: &Core) { core.drop_future_or_output(); })); - match res { - Ok(()) => { - core.store_output(Err(JoinError::cancelled(core.task_id))); - } - Err(panic) => { - core.store_output(Err(JoinError::panic(core.task_id, panic))); - } - } + core.store_output(panic_result_to_join_error(res)); +} + +fn panic_result_to_join_error(res: Result<(), Box>) { + let err = match res { + Ok(()) => JoinError::cancelled(core.task_id), + Err(panic) => JoinError::panic(core.task_id, panic), + }; + Err(err) } /// Polls the future. If the future completes, the output is written to the From 0480da31fcb3df6fde15205968d3faa7c75cfb7e Mon Sep 17 00:00:00 2001 From: dullbananas Date: Wed, 12 Jul 2023 08:38:07 -0700 Subject: [PATCH 09/17] Fix formatting in core.rs --- tokio/src/runtime/task/core.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tokio/src/runtime/task/core.rs b/tokio/src/runtime/task/core.rs index b0b55be250c..23eb52440c0 100644 --- a/tokio/src/runtime/task/core.rs +++ b/tokio/src/runtime/task/core.rs @@ -244,8 +244,7 @@ impl Cell { assert_eq!(trailer_addr, trailer_ptr.as_ptr() as usize); let scheduler_addr = scheduler as *const S as usize; - let scheduler_ptr = - unsafe { Header::get_scheduler::(NonNull::from(header)) }; + let scheduler_ptr = unsafe { Header::get_scheduler::(NonNull::from(header)) }; assert_eq!(scheduler_addr, scheduler_ptr.as_ptr() as usize); let id_addr = task_id as *const Id as usize; @@ -253,7 +252,12 @@ impl Cell { assert_eq!(id_addr, id_ptr.as_ptr() as usize); } unsafe { - check(&result.header, &result.trailer, &result.core.scheduler, &result.core.task_id); + check( + &result.header, + &result.trailer, + &result.core.scheduler, + &result.core.task_id, + ); } } From bb21d5968564d21c350a581b1f702bad957cf84a Mon Sep 17 00:00:00 2001 From: dullbananas Date: Wed, 12 Jul 2023 08:58:17 -0700 Subject: [PATCH 10/17] Move initialization of Header and Trailer to separate functions --- tokio/src/runtime/task/core.rs | 40 ++++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/tokio/src/runtime/task/core.rs b/tokio/src/runtime/task/core.rs index 23eb52440c0..4294ec57e88 100644 --- a/tokio/src/runtime/task/core.rs +++ b/tokio/src/runtime/task/core.rs @@ -207,21 +207,39 @@ pub(super) enum Stage { Consumed, } + + impl Cell { /// Allocates a new task cell, containing the header, trailer, and core /// structures. pub(super) fn new(future: T, scheduler: S, state: State, task_id: Id) -> Box> { + // Separated into a non-generic function to reduce LLVM codegen + fn new_header( + state: State, + vtable: &'static Vtable, + #[cfg(all(tokio_unstable, feature = "tracing"))] + tracing_id: Option, + ) -> Header { + Header { + state, + queue_next: UnsafeCell::new(None), + vtable,, + owner_id: UnsafeCell::new(0), + #[cfg(all(tokio_unstable, feature = "tracing"))] + tracing_id, + } + } + #[cfg(all(tokio_unstable, feature = "tracing"))] let tracing_id = future.id(); + let vtable = raw::vtable::(); let result = Box::new(Cell { - header: Header { + header: new_header( state, - queue_next: UnsafeCell::new(None), - vtable: raw::vtable::(), - owner_id: UnsafeCell::new(0), + vtable, #[cfg(all(tokio_unstable, feature = "tracing"))] tracing_id, - }, + ), core: Core { scheduler, stage: CoreStage { @@ -229,10 +247,7 @@ impl Cell { }, task_id, }, - trailer: Trailer { - waker: UnsafeCell::new(None), - owned: linked_list::Pointers::new(), - }, + trailer: Trailer::new(), }); #[cfg(debug_assertions)] @@ -452,6 +467,13 @@ impl Header { } impl Trailer { + fn new() -> Self { + Trailer { + waker: UnsafeCell::new(None), + owned: linked_list::Pointers::new(), + } + } + pub(super) unsafe fn set_waker(&self, waker: Option) { self.waker.with_mut(|ptr| { *ptr = waker; From ab44d668256b7e54899f631c58b7cdbf0a75da6e Mon Sep 17 00:00:00 2001 From: dullbananas Date: Wed, 12 Jul 2023 09:13:55 -0700 Subject: [PATCH 11/17] Remove added blank lines in core.rs --- tokio/src/runtime/task/core.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/tokio/src/runtime/task/core.rs b/tokio/src/runtime/task/core.rs index 4294ec57e88..9eae9988c1f 100644 --- a/tokio/src/runtime/task/core.rs +++ b/tokio/src/runtime/task/core.rs @@ -207,8 +207,6 @@ pub(super) enum Stage { Consumed, } - - impl Cell { /// Allocates a new task cell, containing the header, trailer, and core /// structures. From fab8991d880fac0dd74e247582cf5c4a7dcc29b1 Mon Sep 17 00:00:00 2001 From: dullbananas Date: Wed, 12 Jul 2023 11:44:09 -0700 Subject: [PATCH 12/17] Fix `bind_inner` --- tokio/src/runtime/task/list.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tokio/src/runtime/task/list.rs b/tokio/src/runtime/task/list.rs index 5d75a840293..d377d30c900 100644 --- a/tokio/src/runtime/task/list.rs +++ b/tokio/src/runtime/task/list.rs @@ -118,7 +118,7 @@ impl OwnedTasks { None } else { lock.list.push_front(task); - (join, Some(notified)) + Some(notified) } } From 2a9b65cbe2365fcd40c8630007f1c4c5bbb9a0db Mon Sep 17 00:00:00 2001 From: dullbananas Date: Wed, 12 Jul 2023 11:48:36 -0700 Subject: [PATCH 13/17] Remove comma --- tokio/src/runtime/task/core.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tokio/src/runtime/task/core.rs b/tokio/src/runtime/task/core.rs index 9eae9988c1f..e63f5470b8e 100644 --- a/tokio/src/runtime/task/core.rs +++ b/tokio/src/runtime/task/core.rs @@ -221,7 +221,7 @@ impl Cell { Header { state, queue_next: UnsafeCell::new(None), - vtable,, + vtable, owner_id: UnsafeCell::new(0), #[cfg(all(tokio_unstable, feature = "tracing"))] tracing_id, From 974eff9da34f153896891dd72685102d06b3215c Mon Sep 17 00:00:00 2001 From: dullbananas Date: Wed, 12 Jul 2023 12:56:59 -0700 Subject: [PATCH 14/17] Fix formatting and errors --- tokio/src/runtime/task/core.rs | 3 +-- tokio/src/runtime/task/harness.rs | 11 ++++++----- tokio/src/runtime/task/list.rs | 4 +--- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/tokio/src/runtime/task/core.rs b/tokio/src/runtime/task/core.rs index e63f5470b8e..dbaa330937e 100644 --- a/tokio/src/runtime/task/core.rs +++ b/tokio/src/runtime/task/core.rs @@ -215,8 +215,7 @@ impl Cell { fn new_header( state: State, vtable: &'static Vtable, - #[cfg(all(tokio_unstable, feature = "tracing"))] - tracing_id: Option, + #[cfg(all(tokio_unstable, feature = "tracing"))] tracing_id: Option, ) -> Header { Header { state, diff --git a/tokio/src/runtime/task/harness.rs b/tokio/src/runtime/task/harness.rs index 7ab5005a2d7..97341e0fc89 100644 --- a/tokio/src/runtime/task/harness.rs +++ b/tokio/src/runtime/task/harness.rs @@ -4,6 +4,7 @@ use crate::runtime::task::state::{Snapshot, State}; use crate::runtime::task::waker::waker_ref; use crate::runtime::task::{Id, JoinError, Notified, RawTask, Schedule, Task}; +use std::any::Any; use std::mem; use std::mem::ManuallyDrop; use std::panic; @@ -452,13 +453,13 @@ fn cancel_task(core: &Core) { core.drop_future_or_output(); })); - core.store_output(panic_result_to_join_error(res)); + core.store_output(panic_result_to_join_error(core.task_id, res)); } -fn panic_result_to_join_error(res: Result<(), Box>) { +fn panic_result_to_join_error(task_id: Id, res: Result<(), Box>) { let err = match res { - Ok(()) => JoinError::cancelled(core.task_id), - Err(panic) => JoinError::panic(core.task_id, panic), + Ok(()) => JoinError::cancelled(task_id), + Err(panic) => JoinError::panic(task_id, panic), }; Err(err) } @@ -507,7 +508,7 @@ fn poll_future(core: &Core, cx: Context<'_>) -> Po fn panic_to_error( scheduler: &S, task_id: Id, - panic: Box, ) -> JoinError { scheduler.unhandled_panic(); JoinError::panic(task_id, panic) diff --git a/tokio/src/runtime/task/list.rs b/tokio/src/runtime/task/list.rs index d377d30c900..a61bc6cc777 100644 --- a/tokio/src/runtime/task/list.rs +++ b/tokio/src/runtime/task/list.rs @@ -96,9 +96,7 @@ impl OwnedTasks { T::Output: Send + 'static, { let (task, notified, join) = super::new_task(task, scheduler, id); - let notified = unsafe { - self.bind_inner(task, notified) - }; + let notified = unsafe { self.bind_inner(task, notified) }; (join, notified) } From a8de86acac336e30864c082b5bf4d81567755a2b Mon Sep 17 00:00:00 2001 From: dullbananas Date: Wed, 12 Jul 2023 13:05:28 -0700 Subject: [PATCH 15/17] Fix type errors --- tokio/src/runtime/task/harness.rs | 9 ++++----- tokio/src/runtime/task/list.rs | 5 ++++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/tokio/src/runtime/task/harness.rs b/tokio/src/runtime/task/harness.rs index 97341e0fc89..39264d5995a 100644 --- a/tokio/src/runtime/task/harness.rs +++ b/tokio/src/runtime/task/harness.rs @@ -453,15 +453,14 @@ fn cancel_task(core: &Core) { core.drop_future_or_output(); })); - core.store_output(panic_result_to_join_error(core.task_id, res)); + core.store_output(Err(panic_result_to_join_error(core.task_id, res))); } -fn panic_result_to_join_error(task_id: Id, res: Result<(), Box>) { - let err = match res { +fn panic_result_to_join_error(task_id: Id,res: Result<(), Box>) -> JoinError { + match res { Ok(()) => JoinError::cancelled(task_id), Err(panic) => JoinError::panic(task_id, panic), - }; - Err(err) + } } /// Polls the future. If the future completes, the output is written to the diff --git a/tokio/src/runtime/task/list.rs b/tokio/src/runtime/task/list.rs index a61bc6cc777..930a0099d3d 100644 --- a/tokio/src/runtime/task/list.rs +++ b/tokio/src/runtime/task/list.rs @@ -101,7 +101,10 @@ impl OwnedTasks { } /// The part of `bind` that's the same for every type of future. - unsafe fn bind_inner(&self, task: Task, notified: Notified) -> Option> { + unsafe fn bind_inner(&self, task: Task, notified: Notified) -> Option> + where + S: Schedule, + { unsafe { // safety: We just created the task, so we have exclusive access // to the field. From dcf662b05c8ce70e910bbbe1d0afa53f0391a69c Mon Sep 17 00:00:00 2001 From: dullbananas Date: Wed, 12 Jul 2023 13:11:03 -0700 Subject: [PATCH 16/17] Format `panic_result_to_join_error` --- tokio/src/runtime/task/harness.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tokio/src/runtime/task/harness.rs b/tokio/src/runtime/task/harness.rs index 39264d5995a..aa18b4a858d 100644 --- a/tokio/src/runtime/task/harness.rs +++ b/tokio/src/runtime/task/harness.rs @@ -456,7 +456,10 @@ fn cancel_task(core: &Core) { core.store_output(Err(panic_result_to_join_error(core.task_id, res))); } -fn panic_result_to_join_error(task_id: Id,res: Result<(), Box>) -> JoinError { +fn panic_result_to_join_error( + task_id: Id, + res: Result<(), Box>, +) -> JoinError { match res { Ok(()) => JoinError::cancelled(task_id), Err(panic) => JoinError::panic(task_id, panic), From b92833c23c96ba4db261170b5b59be87affb9f04 Mon Sep 17 00:00:00 2001 From: dullbananas Date: Fri, 14 Jul 2023 07:47:14 -0700 Subject: [PATCH 17/17] Update tokio/src/runtime/task/harness.rs Co-authored-by: Alice Ryhl --- tokio/src/runtime/task/harness.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tokio/src/runtime/task/harness.rs b/tokio/src/runtime/task/harness.rs index aa18b4a858d..13c46bbf7a5 100644 --- a/tokio/src/runtime/task/harness.rs +++ b/tokio/src/runtime/task/harness.rs @@ -213,7 +213,7 @@ where } let transition_res = self.state().transition_to_idle(); - if let &TransitionToIdle::Cancelled = &transition_res { + if let TransitionToIdle::Cancelled = transition_res { // The transition to idle failed because the task was // cancelled during the poll. cancel_task(self.core());