Skip to content

Commit 3a93e91

Browse files
committed
Remove unnecessary local in await! macro
1 parent 03da14b commit 3a93e91

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

src/libstd/future.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,9 @@ where
108108

109109
#[unstable(feature = "gen_future", issue = "50547")]
110110
/// Polls a future in the current thread-local task context.
111-
pub fn poll_in_task_cx<F>(f: &mut PinMut<F>) -> Poll<F::Output>
111+
pub fn poll_in_task_cx<F>(f: PinMut<F>) -> Poll<F::Output>
112112
where
113113
F: Future
114114
{
115-
get_task_cx(|cx| f.reborrow().poll(cx))
115+
get_task_cx(|cx| f.poll(cx))
116116
}

src/libstd/macros.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -227,14 +227,17 @@ macro_rules! eprintln {
227227
macro_rules! await {
228228
($e:expr) => { {
229229
let mut pinned = $e;
230-
let mut pinned = unsafe { $crate::mem::PinMut::new_unchecked(&mut pinned) };
231230
loop {
232-
match $crate::future::poll_in_task_cx(&mut pinned) {
233-
// FIXME(cramertj) prior to stabilizing await, we have to ensure that this
234-
// can't be used to create a generator on stable via `|| await!()`.
235-
$crate::task::Poll::Pending => yield,
236-
$crate::task::Poll::Ready(x) => break x,
231+
if let $crate::task::Poll::Ready(x) =
232+
$crate::future::poll_in_task_cx(unsafe {
233+
$crate::mem::PinMut::new_unchecked(&mut pinned)
234+
})
235+
{
236+
break x;
237237
}
238+
// FIXME(cramertj) prior to stabilizing await, we have to ensure that this
239+
// can't be used to create a generator on stable via `|| await!()`.
240+
yield
238241
}
239242
} }
240243
}

0 commit comments

Comments
 (0)