@@ -116,21 +116,9 @@ pub trait TypeFoldable<'tcx>: fmt::Debug + Clone {
116116pub trait TypeFolder < ' tcx > : Sized {
117117 fn tcx < ' a > ( & ' a self ) -> & ' a TyCtxt < ' tcx > ;
118118
119- /// Invoked by the `super_*` routines when we enter a region
120- /// binding level (for example, when entering a function
121- /// signature). This is used by clients that want to track the
122- /// Debruijn index nesting level.
123- fn enter_region_binder ( & mut self ) { }
124-
125- /// Invoked by the `super_*` routines when we exit a region
126- /// binding level. This is used by clients that want to
127- /// track the Debruijn index nesting level.
128- fn exit_region_binder ( & mut self ) { }
129-
130119 fn fold_binder < T > ( & mut self , t : & Binder < T > ) -> Binder < T >
131120 where T : TypeFoldable < ' tcx >
132121 {
133- // FIXME(#20526) this should replace `enter_region_binder`/`exit_region_binder`.
134122 t. super_fold_with ( self )
135123 }
136124
@@ -197,8 +185,9 @@ pub trait TypeFolder<'tcx> : Sized {
197185}
198186
199187pub trait TypeVisitor < ' tcx > : Sized {
200- fn enter_region_binder ( & mut self ) { }
201- fn exit_region_binder ( & mut self ) { }
188+ fn visit_binder < T : TypeFoldable < ' tcx > > ( & mut self , t : & Binder < T > ) -> bool {
189+ t. super_visit_with ( self )
190+ }
202191
203192 fn visit_ty ( & mut self , t : Ty < ' tcx > ) -> bool {
204193 t. super_visit_with ( self )
@@ -296,12 +285,11 @@ impl<'a, 'tcx> TypeFolder<'tcx> for RegionFolder<'a, 'tcx>
296285{
297286 fn tcx ( & self ) -> & TyCtxt < ' tcx > { self . tcx }
298287
299- fn enter_region_binder ( & mut self ) {
288+ fn fold_binder < T : TypeFoldable < ' tcx > > ( & mut self , t : & ty :: Binder < T > ) -> ty :: Binder < T > {
300289 self . current_depth += 1 ;
301- }
302-
303- fn exit_region_binder ( & mut self ) {
290+ let t = t. super_fold_with ( self ) ;
304291 self . current_depth -= 1 ;
292+ t
305293 }
306294
307295 fn fold_region ( & mut self , r : ty:: Region ) -> ty:: Region {
@@ -438,12 +426,11 @@ impl<'a, 'tcx> TypeFolder<'tcx> for RegionReplacer<'a, 'tcx>
438426{
439427 fn tcx ( & self ) -> & TyCtxt < ' tcx > { self . tcx }
440428
441- fn enter_region_binder ( & mut self ) {
429+ fn fold_binder < T : TypeFoldable < ' tcx > > ( & mut self , t : & ty :: Binder < T > ) -> ty :: Binder < T > {
442430 self . current_depth += 1 ;
443- }
444-
445- fn exit_region_binder ( & mut self ) {
431+ let t = t. super_fold_with ( self ) ;
446432 self . current_depth -= 1 ;
433+ t
447434 }
448435
449436 fn fold_ty ( & mut self , t : Ty < ' tcx > ) -> Ty < ' tcx > {
@@ -596,12 +583,11 @@ struct HasEscapingRegionsVisitor {
596583}
597584
598585impl < ' tcx > TypeVisitor < ' tcx > for HasEscapingRegionsVisitor {
599- fn enter_region_binder ( & mut self ) {
586+ fn visit_binder < T : TypeFoldable < ' tcx > > ( & mut self , t : & Binder < T > ) -> bool {
600587 self . depth += 1 ;
601- }
602-
603- fn exit_region_binder ( & mut self ) {
588+ let result = t. super_visit_with ( self ) ;
604589 self . depth -= 1 ;
590+ result
605591 }
606592
607593 fn visit_ty ( & mut self , t : Ty < ' tcx > ) -> bool {
0 commit comments