diff options
| author | Taylor Cramer <cramertj@google.com> | 2018-08-02 13:07:55 -0700 |
|---|---|---|
| committer | Taylor Cramer <cramertj@google.com> | 2018-08-02 13:07:55 -0700 |
| commit | 3a93e914ebe317a2b8267401e65e137961afc851 (patch) | |
| tree | 9b419d1cff538710427f7701d792fab49f6b0a25 /src/libstd | |
| parent | 03da14ba8cd22acbcfe1cca617f6c274999e5e9e (diff) | |
| download | rust-3a93e914ebe317a2b8267401e65e137961afc851.tar.gz rust-3a93e914ebe317a2b8267401e65e137961afc851.zip | |
Remove unnecessary local in await! macro
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/future.rs | 4 | ||||
| -rw-r--r-- | src/libstd/macros.rs | 15 |
2 files changed, 11 insertions, 8 deletions
diff --git a/src/libstd/future.rs b/src/libstd/future.rs index c1cc36f3b41..12ea1ea9f9d 100644 --- a/src/libstd/future.rs +++ b/src/libstd/future.rs @@ -108,9 +108,9 @@ where #[unstable(feature = "gen_future", issue = "50547")] /// Polls a future in the current thread-local task context. -pub fn poll_in_task_cx<F>(f: &mut PinMut<F>) -> Poll<F::Output> +pub fn poll_in_task_cx<F>(f: PinMut<F>) -> Poll<F::Output> where F: Future { - get_task_cx(|cx| f.reborrow().poll(cx)) + get_task_cx(|cx| f.poll(cx)) } diff --git a/src/libstd/macros.rs b/src/libstd/macros.rs index a96e2ba2134..f15494c5fd7 100644 --- a/src/libstd/macros.rs +++ b/src/libstd/macros.rs @@ -227,14 +227,17 @@ macro_rules! eprintln { macro_rules! await { ($e:expr) => { { let mut pinned = $e; - let mut pinned = unsafe { $crate::mem::PinMut::new_unchecked(&mut pinned) }; loop { - match $crate::future::poll_in_task_cx(&mut pinned) { - // FIXME(cramertj) prior to stabilizing await, we have to ensure that this - // can't be used to create a generator on stable via `|| await!()`. - $crate::task::Poll::Pending => yield, - $crate::task::Poll::Ready(x) => break x, + if let $crate::task::Poll::Ready(x) = + $crate::future::poll_in_task_cx(unsafe { + $crate::mem::PinMut::new_unchecked(&mut pinned) + }) + { + break x; } + // FIXME(cramertj) prior to stabilizing await, we have to ensure that this + // can't be used to create a generator on stable via `|| await!()`. + yield } } } } |
