Skip to content

Commit 85d2b6e

Browse files
Remove unnecessary arm in check_expr_yield
1 parent d6d7a93 commit 85d2b6e

File tree

2 files changed

+1
-16
lines changed

2 files changed

+1
-16
lines changed

compiler/rustc_hir/src/hir.rs

-6
Original file line numberDiff line numberDiff line change
@@ -2071,12 +2071,6 @@ pub enum YieldSource {
20712071
Yield,
20722072
}
20732073

2074-
impl YieldSource {
2075-
pub fn is_await(&self) -> bool {
2076-
matches!(self, YieldSource::Await { .. })
2077-
}
2078-
}
2079-
20802074
impl fmt::Display for YieldSource {
20812075
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
20822076
f.write_str(match self {

compiler/rustc_hir_typeck/src/expr.rs

+1-10
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
349349
ExprKind::Index(base, idx, brackets_span) => {
350350
self.check_expr_index(base, idx, expr, brackets_span)
351351
}
352-
ExprKind::Yield(value, ref src) => self.check_expr_yield(value, expr, src),
352+
ExprKind::Yield(value, _) => self.check_expr_yield(value, expr),
353353
hir::ExprKind::Err(guar) => Ty::new_error(tcx, guar),
354354
}
355355
}
@@ -3155,22 +3155,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
31553155
&self,
31563156
value: &'tcx hir::Expr<'tcx>,
31573157
expr: &'tcx hir::Expr<'tcx>,
3158-
src: &'tcx hir::YieldSource,
31593158
) -> Ty<'tcx> {
31603159
match self.resume_yield_tys {
31613160
Some((resume_ty, yield_ty)) => {
31623161
self.check_expr_coercible_to_type(value, yield_ty, None);
31633162

31643163
resume_ty
31653164
}
3166-
// Given that this `yield` expression was generated as a result of lowering a `.await`,
3167-
// we know that the yield type must be `()`; however, the context won't contain this
3168-
// information. Hence, we check the source of the yield expression here and check its
3169-
// value's type against `()` (this check should always hold).
3170-
None if src.is_await() => {
3171-
self.check_expr_coercible_to_type(value, Ty::new_unit(self.tcx), None);
3172-
Ty::new_unit(self.tcx)
3173-
}
31743165
_ => {
31753166
self.tcx.sess.emit_err(YieldExprOutsideOfCoroutine { span: expr.span });
31763167
// Avoid expressions without types during writeback (#78653).

0 commit comments

Comments
 (0)