diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2018-08-29 14:33:38 -0400 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2018-09-09 14:14:41 -0400 |
| commit | 5c016f4cb51e79a6ec3cae25f5d6c11ed92fe6da (patch) | |
| tree | bca94dbe8351bee07292fccfc0d75e96b090abc1 | |
| parent | 3f600431ec2126f459e97cad22fbf2fbe792f308 (diff) | |
| download | rust-5c016f4cb51e79a6ec3cae25f5d6c11ed92fe6da.tar.gz rust-5c016f4cb51e79a6ec3cae25f5d6c11ed92fe6da.zip | |
add ability to create region vars with explicit universe
| -rw-r--r-- | src/librustc/infer/mod.rs | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/src/librustc/infer/mod.rs b/src/librustc/infer/mod.rs index 66aa7d6d8ea..e628a3458f9 100644 --- a/src/librustc/infer/mod.rs +++ b/src/librustc/infer/mod.rs @@ -931,14 +931,22 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { } /// Create a fresh region variable with the next available index. - /// - /// # Parameters - /// - /// - `origin`: information about why we created this variable, for use - /// during diagnostics / error-reporting. + /// The variable will be created in the maximum universe created + /// thus far, allowing it to name any region created thus far. pub fn next_region_var(&self, origin: RegionVariableOrigin) -> ty::Region<'tcx> { + self.next_region_var_in_universe(origin, self.universe()) + } + + /// Create a fresh region variable with the next available index + /// in the given universe; typically, you can use + /// `next_region_var` and just use the maximal universe. + pub fn next_region_var_in_universe( + &self, + origin: RegionVariableOrigin, + universe: ty::UniverseIndex, + ) -> ty::Region<'tcx> { let region_var = self.borrow_region_constraints() - .new_region_var(self.universe(), origin); + .new_region_var(universe, origin); self.tcx.mk_region(ty::ReVar(region_var)) } @@ -952,6 +960,15 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { self.next_region_var(RegionVariableOrigin::NLL(origin)) } + /// Just a convenient wrapper of `next_region_var` for using during NLL. + pub fn next_nll_region_var_in_universe( + &self, + origin: NLLRegionVariableOrigin, + universe: ty::UniverseIndex, + ) -> ty::Region<'tcx> { + self.next_region_var_in_universe(RegionVariableOrigin::NLL(origin), universe) + } + pub fn var_for_def(&self, span: Span, param: &ty::GenericParamDef) -> Kind<'tcx> { match param.kind { GenericParamDefKind::Lifetime => { |
