diff options
author | John-John Tedro <udoprog@tedro.se> | 2020-04-29 17:24:55 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-29 08:24:55 -0700 |
commit | 2c53bebe56d584f1d6b710e9b39df6452d655a26 (patch) | |
tree | 12172c80c652e3b2838b72595cf31d48c952dcc9 | |
parent | 0f4287ac2bc8950088d20e4a94614b608891bfb5 (diff) |
runtime: mem::forget instead of keeping track of dropped state (#2451)
-rw-r--r-- | tokio/src/runtime/task/harness.rs | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/tokio/src/runtime/task/harness.rs b/tokio/src/runtime/task/harness.rs index a2488aa2..e86b29e6 100644 --- a/tokio/src/runtime/task/harness.rs +++ b/tokio/src/runtime/task/harness.rs @@ -89,21 +89,15 @@ where let res = panic::catch_unwind(panic::AssertUnwindSafe(|| { struct Guard<'a, T: Future, S: Schedule> { core: &'a Core<T, S>, - polled: bool, } impl<T: Future, S: Schedule> Drop for Guard<'_, T, S> { fn drop(&mut self) { - if !self.polled { - self.core.drop_future_or_output(); - } + self.core.drop_future_or_output(); } } - let mut guard = Guard { - core: self.core(), - polled: false, - }; + let guard = Guard { core: self.core() }; // If the task is cancelled, avoid polling it, instead signalling it // is complete. @@ -113,7 +107,7 @@ where let res = guard.core.poll(self.header()); // prevent the guard from dropping the future - guard.polled = true; + mem::forget(guard); res.map(Ok) } |