From 85d2b6e3f3c39489784b2f7ca54b33458a7b4da8 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Sat, 23 Dec 2023 04:10:27 +0000 Subject: [PATCH] Remove unnecessary arm in check_expr_yield --- compiler/rustc_hir/src/hir.rs | 6 ------ compiler/rustc_hir_typeck/src/expr.rs | 11 +---------- 2 files changed, 1 insertion(+), 16 deletions(-) diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs index 26430dcf965fe..f5389d15832c1 100644 --- a/compiler/rustc_hir/src/hir.rs +++ b/compiler/rustc_hir/src/hir.rs @@ -2071,12 +2071,6 @@ pub enum YieldSource { Yield, } -impl YieldSource { - pub fn is_await(&self) -> bool { - matches!(self, YieldSource::Await { .. }) - } -} - impl fmt::Display for YieldSource { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str(match self { diff --git a/compiler/rustc_hir_typeck/src/expr.rs b/compiler/rustc_hir_typeck/src/expr.rs index 5d5b5f39ccfc8..f99abfaf5db6d 100644 --- a/compiler/rustc_hir_typeck/src/expr.rs +++ b/compiler/rustc_hir_typeck/src/expr.rs @@ -349,7 +349,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ExprKind::Index(base, idx, brackets_span) => { self.check_expr_index(base, idx, expr, brackets_span) } - ExprKind::Yield(value, ref src) => self.check_expr_yield(value, expr, src), + ExprKind::Yield(value, _) => self.check_expr_yield(value, expr), hir::ExprKind::Err(guar) => Ty::new_error(tcx, guar), } } @@ -3155,7 +3155,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { &self, value: &'tcx hir::Expr<'tcx>, expr: &'tcx hir::Expr<'tcx>, - src: &'tcx hir::YieldSource, ) -> Ty<'tcx> { match self.resume_yield_tys { Some((resume_ty, yield_ty)) => { @@ -3163,14 +3162,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { resume_ty } - // Given that this `yield` expression was generated as a result of lowering a `.await`, - // we know that the yield type must be `()`; however, the context won't contain this - // information. Hence, we check the source of the yield expression here and check its - // value's type against `()` (this check should always hold). - None if src.is_await() => { - self.check_expr_coercible_to_type(value, Ty::new_unit(self.tcx), None); - Ty::new_unit(self.tcx) - } _ => { self.tcx.sess.emit_err(YieldExprOutsideOfCoroutine { span: expr.span }); // Avoid expressions without types during writeback (#78653).