@@ -23,29 +23,39 @@ crate struct ConstraintSet {
23
23
}
24
24
25
25
impl ConstraintSet {
26
- pub fn push ( & mut self , outlives_constraint : OutlivesConstraint ) {
26
+ pub fn new ( ) -> Self {
27
+ Default :: default ( )
28
+ }
29
+
30
+ pub fn push ( & mut self , constraint : OutlivesConstraint ) {
27
31
debug ! ( "add_outlives({:?}: {:?} @ {:?}" ,
28
- outlives_constraint . sup,
29
- outlives_constraint . sub,
30
- outlives_constraint . point) ;
31
- if outlives_constraint . sup == outlives_constraint . sub {
32
+ constraint . sup,
33
+ constraint . sub,
34
+ constraint . point) ;
35
+ if constraint . sup == constraint . sub {
32
36
// 'a: 'a is pretty uninteresting
33
37
return ;
34
38
}
35
- if self . seen_constraints . insert ( outlives_constraint . dedup_key ( ) ) {
36
- self . constraints . push ( outlives_constraint ) ;
39
+ if self . seen_constraints . insert ( constraint . dedup_key ( ) ) {
40
+ self . constraints . push ( constraint ) ;
37
41
}
38
42
}
39
43
40
44
pub fn inner ( & self ) -> & IndexVec < ConstraintIndex , OutlivesConstraint > {
41
45
& self . constraints
42
46
}
43
47
44
- /// Do Not use this to add nor remove items to the Vec,
45
- /// nor change the `sup`,
46
- /// nor `sub` of the data.
47
- pub fn inner_mut ( & mut self ) -> & mut IndexVec < ConstraintIndex , OutlivesConstraint > {
48
- & mut self . constraints
48
+ pub fn link ( & mut self , len : usize ) -> IndexVec < RegionVid , Option < ConstraintIndex > > {
49
+ let mut map = IndexVec :: from_elem_n ( None , len) ;
50
+
51
+ for ( idx, constraint) in self . constraints . iter_enumerated_mut ( ) . rev ( ) {
52
+ let mut head = & mut map[ constraint. sub ] ;
53
+ debug_assert ! ( constraint. next. is_none( ) ) ;
54
+ constraint. next = * head;
55
+ * head = Some ( idx) ;
56
+ }
57
+
58
+ map
49
59
}
50
60
}
51
61
0 commit comments