Skip to content

Commit 57a593f

Browse files
nikomatsakissgrif
authored andcommitted
store type values in the unification table directly
1 parent c7953bb commit 57a593f

File tree

5 files changed

+176
-98
lines changed

5 files changed

+176
-98
lines changed

src/librustc/infer/combine.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ impl<'cx, 'gcx, 'tcx> TypeRelation<'cx, 'gcx, 'tcx> for Generalizer<'cx, 'gcx, '
402402
// `vid` are related via subtyping.
403403
return Err(TypeError::CyclicTy(self.root_ty));
404404
} else {
405-
match variables.probe_root(vid) {
405+
match variables.probe(vid) {
406406
Some(u) => {
407407
drop(variables);
408408
self.relate(&u, &u)
@@ -423,7 +423,7 @@ impl<'cx, 'gcx, 'tcx> TypeRelation<'cx, 'gcx, 'tcx> for Generalizer<'cx, 'gcx, '
423423
ty::Covariant | ty::Contravariant => (),
424424
}
425425

426-
let origin = variables.origin(vid);
426+
let origin = *variables.var_origin(vid);
427427
let new_var_id = variables.new_var(false, origin);
428428
let u = self.tcx().mk_var(new_var_id);
429429
debug!("generalize: replacing original vid={:?} with new={:?}",

src/librustc/infer/higher_ranked/mod.rs

+8-9
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ impl<'a, 'gcx, 'tcx> CombineFields<'a, 'gcx, 'tcx> {
244244

245245
fn generalize_region<'a, 'gcx, 'tcx>(infcx: &InferCtxt<'a, 'gcx, 'tcx>,
246246
span: Span,
247-
snapshot: &CombinedSnapshot,
247+
snapshot: &CombinedSnapshot<'a, 'tcx>,
248248
debruijn: ty::DebruijnIndex,
249249
new_vars: &[ty::RegionVid],
250250
a_map: &BTreeMap<ty::BoundRegion, ty::Region<'tcx>>,
@@ -340,7 +340,7 @@ impl<'a, 'gcx, 'tcx> CombineFields<'a, 'gcx, 'tcx> {
340340

341341
fn generalize_region<'a, 'gcx, 'tcx>(infcx: &InferCtxt<'a, 'gcx, 'tcx>,
342342
span: Span,
343-
snapshot: &CombinedSnapshot,
343+
snapshot: &CombinedSnapshot<'a, 'tcx>,
344344
debruijn: ty::DebruijnIndex,
345345
new_vars: &[ty::RegionVid],
346346
a_map: &BTreeMap<ty::BoundRegion, ty::Region<'tcx>>,
@@ -479,7 +479,7 @@ fn fold_regions_in<'a, 'gcx, 'tcx, T, F>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
479479

480480
impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
481481
fn tainted_regions(&self,
482-
snapshot: &CombinedSnapshot,
482+
snapshot: &CombinedSnapshot<'a, 'tcx>,
483483
r: ty::Region<'tcx>,
484484
directions: TaintDirections)
485485
-> FxHashSet<ty::Region<'tcx>> {
@@ -491,7 +491,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
491491
}
492492

493493
fn region_vars_confined_to_snapshot(&self,
494-
snapshot: &CombinedSnapshot)
494+
snapshot: &CombinedSnapshot<'a, 'tcx>)
495495
-> Vec<ty::RegionVid>
496496
{
497497
/*!
@@ -583,7 +583,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
583583
/// See `README.md` for more details.
584584
pub fn skolemize_late_bound_regions<T>(&self,
585585
binder: &ty::Binder<T>,
586-
snapshot: &CombinedSnapshot)
586+
snapshot: &CombinedSnapshot<'a, 'tcx>)
587587
-> (T, SkolemizationMap<'tcx>)
588588
where T : TypeFoldable<'tcx>
589589
{
@@ -609,7 +609,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
609609
overly_polymorphic: bool,
610610
_span: Span,
611611
skol_map: &SkolemizationMap<'tcx>,
612-
snapshot: &CombinedSnapshot)
612+
snapshot: &CombinedSnapshot<'a, 'tcx>)
613613
-> RelateResult<'tcx, ()>
614614
{
615615
debug!("leak_check: skol_map={:?}",
@@ -684,7 +684,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
684684
/// predicate is `for<'a> &'a int : Clone`.
685685
pub fn plug_leaks<T>(&self,
686686
skol_map: SkolemizationMap<'tcx>,
687-
snapshot: &CombinedSnapshot,
687+
snapshot: &CombinedSnapshot<'a, 'tcx>,
688688
value: T) -> T
689689
where T : TypeFoldable<'tcx>
690690
{
@@ -770,8 +770,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
770770
/// Note: popping also occurs implicitly as part of `leak_check`.
771771
pub fn pop_skolemized(&self,
772772
skol_map: SkolemizationMap<'tcx>,
773-
snapshot: &CombinedSnapshot)
774-
{
773+
snapshot: &CombinedSnapshot<'a, 'tcx>) {
775774
debug!("pop_skolemized({:?})", skol_map);
776775
let skol_regions: FxHashSet<_> = skol_map.values().cloned().collect();
777776
self.borrow_region_constraints()

src/librustc/infer/mod.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ impl<'tcx, T> InferOk<'tcx, T> {
475475
#[must_use = "once you start a snapshot, you should always consume it"]
476476
pub struct CombinedSnapshot<'a, 'tcx:'a> {
477477
projection_cache_snapshot: traits::ProjectionCacheSnapshot,
478-
type_snapshot: type_variable::Snapshot,
478+
type_snapshot: type_variable::Snapshot<'tcx>,
479479
int_snapshot: ut::Snapshot<ut::InPlace<ty::IntVid>>,
480480
float_snapshot: ut::Snapshot<ut::InPlace<ty::FloatVid>>,
481481
region_constraints_snapshot: RegionSnapshot,
@@ -765,7 +765,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
765765
result
766766
}
767767

768-
fn start_snapshot<'b>(&'b self) -> CombinedSnapshot<'b, 'tcx> {
768+
fn start_snapshot(&self) -> CombinedSnapshot<'a, 'tcx> {
769769
debug!("start_snapshot()");
770770

771771
let in_snapshot = self.in_snapshot.get();
@@ -787,7 +787,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
787787
}
788788
}
789789

790-
fn rollback_to(&self, cause: &str, snapshot: CombinedSnapshot) {
790+
fn rollback_to(&self, cause: &str, snapshot: CombinedSnapshot<'a, 'tcx>) {
791791
debug!("rollback_to(cause={})", cause);
792792
let CombinedSnapshot { projection_cache_snapshot,
793793
type_snapshot,
@@ -819,7 +819,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
819819
.rollback_to(region_constraints_snapshot);
820820
}
821821

822-
fn commit_from(&self, snapshot: CombinedSnapshot) {
822+
fn commit_from(&self, snapshot: CombinedSnapshot<'a, 'tcx>) {
823823
debug!("commit_from()");
824824
let CombinedSnapshot { projection_cache_snapshot,
825825
type_snapshot,
@@ -861,7 +861,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
861861

862862
/// Execute `f` and commit the bindings if closure `f` returns `Ok(_)`
863863
pub fn commit_if_ok<T, E, F>(&self, f: F) -> Result<T, E> where
864-
F: FnOnce(&CombinedSnapshot) -> Result<T, E>
864+
F: FnOnce(&CombinedSnapshot<'a, 'tcx>) -> Result<T, E>
865865
{
866866
debug!("commit_if_ok()");
867867
let snapshot = self.start_snapshot();
@@ -876,7 +876,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
876876

877877
// Execute `f` in a snapshot, and commit the bindings it creates
878878
pub fn in_snapshot<T, F>(&self, f: F) -> T where
879-
F: FnOnce(&CombinedSnapshot) -> T
879+
F: FnOnce(&CombinedSnapshot<'a, 'tcx>) -> T
880880
{
881881
debug!("in_snapshot()");
882882
let snapshot = self.start_snapshot();
@@ -887,7 +887,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
887887

888888
/// Execute `f` then unroll any bindings it creates
889889
pub fn probe<R, F>(&self, f: F) -> R where
890-
F: FnOnce(&CombinedSnapshot) -> R,
890+
F: FnOnce(&CombinedSnapshot<'a, 'tcx>) -> R,
891891
{
892892
debug!("probe()");
893893
let snapshot = self.start_snapshot();

0 commit comments

Comments
 (0)