Skip to content

Remove unnecessary local in await! generator #52995

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/libstd/future.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
15 changes: 9 additions & 6 deletions src/libstd/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
} }
}
Expand Down