@@ -37,15 +37,13 @@ impl<I: Interner> InferenceTable<I> {
37
37
struct Unifier < ' t , I : Interner > {
38
38
table : & ' t mut InferenceTable < I > ,
39
39
environment : & ' t Environment < I > ,
40
- goals : Vec < InEnvironment < DomainGoal < I > > > ,
41
- constraints : Vec < InEnvironment < Constraint < I > > > ,
40
+ goals : Vec < InEnvironment < Goal < I > > > ,
42
41
interner : & ' t I ,
43
42
}
44
43
45
44
#[ derive( Debug ) ]
46
45
pub ( crate ) struct UnificationResult < I : Interner > {
47
- pub ( crate ) goals : Vec < InEnvironment < DomainGoal < I > > > ,
48
- pub ( crate ) constraints : Vec < InEnvironment < Constraint < I > > > ,
46
+ pub ( crate ) goals : Vec < InEnvironment < Goal < I > > > ,
49
47
}
50
48
51
49
impl < ' t , I : Interner > Unifier < ' t , I > {
@@ -58,7 +56,6 @@ impl<'t, I: Interner> Unifier<'t, I> {
58
56
environment : environment,
59
57
table : table,
60
58
goals : vec ! [ ] ,
61
- constraints : vec ! [ ] ,
62
59
interner,
63
60
}
64
61
}
@@ -71,10 +68,7 @@ impl<'t, I: Interner> Unifier<'t, I> {
71
68
T : ?Sized + Zip < I > ,
72
69
{
73
70
Zip :: zip_with ( & mut self , a, b) ?;
74
- Ok ( UnificationResult {
75
- goals : self . goals ,
76
- constraints : self . constraints ,
77
- } )
71
+ Ok ( UnificationResult { goals : self . goals } )
78
72
}
79
73
80
74
fn unify_ty_ty ( & mut self , a : & Ty < I > , b : & Ty < I > ) -> Fallible < ( ) > {
@@ -344,7 +338,7 @@ impl<'t, I: Interner> Unifier<'t, I> {
344
338
345
339
( & LifetimeData :: Placeholder ( _) , & LifetimeData :: Placeholder ( _) ) => {
346
340
if a != b {
347
- Ok ( self . push_lifetime_eq_constraint ( a. clone ( ) , b. clone ( ) ) )
341
+ Ok ( self . push_lifetime_eq_subgoal ( a. clone ( ) , b. clone ( ) ) )
348
342
} else {
349
343
Ok ( ( ) )
350
344
}
@@ -388,7 +382,7 @@ impl<'t, I: Interner> Unifier<'t, I> {
388
382
"unify_lifetime_var: {:?} in {:?} cannot see {:?}; pushing constraint" ,
389
383
var, var_ui, value_ui
390
384
) ;
391
- Ok ( self . push_lifetime_eq_constraint ( a. clone ( ) , b. clone ( ) ) )
385
+ Ok ( self . push_lifetime_eq_subgoal ( a. clone ( ) , b. clone ( ) ) )
392
386
}
393
387
}
394
388
@@ -478,15 +472,14 @@ impl<'t, I: Interner> Unifier<'t, I> {
478
472
Ok ( ( ) )
479
473
}
480
474
481
- fn push_lifetime_eq_constraint ( & mut self , a : Lifetime < I > , b : Lifetime < I > ) {
482
- self . constraints . push ( InEnvironment :: new (
483
- self . environment ,
484
- Constraint :: Outlives ( a. clone ( ) , b. clone ( ) ) ,
485
- ) ) ;
486
- self . constraints . push ( InEnvironment :: new (
487
- self . environment ,
488
- Constraint :: Outlives ( b, a) ,
489
- ) ) ;
475
+ fn push_lifetime_eq_subgoal ( & mut self , a : Lifetime < I > , b : Lifetime < I > ) {
476
+ let interner = self . interner ;
477
+ let b_outlives_a = GoalData :: AddRegionConstraint ( b. clone ( ) , a. clone ( ) ) . intern ( interner) ;
478
+ self . goals
479
+ . push ( InEnvironment :: new ( self . environment , b_outlives_a) ) ;
480
+ let a_outlives_b = GoalData :: AddRegionConstraint ( a, b) . intern ( interner) ;
481
+ self . goals
482
+ . push ( InEnvironment :: new ( self . environment , a_outlives_b) ) ;
490
483
}
491
484
}
492
485
@@ -588,10 +581,8 @@ where
588
581
// exists<'x> forall<'b> ?T = Foo<'x>, where 'x = 'b
589
582
590
583
let tick_x = self . unifier . table . new_variable ( self . universe_index ) ;
591
- self . unifier . push_lifetime_eq_constraint (
592
- tick_x. to_lifetime ( interner) ,
593
- ui. to_lifetime ( interner) ,
594
- ) ;
584
+ self . unifier
585
+ . push_lifetime_eq_subgoal ( tick_x. to_lifetime ( interner) , ui. to_lifetime ( interner) ) ;
595
586
Ok ( tick_x. to_lifetime ( interner) )
596
587
} else {
597
588
// If the `ui` is higher than `self.universe_index`, then we can name
0 commit comments