@@ -37,9 +37,7 @@ use super::{
3737use crate :: error_reporting:: TypeErrCtxt ;
3838use crate :: error_reporting:: infer:: TyCategory ;
3939use crate :: error_reporting:: traits:: report_dyn_incompatibility;
40- use crate :: errors:: {
41- AsyncClosureNotFn , ClosureFnMutLabel , ClosureFnOnceLabel , ClosureKindMismatch ,
42- } ;
40+ use crate :: errors:: { ClosureFnMutLabel , ClosureFnOnceLabel , ClosureKindMismatch , CoroClosureNotFn } ;
4341use crate :: infer:: { self , InferCtxt , InferCtxtExt as _} ;
4442use crate :: traits:: query:: evaluate_obligation:: InferCtxtExt as _;
4543use crate :: traits:: {
@@ -887,15 +885,16 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
887885 }
888886
889887 // If the closure has captures, then perhaps the reason that the trait
890- // is unimplemented is because async closures don't implement `Fn`/`FnMut`
888+ // is unimplemented is because coro closures don't implement `Fn`/`FnMut`
891889 // if they have captures.
892890 if let Some ( by_ref_captures) = by_ref_captures
893891 && let ty:: FnPtr ( sig_tys, _) = by_ref_captures. kind ( )
894892 && !sig_tys. skip_binder ( ) . output ( ) . is_unit ( )
895893 {
896- let mut err = self . dcx ( ) . create_err ( AsyncClosureNotFn {
894+ let mut err = self . dcx ( ) . create_err ( CoroClosureNotFn {
897895 span : self . tcx . def_span ( closure_def_id) ,
898896 kind : expected_kind. as_str ( ) ,
897+ coro_kind : self . tcx . coroutine_kind ( closure_def_id) . unwrap ( ) . to_string ( ) ,
899898 } ) ;
900899 self . note_obligation_cause ( & mut err, & obligation) ;
901900 return Some ( err. emit ( ) ) ;
0 commit comments