]> git.lizzy.rs Git - rust.git/blobdiff - src/libstd/future.rs
Rollup merge of #68388 - varkor:toogeneric-wf, r=eddyb
[rust.git] / src / libstd / future.rs
index ac1ef3e1d8b72a6b319636ebaa17c8e7c5c084aa..9c7422c2b20a6208c9807fbb81fbd889f70d3ace 100644 (file)
@@ -2,11 +2,11 @@
 
 use core::cell::Cell;
 use core::marker::Unpin;
-use core::pin::Pin;
+use core::ops::{Drop, Generator, GeneratorState};
 use core::option::Option;
+use core::pin::Pin;
 use core::ptr::NonNull;
 use core::task::{Context, Poll};
-use core::ops::{Drop, Generator, GeneratorState};
 
 #[doc(inline)]
 #[stable(feature = "futures_api", since = "1.36.0")]
@@ -66,9 +66,7 @@ fn drop(&mut self) {
 unsafe fn set_task_context(cx: &mut Context<'_>) -> SetOnDrop {
     // transmute the context's lifetime to 'static so we can store it.
     let cx = core::mem::transmute::<&mut Context<'_>, &mut Context<'static>>(cx);
-    let old_cx = TLS_CX.with(|tls_cx| {
-        tls_cx.replace(Some(NonNull::from(cx)))
-    });
+    let old_cx = TLS_CX.with(|tls_cx| tls_cx.replace(Some(NonNull::from(cx))));
     SetOnDrop(old_cx)
 }
 
@@ -77,7 +75,7 @@ unsafe fn set_task_context(cx: &mut Context<'_>) -> SetOnDrop {
 /// Polls a future in the current thread-local task waker.
 pub fn poll_with_tls_context<F>(f: Pin<&mut F>) -> Poll<F::Output>
 where
-    F: Future
+    F: Future,
 {
     let cx_ptr = TLS_CX.with(|tls_cx| {
         // Clear the entry so that nested `get_task_waker` calls
@@ -88,7 +86,8 @@ pub fn poll_with_tls_context<F>(f: Pin<&mut F>) -> Poll<F::Output>
 
     let mut cx_ptr = cx_ptr.expect(
         "TLS Context not set. This is a rustc bug. \
-        Please file an issue on https://github.com/rust-lang/rust.");
+        Please file an issue on https://github.com/rust-lang/rust.",
+    );
 
     // Safety: we've ensured exclusive access to the context by
     // removing the pointer from TLS, only to be replaced once