diff --git a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs index caa566e79e29b..cd5e008dd8c27 100644 --- a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs @@ -274,7 +274,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> { let ty = used_place.ty(self.body, self.infcx.tcx).ty; let needs_note = match ty.kind() { - ty::Closure(id, _) => { + ty::Closure(id, _) | ty::CoroutineClosure(id, _) => { self.infcx.tcx.closure_kind_origin(id.expect_local()).is_none() } _ => true, diff --git a/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs b/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs index a4025f28a5511..e2304e3fb5187 100644 --- a/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs @@ -465,7 +465,9 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> { if suggest { self.construct_mut_suggestion_for_local_binding_patterns(&mut err, local); let tcx = self.infcx.tcx; - if let ty::Closure(id, _) = *the_place_err.ty(self.body, tcx).ty.kind() { + if let ty::Closure(id, _) | ty::CoroutineClosure(id, _) = + *the_place_err.ty(self.body, tcx).ty.kind() + { self.show_mutating_upvar(tcx, id.expect_local(), the_place_err, &mut err); } } @@ -519,7 +521,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> { let tcx = self.infcx.tcx; if let ty::Ref(_, ty, Mutability::Mut) = the_place_err.ty(self.body, tcx).ty.kind() - && let ty::Closure(id, _) = *ty.kind() + && let ty::Closure(id, _) | ty::CoroutineClosure(id, _) = *ty.kind() { self.show_mutating_upvar(tcx, id.expect_local(), the_place_err, &mut err); }