@@ -446,15 +446,15 @@ pub(super) fn check_opaque_for_inheriting_lifetimes(
446446 struct ProhibitOpaqueVisitor < ' tcx > {
447447 opaque_identity_ty : Ty < ' tcx > ,
448448 generics : & ' tcx ty:: Generics ,
449- ty : Option < Ty < ' tcx > > ,
450449 } ;
451450
452451 impl < ' tcx > ty:: fold:: TypeVisitor < ' tcx > for ProhibitOpaqueVisitor < ' tcx > {
452+ type BreakTy = Option < Ty < ' tcx > > ;
453+
453454 fn visit_ty ( & mut self , t : Ty < ' tcx > ) -> ControlFlow < Self :: BreakTy > {
454455 debug ! ( "check_opaque_for_inheriting_lifetimes: (visit_ty) t={:?}" , t) ;
455456 if t != self . opaque_identity_ty && t. super_visit_with ( self ) . is_break ( ) {
456- self . ty = Some ( t) ;
457- return ControlFlow :: BREAK ;
457+ return ControlFlow :: Break ( Some ( t) ) ;
458458 }
459459 ControlFlow :: CONTINUE
460460 }
@@ -463,7 +463,7 @@ pub(super) fn check_opaque_for_inheriting_lifetimes(
463463 debug ! ( "check_opaque_for_inheriting_lifetimes: (visit_region) r={:?}" , r) ;
464464 if let RegionKind :: ReEarlyBound ( ty:: EarlyBoundRegion { index, .. } ) = r {
465465 if * index < self . generics . parent_count as u32 {
466- return ControlFlow :: BREAK ;
466+ return ControlFlow :: Break ( None ) ;
467467 } else {
468468 return ControlFlow :: CONTINUE ;
469469 }
@@ -494,18 +494,17 @@ pub(super) fn check_opaque_for_inheriting_lifetimes(
494494 InternalSubsts :: identity_for_item ( tcx, def_id. to_def_id ( ) ) ,
495495 ) ,
496496 generics : tcx. generics_of ( def_id) ,
497- ty : None ,
498497 } ;
499498 let prohibit_opaque = tcx
500499 . explicit_item_bounds ( def_id)
501500 . iter ( )
502- . any ( |( predicate, _) | predicate. visit_with ( & mut visitor) . is_break ( ) ) ;
501+ . try_for_each ( |( predicate, _) | predicate. visit_with ( & mut visitor) ) ;
503502 debug ! (
504503 "check_opaque_for_inheriting_lifetimes: prohibit_opaque={:?}, visitor={:?}" ,
505504 prohibit_opaque, visitor
506505 ) ;
507506
508- if prohibit_opaque {
507+ if let Some ( ty ) = prohibit_opaque. break_value ( ) {
509508 let is_async = match item. kind {
510509 ItemKind :: OpaqueTy ( hir:: OpaqueTy { origin, .. } ) => match origin {
511510 hir:: OpaqueTyOrigin :: AsyncFn => true ,
@@ -525,7 +524,7 @@ pub(super) fn check_opaque_for_inheriting_lifetimes(
525524
526525 if let Ok ( snippet) = tcx. sess . source_map ( ) . span_to_snippet ( span) {
527526 if snippet == "Self" {
528- if let Some ( ty) = visitor . ty {
527+ if let Some ( ty) = ty {
529528 err. span_suggestion (
530529 span,
531530 "consider spelling out the type instead" ,
0 commit comments