Skip to content

Commit 2b7f276

Browse files
committed
store type values in the unification table directly
1 parent 744f102 commit 2b7f276

File tree

5 files changed

+176
-98
lines changed

5 files changed

+176
-98
lines changed

src/librustc/infer/combine.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ impl<'cx, 'gcx, 'tcx> TypeRelation<'cx, 'gcx, 'tcx> for Generalizer<'cx, 'gcx, '
388388
// `vid` are related via subtyping.
389389
return Err(TypeError::CyclicTy);
390390
} else {
391-
match variables.probe_root(vid) {
391+
match variables.probe(vid) {
392392
Some(u) => {
393393
drop(variables);
394394
self.relate(&u, &u)
@@ -409,7 +409,7 @@ impl<'cx, 'gcx, 'tcx> TypeRelation<'cx, 'gcx, 'tcx> for Generalizer<'cx, 'gcx, '
409409
ty::Covariant | ty::Contravariant => (),
410410
}
411411

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

src/librustc/infer/higher_ranked/mod.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ impl<'a, 'gcx, 'tcx> CombineFields<'a, 'gcx, 'tcx> {
242242

243243
fn generalize_region<'a, 'gcx, 'tcx>(infcx: &InferCtxt<'a, 'gcx, 'tcx>,
244244
span: Span,
245-
snapshot: &CombinedSnapshot,
245+
snapshot: &CombinedSnapshot<'a, 'tcx>,
246246
debruijn: ty::DebruijnIndex,
247247
new_vars: &[ty::RegionVid],
248248
a_map: &FxHashMap<ty::BoundRegion, ty::Region<'tcx>>,
@@ -338,7 +338,7 @@ impl<'a, 'gcx, 'tcx> CombineFields<'a, 'gcx, 'tcx> {
338338

339339
fn generalize_region<'a, 'gcx, 'tcx>(infcx: &InferCtxt<'a, 'gcx, 'tcx>,
340340
span: Span,
341-
snapshot: &CombinedSnapshot,
341+
snapshot: &CombinedSnapshot<'a, 'tcx>,
342342
debruijn: ty::DebruijnIndex,
343343
new_vars: &[ty::RegionVid],
344344
a_map: &FxHashMap<ty::BoundRegion, ty::Region<'tcx>>,
@@ -477,15 +477,15 @@ fn fold_regions_in<'a, 'gcx, 'tcx, T, F>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
477477

478478
impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
479479
fn tainted_regions(&self,
480-
snapshot: &CombinedSnapshot,
480+
snapshot: &CombinedSnapshot<'a, 'tcx>,
481481
r: ty::Region<'tcx>,
482482
directions: TaintDirections)
483483
-> FxHashSet<ty::Region<'tcx>> {
484484
self.region_vars.tainted(&snapshot.region_vars_snapshot, r, directions)
485485
}
486486

487487
fn region_vars_confined_to_snapshot(&self,
488-
snapshot: &CombinedSnapshot)
488+
snapshot: &CombinedSnapshot<'a, 'tcx>)
489489
-> Vec<ty::RegionVid>
490490
{
491491
/*!
@@ -576,7 +576,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
576576
/// See `README.md` for more details.
577577
pub fn skolemize_late_bound_regions<T>(&self,
578578
binder: &ty::Binder<T>,
579-
snapshot: &CombinedSnapshot)
579+
snapshot: &CombinedSnapshot<'a, 'tcx>)
580580
-> (T, SkolemizationMap<'tcx>)
581581
where T : TypeFoldable<'tcx>
582582
{
@@ -601,7 +601,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
601601
overly_polymorphic: bool,
602602
_span: Span,
603603
skol_map: &SkolemizationMap<'tcx>,
604-
snapshot: &CombinedSnapshot)
604+
snapshot: &CombinedSnapshot<'a, 'tcx>)
605605
-> RelateResult<'tcx, ()>
606606
{
607607
debug!("leak_check: skol_map={:?}",
@@ -676,7 +676,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
676676
/// predicate is `for<'a> &'a int : Clone`.
677677
pub fn plug_leaks<T>(&self,
678678
skol_map: SkolemizationMap<'tcx>,
679-
snapshot: &CombinedSnapshot,
679+
snapshot: &CombinedSnapshot<'a, 'tcx>,
680680
value: T) -> T
681681
where T : TypeFoldable<'tcx>
682682
{
@@ -762,8 +762,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
762762
/// Note: popping also occurs implicitly as part of `leak_check`.
763763
pub fn pop_skolemized(&self,
764764
skol_map: SkolemizationMap<'tcx>,
765-
snapshot: &CombinedSnapshot)
766-
{
765+
snapshot: &CombinedSnapshot<'a, 'tcx>) {
767766
debug!("pop_skolemized({:?})", skol_map);
768767
let skol_regions: FxHashSet<_> = skol_map.values().cloned().collect();
769768
self.region_vars.pop_skolemized(&skol_regions, &snapshot.region_vars_snapshot);

src/librustc/infer/mod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ impl<'tcx, T> InferOk<'tcx, T> {
409409
#[must_use = "once you start a snapshot, you should always consume it"]
410410
pub struct CombinedSnapshot<'a, 'tcx:'a> {
411411
projection_cache_snapshot: traits::ProjectionCacheSnapshot,
412-
type_snapshot: type_variable::Snapshot,
412+
type_snapshot: type_variable::Snapshot<'tcx>,
413413
int_snapshot: ut::Snapshot<ut::InPlace<ty::IntVid>>,
414414
float_snapshot: ut::Snapshot<ut::InPlace<ty::FloatVid>>,
415415
region_vars_snapshot: RegionSnapshot,
@@ -698,7 +698,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
698698
result
699699
}
700700

701-
fn start_snapshot<'b>(&'b self) -> CombinedSnapshot<'b, 'tcx> {
701+
fn start_snapshot(&self) -> CombinedSnapshot<'a, 'tcx> {
702702
debug!("start_snapshot()");
703703

704704
let in_snapshot = self.in_snapshot.get();
@@ -719,7 +719,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
719719
}
720720
}
721721

722-
fn rollback_to(&self, cause: &str, snapshot: CombinedSnapshot) {
722+
fn rollback_to(&self, cause: &str, snapshot: CombinedSnapshot<'a, 'tcx>) {
723723
debug!("rollback_to(cause={})", cause);
724724
let CombinedSnapshot { projection_cache_snapshot,
725725
type_snapshot,
@@ -747,7 +747,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
747747
.rollback_to(region_vars_snapshot);
748748
}
749749

750-
fn commit_from(&self, snapshot: CombinedSnapshot) {
750+
fn commit_from(&self, snapshot: CombinedSnapshot<'a, 'tcx>) {
751751
debug!("commit_from()");
752752
let CombinedSnapshot { projection_cache_snapshot,
753753
type_snapshot,
@@ -788,7 +788,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
788788

789789
/// Execute `f` and commit the bindings if closure `f` returns `Ok(_)`
790790
pub fn commit_if_ok<T, E, F>(&self, f: F) -> Result<T, E> where
791-
F: FnOnce(&CombinedSnapshot) -> Result<T, E>
791+
F: FnOnce(&CombinedSnapshot<'a, 'tcx>) -> Result<T, E>
792792
{
793793
debug!("commit_if_ok()");
794794
let snapshot = self.start_snapshot();
@@ -803,7 +803,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
803803

804804
// Execute `f` in a snapshot, and commit the bindings it creates
805805
pub fn in_snapshot<T, F>(&self, f: F) -> T where
806-
F: FnOnce(&CombinedSnapshot) -> T
806+
F: FnOnce(&CombinedSnapshot<'a, 'tcx>) -> T
807807
{
808808
debug!("in_snapshot()");
809809
let snapshot = self.start_snapshot();
@@ -814,7 +814,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
814814

815815
/// Execute `f` then unroll any bindings it creates
816816
pub fn probe<R, F>(&self, f: F) -> R where
817-
F: FnOnce(&CombinedSnapshot) -> R,
817+
F: FnOnce(&CombinedSnapshot<'a, 'tcx>) -> R,
818818
{
819819
debug!("probe()");
820820
let snapshot = self.start_snapshot();

0 commit comments

Comments
 (0)