@@ -2,6 +2,7 @@ use crate::ty::{self, Binder, Ty, TyCtxt, TypeFlags};
2
2
3
3
use rustc_data_structures:: fx:: FxHashSet ;
4
4
use rustc_data_structures:: sso:: SsoHashSet ;
5
+ use rustc_type_ir:: fold:: TypeFoldable ;
5
6
use std:: ops:: ControlFlow ;
6
7
7
8
pub use rustc_type_ir:: visit:: { TypeSuperVisitable , TypeVisitable , TypeVisitableExt , TypeVisitor } ;
@@ -109,36 +110,37 @@ impl<'tcx> TyCtxt<'tcx> {
109
110
/// variables will also be equated.
110
111
pub fn collect_constrained_late_bound_regions < T > (
111
112
self ,
112
- value : & Binder < ' tcx , T > ,
113
+ value : Binder < ' tcx , T > ,
113
114
) -> FxHashSet < ty:: BoundRegionKind >
114
115
where
115
- T : TypeVisitable < TyCtxt < ' tcx > > ,
116
+ T : TypeFoldable < TyCtxt < ' tcx > > ,
116
117
{
117
118
self . collect_late_bound_regions ( value, true )
118
119
}
119
120
120
121
/// Returns a set of all late-bound regions that appear in `value` anywhere.
121
122
pub fn collect_referenced_late_bound_regions < T > (
122
123
self ,
123
- value : & Binder < ' tcx , T > ,
124
+ value : Binder < ' tcx , T > ,
124
125
) -> FxHashSet < ty:: BoundRegionKind >
125
126
where
126
- T : TypeVisitable < TyCtxt < ' tcx > > ,
127
+ T : TypeFoldable < TyCtxt < ' tcx > > ,
127
128
{
128
129
self . collect_late_bound_regions ( value, false )
129
130
}
130
131
131
132
fn collect_late_bound_regions < T > (
132
133
self ,
133
- value : & Binder < ' tcx , T > ,
134
+ value : Binder < ' tcx , T > ,
134
135
just_constrained : bool ,
135
136
) -> FxHashSet < ty:: BoundRegionKind >
136
137
where
137
- T : TypeVisitable < TyCtxt < ' tcx > > ,
138
+ T : TypeFoldable < TyCtxt < ' tcx > > ,
138
139
{
139
- let mut collector = LateBoundRegionsCollector :: new ( self , just_constrained) ;
140
+ let mut collector = LateBoundRegionsCollector :: new ( just_constrained) ;
141
+ let value = value. skip_binder ( ) ;
140
142
let value = if just_constrained { self . expand_weak_alias_tys ( value) } else { value } ;
141
- let result = value. as_ref ( ) . skip_binder ( ) . visit_with ( & mut collector) ;
143
+ let result = value. visit_with ( & mut collector) ;
142
144
assert ! ( result. is_continue( ) ) ; // should never have stopped early
143
145
collector. regions
144
146
}
0 commit comments