@@ -101,8 +101,12 @@ pub trait TypeVisitor<I: Interner>: Sized {
101
101
102
102
// The default region visitor is a no-op because `Region` is non-recursive
103
103
// 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
+ }
106
110
}
107
111
108
112
fn visit_const ( & mut self , c : I :: Const ) -> Self :: Result {
@@ -116,6 +120,10 @@ pub trait TypeVisitor<I: Interner>: Sized {
116
120
fn visit_clauses ( & mut self , p : I :: Clauses ) -> Self :: Result {
117
121
p. super_visit_with ( self )
118
122
}
123
+
124
+ fn visit_error ( & mut self , _guar : I :: ErrorGuaranteed ) -> Self :: Result {
125
+ Self :: Result :: output ( )
126
+ }
119
127
}
120
128
121
129
///////////////////////////////////////////////////////////////////////////
@@ -547,27 +555,7 @@ struct HasErrorVisitor;
547
555
impl < I : Interner > TypeVisitor < I > for HasErrorVisitor {
548
556
type Result = ControlFlow < I :: ErrorGuaranteed > ;
549
557
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)
572
560
}
573
561
}
0 commit comments