@@ -25,7 +25,7 @@ use middle::lang_items;
25
25
use mir:: tcx:: LvalueTy ;
26
26
use ty:: subst:: { Kind , Subst , Substs } ;
27
27
use ty:: { TyVid , IntVid , FloatVid } ;
28
- use ty:: { self , Ty , TyCtxt } ;
28
+ use ty:: { self , RegionVid , Ty , TyCtxt } ;
29
29
use ty:: error:: { ExpectedFound , TypeError , UnconstrainedNumeric } ;
30
30
use ty:: fold:: { TypeFoldable , TypeFolder , TypeVisitor } ;
31
31
use ty:: relate:: RelateResult ;
@@ -1166,6 +1166,21 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
1166
1166
self . borrow_region_constraints ( ) . take_and_reset_data ( )
1167
1167
}
1168
1168
1169
+ /// Returns the number of region variables created thus far.
1170
+ pub fn num_region_vars ( & self ) -> usize {
1171
+ self . borrow_region_constraints ( ) . var_origins ( ) . len ( )
1172
+ }
1173
+
1174
+ /// Returns an iterator over all region variables created thus far.
1175
+ pub fn all_region_vars ( & self ) -> impl Iterator < Item = RegionVid > {
1176
+ self . borrow_region_constraints ( ) . var_origins ( ) . indices ( )
1177
+ }
1178
+
1179
+ /// Returns the origin of a given region variable.
1180
+ pub fn region_var_origin ( & self , var : RegionVid ) -> RegionVariableOrigin {
1181
+ self . borrow_region_constraints ( ) . var_origins ( ) [ var] . clone ( )
1182
+ }
1183
+
1169
1184
pub fn ty_to_string ( & self , t : Ty < ' tcx > ) -> String {
1170
1185
self . resolve_type_vars_if_possible ( & t) . to_string ( )
1171
1186
}
0 commit comments