This commit is contained in:
Jonas Schievink 2020-02-10 18:20:22 +01:00
parent f79a95a65d
commit b7fba973cb
2 changed files with 4 additions and 8 deletions

View File

@ -47,7 +47,7 @@ unsafe impl Sync for ResumeTy {}
#[inline]
pub const fn from_generator<T>(gen: T) -> impl Future<Output = T::Return>
where
T: Generator<ResumeTy, Yield = ()>
T: Generator<ResumeTy, Yield = ()>,
{
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
struct GenFuture<T: Generator<ResumeTy, Yield = ()>>(T);

View File

@ -675,11 +675,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
if let Some(task_context_hid) = self.task_context {
let lhs = self.expr_ident(span, task_context_ident, task_context_hid);
let assign = self.expr(
span,
hir::ExprKind::Assign(lhs, yield_expr, span),
AttrVec::new(),
);
let assign =
self.expr(span, hir::ExprKind::Assign(lhs, yield_expr, span), AttrVec::new());
self.stmt_expr(span, assign)
} else {
// Use of `await` outside of an async context. Return `yield_expr` so that we can
@ -688,8 +685,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
}
};
let loop_block =
self.block_all(span, arena_vec![self; inner_match_stmt, yield_stmt], None);
let loop_block = self.block_all(span, arena_vec![self; inner_match_stmt, yield_stmt], None);
// loop { ...; task_context = yield (); }
let loop_expr = self.arena.alloc(hir::Expr {