@@ -67,7 +67,7 @@ pub trait TypeVisitable<I: Interner>: fmt::Debug {
6767 /// each field/element.
6868 ///
6969 /// For types of interest (such as `Ty`), the implementation of this method
70- /// that calls a visitor method specifically for that type (such as
70+ /// calls a visitor method specifically for that type (such as
7171 /// `V::visit_ty`). This is where control transfers from `TypeVisitable` to
7272 /// `TypeVisitor`.
7373 fn visit_with < V : TypeVisitor < I > > ( & self , visitor : & mut V ) -> V :: Result ;
@@ -102,8 +102,8 @@ pub trait TypeVisitor<I: Interner>: Sized {
102102 t. super_visit_with ( self )
103103 }
104104
105- // The default region visitor is a no-op because `Region` is non-recursive
106- // and has no `super_visit_with` method to call.
105+ // `Region` is non-recursive so the default region visitor has no
106+ // `super_visit_with` method to call.
107107 fn visit_region ( & mut self , r : I :: Region ) -> Self :: Result {
108108 if let ty:: ReError ( guar) = r. kind ( ) {
109109 self . visit_error ( guar)
@@ -251,10 +251,10 @@ pub trait TypeVisitableExt<I: Interner>: TypeVisitable<I> {
251251 self . has_vars_bound_at_or_above ( binder. shifted_in ( 1 ) )
252252 }
253253
254- /// Return `true` if this type has regions that are not a part of the type.
255- /// For example, `for<'a> fn(&'a i32)` return `false`, while `fn(&'a i32)`
256- /// would return ` true`. The latter can occur when traversing through the
257- /// former.
254+ /// Returns `true` if this type has regions that are not a part of the
255+ /// type. For example, given a `for<'a> fn(&'a i32)` this function returns
256+ /// `false`, while given a `fn(&'a i32)` it returns ` true`. The latter can
257+ /// occur when traversing through the former.
258258 ///
259259 /// See [`HasEscapingVarsVisitor`] for more information.
260260 fn has_escaping_bound_vars ( & self ) -> bool {
@@ -285,6 +285,10 @@ pub trait TypeVisitableExt<I: Interner>: TypeVisitable<I> {
285285 self . has_type_flags ( TypeFlags :: HAS_PARAM - TypeFlags :: HAS_RE_PARAM )
286286 }
287287
288+ fn has_regions ( & self ) -> bool {
289+ self . has_type_flags ( TypeFlags :: HAS_REGIONS )
290+ }
291+
288292 fn has_infer_regions ( & self ) -> bool {
289293 self . has_type_flags ( TypeFlags :: HAS_RE_INFER )
290294 }
@@ -363,13 +367,12 @@ pub trait TypeVisitableExt<I: Interner>: TypeVisitable<I> {
363367
364368impl < I : Interner , T : TypeVisitable < I > > TypeVisitableExt < I > for T {
365369 fn has_type_flags ( & self , flags : TypeFlags ) -> bool {
366- let res =
367- self . visit_with ( & mut HasTypeFlagsVisitor { flags } ) == ControlFlow :: Break ( FoundFlags ) ;
368- res
370+ self . visit_with ( & mut HasTypeFlagsVisitor { flags } ) == ControlFlow :: Break ( FoundFlags )
369371 }
370372
371373 fn has_vars_bound_at_or_above ( & self , binder : ty:: DebruijnIndex ) -> bool {
372- self . visit_with ( & mut HasEscapingVarsVisitor { outer_index : binder } ) . is_break ( )
374+ self . visit_with ( & mut HasEscapingVarsVisitor { outer_index : binder } )
375+ == ControlFlow :: Break ( FoundEscapingVars )
373376 }
374377
375378 fn error_reported ( & self ) -> Result < ( ) , I :: ErrorGuaranteed > {
@@ -438,8 +441,7 @@ impl<I: Interner> TypeVisitor<I> for HasTypeFlagsVisitor {
438441 #[ inline]
439442 fn visit_ty ( & mut self , t : I :: Ty ) -> Self :: Result {
440443 // Note: no `super_visit_with` call.
441- let flags = t. flags ( ) ;
442- if flags. intersects ( self . flags ) {
444+ if t. flags ( ) . intersects ( self . flags ) {
443445 ControlFlow :: Break ( FoundFlags )
444446 } else {
445447 ControlFlow :: Continue ( ( ) )
@@ -449,8 +451,7 @@ impl<I: Interner> TypeVisitor<I> for HasTypeFlagsVisitor {
449451 #[ inline]
450452 fn visit_region ( & mut self , r : I :: Region ) -> Self :: Result {
451453 // Note: no `super_visit_with` call, as usual for `Region`.
452- let flags = r. flags ( ) ;
453- if flags. intersects ( self . flags ) {
454+ if r. flags ( ) . intersects ( self . flags ) {
454455 ControlFlow :: Break ( FoundFlags )
455456 } else {
456457 ControlFlow :: Continue ( ( ) )
@@ -571,7 +572,7 @@ impl<I: Interner> TypeVisitor<I> for HasEscapingVarsVisitor {
571572 // `outer_index`, that means that `ct` contains some content
572573 // bound at `outer_index` or above (because
573574 // `outer_exclusive_binder` is always 1 higher than the
574- // content in `t `). Therefore, `t ` has some escaping vars.
575+ // content in `ct `). Therefore, `ct ` has some escaping vars.
575576 if ct. outer_exclusive_binder ( ) > self . outer_index {
576577 ControlFlow :: Break ( FoundEscapingVars )
577578 } else {
0 commit comments