@@ -1509,7 +1509,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
15091509
15101510 impl < ' tcx > ty:: fold:: TypeVisitor < ' tcx > for OpaqueTypesVisitor < ' tcx > {
15111511 fn visit_ty ( & mut self , t : Ty < ' tcx > ) -> ControlFlow < Self :: BreakTy > {
1512- if let Some ( ( kind, def_id) ) = TyCategory :: from_ty ( t) {
1512+ if let Some ( ( kind, def_id) ) = TyCategory :: from_ty ( self . tcx , t) {
15131513 let span = self . tcx . def_span ( def_id) ;
15141514 // Avoid cluttering the output when the "found" and error span overlap:
15151515 //
@@ -1582,11 +1582,11 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
15821582 } ;
15831583 if let Some ( ( expected, found) ) = expected_found {
15841584 let expected_label = match exp_found {
1585- Mismatch :: Variable ( ef) => ef. expected . prefix_string ( ) ,
1585+ Mismatch :: Variable ( ef) => ef. expected . prefix_string ( self . tcx ) ,
15861586 Mismatch :: Fixed ( s) => s. into ( ) ,
15871587 } ;
15881588 let found_label = match exp_found {
1589- Mismatch :: Variable ( ef) => ef. found . prefix_string ( ) ,
1589+ Mismatch :: Variable ( ef) => ef. found . prefix_string ( self . tcx ) ,
15901590 Mismatch :: Fixed ( s) => s. into ( ) ,
15911591 } ;
15921592 let exp_found = match exp_found {
@@ -2436,7 +2436,7 @@ impl<'tcx> ObligationCauseExt<'tcx> for ObligationCause<'tcx> {
24362436pub enum TyCategory {
24372437 Closure ,
24382438 Opaque ,
2439- Generator ,
2439+ Generator ( hir :: GeneratorKind ) ,
24402440 Foreign ,
24412441}
24422442
@@ -2445,16 +2445,18 @@ impl TyCategory {
24452445 match self {
24462446 Self :: Closure => "closure" ,
24472447 Self :: Opaque => "opaque type" ,
2448- Self :: Generator => "generator" ,
2448+ Self :: Generator ( gk ) => gk . descr ( ) ,
24492449 Self :: Foreign => "foreign type" ,
24502450 }
24512451 }
24522452
2453- pub fn from_ty ( ty : Ty < ' _ > ) -> Option < ( Self , DefId ) > {
2453+ pub fn from_ty ( tcx : TyCtxt < ' _ > , ty : Ty < ' _ > ) -> Option < ( Self , DefId ) > {
24542454 match * ty. kind ( ) {
24552455 ty:: Closure ( def_id, _) => Some ( ( Self :: Closure , def_id) ) ,
24562456 ty:: Opaque ( def_id, _) => Some ( ( Self :: Opaque , def_id) ) ,
2457- ty:: Generator ( def_id, ..) => Some ( ( Self :: Generator , def_id) ) ,
2457+ ty:: Generator ( def_id, ..) => {
2458+ Some ( ( Self :: Generator ( tcx. generator_kind ( def_id) . unwrap ( ) ) , def_id) )
2459+ }
24582460 ty:: Foreign ( def_id) => Some ( ( Self :: Foreign , def_id) ) ,
24592461 _ => None ,
24602462 }
0 commit comments