Skip to content

Commit afb4010

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 5aca3b9 commit afb4010

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/librustc/infer/mod.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ pub struct InferCtxt<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
191191
/// part of the root universe. So this would only get incremented
192192
/// when we enter into a higher-ranked (`for<..>`) type or trait
193193
/// bound.
194-
pub universe: ty::UniverseIndex,
194+
universe: Cell<ty::UniverseIndex>,
195195
}
196196

197197
/// A map returned by `skolemize_late_bound_regions()` indicating the skolemized
@@ -464,7 +464,7 @@ impl<'a, 'gcx, 'tcx> InferCtxtBuilder<'a, 'gcx, 'tcx> {
464464
err_count_on_creation: tcx.sess.err_count(),
465465
in_snapshot: Cell::new(false),
466466
region_obligations: RefCell::new(vec![]),
467-
universe: ty::UniverseIndex::ROOT,
467+
universe: Cell::new(ty::UniverseIndex::ROOT),
468468
}))
469469
}
470470
}
@@ -850,7 +850,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
850850
pub fn next_ty_var_id(&self, diverging: bool, origin: TypeVariableOrigin) -> TyVid {
851851
self.type_variables
852852
.borrow_mut()
853-
.new_var(self.universe, diverging, origin)
853+
.new_var(self.universe(), diverging, origin)
854854
}
855855

856856
pub fn next_ty_var(&self, origin: TypeVariableOrigin) -> Ty<'tcx> {
@@ -882,7 +882,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
882882
pub fn next_region_var(&self, origin: RegionVariableOrigin)
883883
-> ty::Region<'tcx> {
884884
let region_var = self.borrow_region_constraints()
885-
.new_region_var(self.universe, origin);
885+
.new_region_var(self.universe(), origin);
886886
self.tcx.mk_region(ty::ReVar(region_var))
887887
}
888888

@@ -920,7 +920,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
920920
-> Ty<'tcx> {
921921
let ty_var_id = self.type_variables
922922
.borrow_mut()
923-
.new_var(self.universe,
923+
.new_var(self.universe(),
924924
false,
925925
TypeVariableOrigin::TypeParameterDefinition(span, def.name));
926926

@@ -1335,6 +1335,10 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
13351335
self.evaluation_cache.clear();
13361336
self.projection_cache.borrow_mut().clear();
13371337
}
1338+
1339+
fn universe(&self) -> ty::UniverseIndex {
1340+
self.universe.get()
1341+
}
13381342
}
13391343

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

0 commit comments

Comments
 (0)