@@ -931,14 +931,22 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
931
931
}
932
932
933
933
/// Create a fresh region variable with the next available index.
934
- ///
935
- /// # Parameters
936
- ///
937
- /// - `origin`: information about why we created this variable, for use
938
- /// during diagnostics / error-reporting.
934
+ /// The variable will be created in the maximum universe created
935
+ /// thus far, allowing it to name any region created thus far.
939
936
pub fn next_region_var ( & self , origin : RegionVariableOrigin ) -> ty:: Region < ' tcx > {
937
+ self . next_region_var_in_universe ( origin, self . universe ( ) )
938
+ }
939
+
940
+ /// Create a fresh region variable with the next available index
941
+ /// in the given universe; typically, you can use
942
+ /// `next_region_var` and just use the maximal universe.
943
+ pub fn next_region_var_in_universe (
944
+ & self ,
945
+ origin : RegionVariableOrigin ,
946
+ universe : ty:: UniverseIndex ,
947
+ ) -> ty:: Region < ' tcx > {
940
948
let region_var = self . borrow_region_constraints ( )
941
- . new_region_var ( self . universe ( ) , origin) ;
949
+ . new_region_var ( universe, origin) ;
942
950
self . tcx . mk_region ( ty:: ReVar ( region_var) )
943
951
}
944
952
@@ -952,6 +960,15 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
952
960
self . next_region_var ( RegionVariableOrigin :: NLL ( origin) )
953
961
}
954
962
963
+ /// Just a convenient wrapper of `next_region_var` for using during NLL.
964
+ pub fn next_nll_region_var_in_universe (
965
+ & self ,
966
+ origin : NLLRegionVariableOrigin ,
967
+ universe : ty:: UniverseIndex ,
968
+ ) -> ty:: Region < ' tcx > {
969
+ self . next_region_var_in_universe ( RegionVariableOrigin :: NLL ( origin) , universe)
970
+ }
971
+
955
972
pub fn var_for_def ( & self , span : Span , param : & ty:: GenericParamDef ) -> Kind < ' tcx > {
956
973
match param. kind {
957
974
GenericParamDefKind :: Lifetime => {
0 commit comments