@@ -101,8 +101,12 @@ pub trait TypeVisitor<I: Interner>: Sized {
101101
102102 // The default region visitor is a no-op because `Region` is non-recursive
103103 // and has no `super_visit_with` method to call.
104- fn visit_region ( & mut self , _r : I :: Region ) -> Self :: Result {
105- Self :: Result :: output ( )
104+ fn visit_region ( & mut self , r : I :: Region ) -> Self :: Result {
105+ if let ty:: ReError ( guar) = r. kind ( ) {
106+ self . visit_error ( guar)
107+ } else {
108+ Self :: Result :: output ( )
109+ }
106110 }
107111
108112 fn visit_const ( & mut self , c : I :: Const ) -> Self :: Result {
@@ -116,6 +120,10 @@ pub trait TypeVisitor<I: Interner>: Sized {
116120 fn visit_clauses ( & mut self , p : I :: Clauses ) -> Self :: Result {
117121 p. super_visit_with ( self )
118122 }
123+
124+ fn visit_error ( & mut self , _guar : I :: ErrorGuaranteed ) -> Self :: Result {
125+ Self :: Result :: output ( )
126+ }
119127}
120128
121129///////////////////////////////////////////////////////////////////////////
@@ -547,27 +555,7 @@ struct HasErrorVisitor;
547555impl < I : Interner > TypeVisitor < I > for HasErrorVisitor {
548556 type Result = ControlFlow < I :: ErrorGuaranteed > ;
549557
550- fn visit_ty ( & mut self , t : <I as Interner >:: Ty ) -> Self :: Result {
551- if let ty:: Error ( guar) = t. kind ( ) {
552- ControlFlow :: Break ( guar)
553- } else {
554- t. super_visit_with ( self )
555- }
556- }
557-
558- fn visit_const ( & mut self , c : <I as Interner >:: Const ) -> Self :: Result {
559- if let ty:: ConstKind :: Error ( guar) = c. kind ( ) {
560- ControlFlow :: Break ( guar)
561- } else {
562- c. super_visit_with ( self )
563- }
564- }
565-
566- fn visit_region ( & mut self , r : <I as Interner >:: Region ) -> Self :: Result {
567- if let ty:: ReError ( guar) = r. kind ( ) {
568- ControlFlow :: Break ( guar)
569- } else {
570- ControlFlow :: Continue ( ( ) )
571- }
558+ fn visit_error ( & mut self , guar : <I as Interner >:: ErrorGuaranteed ) -> Self :: Result {
559+ ControlFlow :: Break ( guar)
572560 }
573561}
0 commit comments