Skip to content

Commit f5d240b

Browse files
committed
Wrap InferCtxt::universe in a cell
We'll need this in order to start tracking skolemizatoins here, and it's easier to update all the field accesses now rather than later.
1 parent ce64f9d commit f5d240b

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/librustc/infer/mod.rs

+9-5
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ pub struct InferCtxt<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
193193
/// part of the root universe. So this would only get incremented
194194
/// when we enter into a higher-ranked (`for<..>`) type or trait
195195
/// bound.
196-
pub universe: ty::UniverseIndex,
196+
universe: Cell<ty::UniverseIndex>,
197197
}
198198

199199
/// A map returned by `skolemize_late_bound_regions()` indicating the skolemized
@@ -466,7 +466,7 @@ impl<'a, 'gcx, 'tcx> InferCtxtBuilder<'a, 'gcx, 'tcx> {
466466
err_count_on_creation: tcx.sess.err_count(),
467467
in_snapshot: Cell::new(false),
468468
region_obligations: RefCell::new(vec![]),
469-
universe: ty::UniverseIndex::ROOT,
469+
universe: Cell::new(ty::UniverseIndex::ROOT),
470470
}))
471471
}
472472
}
@@ -853,7 +853,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
853853
pub fn next_ty_var_id(&self, diverging: bool, origin: TypeVariableOrigin) -> TyVid {
854854
self.type_variables
855855
.borrow_mut()
856-
.new_var(self.universe, diverging, origin)
856+
.new_var(self.universe(), diverging, origin)
857857
}
858858

859859
pub fn next_ty_var(&self, origin: TypeVariableOrigin) -> Ty<'tcx> {
@@ -885,7 +885,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
885885
pub fn next_region_var(&self, origin: RegionVariableOrigin)
886886
-> ty::Region<'tcx> {
887887
let region_var = self.borrow_region_constraints()
888-
.new_region_var(self.universe, origin);
888+
.new_region_var(self.universe(), origin);
889889
self.tcx.mk_region(ty::ReVar(region_var))
890890
}
891891

@@ -923,7 +923,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
923923
-> Ty<'tcx> {
924924
let ty_var_id = self.type_variables
925925
.borrow_mut()
926-
.new_var(self.universe,
926+
.new_var(self.universe(),
927927
false,
928928
TypeVariableOrigin::TypeParameterDefinition(span, def.name));
929929

@@ -1371,6 +1371,10 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
13711371
self.evaluation_cache.clear();
13721372
self.projection_cache.borrow_mut().clear();
13731373
}
1374+
1375+
fn universe(&self) -> ty::UniverseIndex {
1376+
self.universe.get()
1377+
}
13741378
}
13751379

13761380
impl<'a, 'gcx, 'tcx> TypeTrace<'tcx> {

0 commit comments

Comments
 (0)