@@ -110,7 +110,7 @@ impl<I: Interner> CanonicalVarInfo<I> {
110
110
111
111
pub fn is_existential ( & self ) -> bool {
112
112
match self . kind {
113
- CanonicalVarKind :: Ty ( _ ) | CanonicalVarKind :: Int | CanonicalVarKind :: Float => true ,
113
+ CanonicalVarKind :: Ty { .. } | CanonicalVarKind :: Int | CanonicalVarKind :: Float => true ,
114
114
CanonicalVarKind :: PlaceholderTy ( _) => false ,
115
115
CanonicalVarKind :: Region ( _) => true ,
116
116
CanonicalVarKind :: PlaceholderRegion ( ..) => false ,
@@ -122,7 +122,7 @@ impl<I: Interner> CanonicalVarInfo<I> {
122
122
pub fn is_region ( & self ) -> bool {
123
123
match self . kind {
124
124
CanonicalVarKind :: Region ( _) | CanonicalVarKind :: PlaceholderRegion ( _) => true ,
125
- CanonicalVarKind :: Ty ( _ )
125
+ CanonicalVarKind :: Ty { .. }
126
126
| CanonicalVarKind :: Int
127
127
| CanonicalVarKind :: Float
128
128
| CanonicalVarKind :: PlaceholderTy ( _)
@@ -133,7 +133,7 @@ impl<I: Interner> CanonicalVarInfo<I> {
133
133
134
134
pub fn expect_placeholder_index ( self ) -> usize {
135
135
match self . kind {
136
- CanonicalVarKind :: Ty ( _ )
136
+ CanonicalVarKind :: Ty { .. }
137
137
| CanonicalVarKind :: Int
138
138
| CanonicalVarKind :: Float
139
139
| CanonicalVarKind :: Region ( _)
@@ -158,7 +158,11 @@ impl<I: Interner> CanonicalVarInfo<I> {
158
158
) ]
159
159
pub enum CanonicalVarKind < I : Interner > {
160
160
/// A general type variable `?T` that can be unified with arbitrary types.
161
- Ty ( UniverseIndex ) ,
161
+ ///
162
+ /// We also store the index of the first type variable which is sub-unified
163
+ /// with this one. If there is no inference variable related to this one,
164
+ /// its `sub_root` just points to itself.
165
+ Ty { universe : UniverseIndex , sub_root : ty:: BoundVar } ,
162
166
163
167
/// Integral type variable `?I` (that can only be unified with integral types).
164
168
Int ,
@@ -187,7 +191,7 @@ pub enum CanonicalVarKind<I: Interner> {
187
191
impl < I : Interner > CanonicalVarKind < I > {
188
192
pub fn universe ( self ) -> UniverseIndex {
189
193
match self {
190
- CanonicalVarKind :: Ty ( ui ) => ui ,
194
+ CanonicalVarKind :: Ty { universe , sub_root : _ } => universe ,
191
195
CanonicalVarKind :: Region ( ui) => ui,
192
196
CanonicalVarKind :: Const ( ui) => ui,
193
197
CanonicalVarKind :: PlaceholderTy ( placeholder) => placeholder. universe ( ) ,
@@ -203,7 +207,9 @@ impl<I: Interner> CanonicalVarKind<I> {
203
207
/// the updated universe is not the root.
204
208
pub fn with_updated_universe ( self , ui : UniverseIndex ) -> CanonicalVarKind < I > {
205
209
match self {
206
- CanonicalVarKind :: Ty ( _) => CanonicalVarKind :: Ty ( ui) ,
210
+ CanonicalVarKind :: Ty { universe : _, sub_root } => {
211
+ CanonicalVarKind :: Ty { universe : ui, sub_root }
212
+ }
207
213
CanonicalVarKind :: Region ( _) => CanonicalVarKind :: Region ( ui) ,
208
214
CanonicalVarKind :: Const ( _) => CanonicalVarKind :: Const ( ui) ,
209
215
@@ -297,7 +303,7 @@ impl<I: Interner> CanonicalVarValues<I> {
297
303
var_values : cx. mk_args_from_iter ( infos. iter ( ) . enumerate ( ) . map (
298
304
|( i, info) | -> I :: GenericArg {
299
305
match info. kind {
300
- CanonicalVarKind :: Ty ( _ )
306
+ CanonicalVarKind :: Ty { .. }
301
307
| CanonicalVarKind :: Int
302
308
| CanonicalVarKind :: Float
303
309
| CanonicalVarKind :: PlaceholderTy ( _) => {
0 commit comments