@@ -540,6 +540,7 @@ impl<'tcx> TyCtxt<'tcx> {
540
540
expanded_cache : FxHashMap :: default ( ) ,
541
541
primary_def_id : Some ( def_id) ,
542
542
found_recursion : false ,
543
+ found_any_recursion : false ,
543
544
check_recursion : true ,
544
545
tcx : self ,
545
546
} ;
@@ -560,6 +561,7 @@ struct OpaqueTypeExpander<'tcx> {
560
561
expanded_cache : FxHashMap < ( DefId , SubstsRef < ' tcx > ) , Ty < ' tcx > > ,
561
562
primary_def_id : Option < DefId > ,
562
563
found_recursion : bool ,
564
+ found_any_recursion : bool ,
563
565
/// Whether or not to check for recursive opaque types.
564
566
/// This is `true` when we're explicitly checking for opaque type
565
567
/// recursion, and 'false' otherwise to avoid unnecessary work.
@@ -569,7 +571,7 @@ struct OpaqueTypeExpander<'tcx> {
569
571
570
572
impl < ' tcx > OpaqueTypeExpander < ' tcx > {
571
573
fn expand_opaque_ty ( & mut self , def_id : DefId , substs : SubstsRef < ' tcx > ) -> Option < Ty < ' tcx > > {
572
- if self . found_recursion {
574
+ if self . found_any_recursion {
573
575
return None ;
574
576
}
575
577
let substs = substs. fold_with ( self ) ;
@@ -591,6 +593,7 @@ impl<'tcx> OpaqueTypeExpander<'tcx> {
591
593
} else {
592
594
// If another opaque type that we contain is recursive, then it
593
595
// will report the error, so we don't have to.
596
+ self . found_any_recursion = true ;
594
597
self . found_recursion = def_id == * self . primary_def_id . as_ref ( ) . unwrap ( ) ;
595
598
None
596
599
}
@@ -1078,6 +1081,7 @@ pub fn normalize_opaque_types(
1078
1081
expanded_cache : FxHashMap :: default ( ) ,
1079
1082
primary_def_id : None ,
1080
1083
found_recursion : false ,
1084
+ found_any_recursion : false ,
1081
1085
check_recursion : false ,
1082
1086
tcx,
1083
1087
} ;
0 commit comments