@@ -1509,7 +1509,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
1509
1509
1510
1510
impl < ' tcx > ty:: fold:: TypeVisitor < ' tcx > for OpaqueTypesVisitor < ' tcx > {
1511
1511
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) {
1513
1513
let span = self . tcx . def_span ( def_id) ;
1514
1514
// Avoid cluttering the output when the "found" and error span overlap:
1515
1515
//
@@ -1582,11 +1582,11 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
1582
1582
} ;
1583
1583
if let Some ( ( expected, found) ) = expected_found {
1584
1584
let expected_label = match exp_found {
1585
- Mismatch :: Variable ( ef) => ef. expected . prefix_string ( ) ,
1585
+ Mismatch :: Variable ( ef) => ef. expected . prefix_string ( self . tcx ) ,
1586
1586
Mismatch :: Fixed ( s) => s. into ( ) ,
1587
1587
} ;
1588
1588
let found_label = match exp_found {
1589
- Mismatch :: Variable ( ef) => ef. found . prefix_string ( ) ,
1589
+ Mismatch :: Variable ( ef) => ef. found . prefix_string ( self . tcx ) ,
1590
1590
Mismatch :: Fixed ( s) => s. into ( ) ,
1591
1591
} ;
1592
1592
let exp_found = match exp_found {
@@ -2436,7 +2436,7 @@ impl<'tcx> ObligationCauseExt<'tcx> for ObligationCause<'tcx> {
2436
2436
pub enum TyCategory {
2437
2437
Closure ,
2438
2438
Opaque ,
2439
- Generator ,
2439
+ Generator ( hir :: GeneratorKind ) ,
2440
2440
Foreign ,
2441
2441
}
2442
2442
@@ -2445,16 +2445,18 @@ impl TyCategory {
2445
2445
match self {
2446
2446
Self :: Closure => "closure" ,
2447
2447
Self :: Opaque => "opaque type" ,
2448
- Self :: Generator => "generator" ,
2448
+ Self :: Generator ( gk ) => gk . descr ( ) ,
2449
2449
Self :: Foreign => "foreign type" ,
2450
2450
}
2451
2451
}
2452
2452
2453
- pub fn from_ty ( ty : Ty < ' _ > ) -> Option < ( Self , DefId ) > {
2453
+ pub fn from_ty ( tcx : TyCtxt < ' _ > , ty : Ty < ' _ > ) -> Option < ( Self , DefId ) > {
2454
2454
match * ty. kind ( ) {
2455
2455
ty:: Closure ( def_id, _) => Some ( ( Self :: Closure , def_id) ) ,
2456
2456
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
+ }
2458
2460
ty:: Foreign ( def_id) => Some ( ( Self :: Foreign , def_id) ) ,
2459
2461
_ => None ,
2460
2462
}
0 commit comments