Rollup merge of #119239 - compiler-errors:yield-coercion, r=davidtwco
Remove unnecessary arm in `check_expr_yield` We always set up the `resume_yield_tys` for async blocks and fns, so this arm was unreachable.
This commit is contained in:
commit
893b6f6538
2 changed files with 1 additions and 16 deletions
|
@ -2110,12 +2110,6 @@ pub enum YieldSource {
|
||||||
Yield,
|
Yield,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl YieldSource {
|
|
||||||
pub fn is_await(&self) -> bool {
|
|
||||||
matches!(self, YieldSource::Await { .. })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl fmt::Display for YieldSource {
|
impl fmt::Display for YieldSource {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
f.write_str(match self {
|
f.write_str(match self {
|
||||||
|
|
|
@ -349,7 +349,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
ExprKind::Index(base, idx, brackets_span) => {
|
ExprKind::Index(base, idx, brackets_span) => {
|
||||||
self.check_expr_index(base, idx, expr, 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),
|
hir::ExprKind::Err(guar) => Ty::new_error(tcx, guar),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3162,7 +3162,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
&self,
|
&self,
|
||||||
value: &'tcx hir::Expr<'tcx>,
|
value: &'tcx hir::Expr<'tcx>,
|
||||||
expr: &'tcx hir::Expr<'tcx>,
|
expr: &'tcx hir::Expr<'tcx>,
|
||||||
src: &'tcx hir::YieldSource,
|
|
||||||
) -> Ty<'tcx> {
|
) -> Ty<'tcx> {
|
||||||
match self.resume_yield_tys {
|
match self.resume_yield_tys {
|
||||||
Some((resume_ty, yield_ty)) => {
|
Some((resume_ty, yield_ty)) => {
|
||||||
|
@ -3170,14 +3169,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
|
|
||||||
resume_ty
|
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.dcx().emit_err(YieldExprOutsideOfCoroutine { span: expr.span });
|
self.dcx().emit_err(YieldExprOutsideOfCoroutine { span: expr.span });
|
||||||
// Avoid expressions without types during writeback (#78653).
|
// Avoid expressions without types during writeback (#78653).
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue