@@ -110,7 +110,7 @@ impl<I: Interner> CanonicalVarInfo<I> {
110110
111111 pub fn is_existential ( & self ) -> bool {
112112 match self . kind {
113- CanonicalVarKind :: Ty ( _ ) | CanonicalVarKind :: Int | CanonicalVarKind :: Float => true ,
113+ CanonicalVarKind :: Ty { .. } | CanonicalVarKind :: Int | CanonicalVarKind :: Float => true ,
114114 CanonicalVarKind :: PlaceholderTy ( _) => false ,
115115 CanonicalVarKind :: Region ( _) => true ,
116116 CanonicalVarKind :: PlaceholderRegion ( ..) => false ,
@@ -122,7 +122,7 @@ impl<I: Interner> CanonicalVarInfo<I> {
122122 pub fn is_region ( & self ) -> bool {
123123 match self . kind {
124124 CanonicalVarKind :: Region ( _) | CanonicalVarKind :: PlaceholderRegion ( _) => true ,
125- CanonicalVarKind :: Ty ( _ )
125+ CanonicalVarKind :: Ty { .. }
126126 | CanonicalVarKind :: Int
127127 | CanonicalVarKind :: Float
128128 | CanonicalVarKind :: PlaceholderTy ( _)
@@ -133,7 +133,7 @@ impl<I: Interner> CanonicalVarInfo<I> {
133133
134134 pub fn expect_placeholder_index ( self ) -> usize {
135135 match self . kind {
136- CanonicalVarKind :: Ty ( _ )
136+ CanonicalVarKind :: Ty { .. }
137137 | CanonicalVarKind :: Int
138138 | CanonicalVarKind :: Float
139139 | CanonicalVarKind :: Region ( _)
@@ -158,7 +158,11 @@ impl<I: Interner> CanonicalVarInfo<I> {
158158) ]
159159pub enum CanonicalVarKind < I : Interner > {
160160 /// 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 } ,
162166
163167 /// Integral type variable `?I` (that can only be unified with integral types).
164168 Int ,
@@ -187,7 +191,7 @@ pub enum CanonicalVarKind<I: Interner> {
187191impl < I : Interner > CanonicalVarKind < I > {
188192 pub fn universe ( self ) -> UniverseIndex {
189193 match self {
190- CanonicalVarKind :: Ty ( ui ) => ui ,
194+ CanonicalVarKind :: Ty { universe , sub_root : _ } => universe ,
191195 CanonicalVarKind :: Region ( ui) => ui,
192196 CanonicalVarKind :: Const ( ui) => ui,
193197 CanonicalVarKind :: PlaceholderTy ( placeholder) => placeholder. universe ( ) ,
@@ -203,7 +207,9 @@ impl<I: Interner> CanonicalVarKind<I> {
203207 /// the updated universe is not the root.
204208 pub fn with_updated_universe ( self , ui : UniverseIndex ) -> CanonicalVarKind < I > {
205209 match self {
206- CanonicalVarKind :: Ty ( _) => CanonicalVarKind :: Ty ( ui) ,
210+ CanonicalVarKind :: Ty { universe : _, sub_root } => {
211+ CanonicalVarKind :: Ty { universe : ui, sub_root }
212+ }
207213 CanonicalVarKind :: Region ( _) => CanonicalVarKind :: Region ( ui) ,
208214 CanonicalVarKind :: Const ( _) => CanonicalVarKind :: Const ( ui) ,
209215
@@ -297,7 +303,7 @@ impl<I: Interner> CanonicalVarValues<I> {
297303 var_values : cx. mk_args_from_iter ( infos. iter ( ) . enumerate ( ) . map (
298304 |( i, info) | -> I :: GenericArg {
299305 match info. kind {
300- CanonicalVarKind :: Ty ( _ )
306+ CanonicalVarKind :: Ty { .. }
301307 | CanonicalVarKind :: Int
302308 | CanonicalVarKind :: Float
303309 | CanonicalVarKind :: PlaceholderTy ( _) => {
0 commit comments