@@ -42,15 +42,15 @@ impl<'tcx> Rollback<sv::UndoLog<ut::Delegate<TyVidEqKey<'tcx>>>> for TypeVariabl
4242
4343impl < ' tcx >  Rollback < sv:: UndoLog < ut:: Delegate < TyVidSubKey > > >  for  TypeVariableStorage < ' tcx >  { 
4444    fn  reverse ( & mut  self ,  undo :  sv:: UndoLog < ut:: Delegate < TyVidSubKey > > )  { 
45-         self . sub_relations . reverse ( undo) 
45+         self . sub_unification_table . reverse ( undo) 
4646    } 
4747} 
4848
4949impl < ' tcx >  Rollback < UndoLog < ' tcx > >  for  TypeVariableStorage < ' tcx >  { 
5050    fn  reverse ( & mut  self ,  undo :  UndoLog < ' tcx > )  { 
5151        match  undo { 
5252            UndoLog :: EqRelation ( undo)  => self . eq_relations . reverse ( undo) , 
53-             UndoLog :: SubRelation ( undo)  => self . sub_relations . reverse ( undo) , 
53+             UndoLog :: SubRelation ( undo)  => self . sub_unification_table . reverse ( undo) , 
5454        } 
5555    } 
5656} 
@@ -63,7 +63,9 @@ pub(crate) struct TypeVariableStorage<'tcx> {
6363/// constraint `?X == ?Y`. This table also stores, for each key, 
6464/// the known value. 
6565eq_relations :  ut:: UnificationTableStorage < TyVidEqKey < ' tcx > > , 
66-     /// Only used by `-Znext-solver` and for diagnostics. 
66+     /// Only used by `-Znext-solver` and for diagnostics. Tracks whether 
67+ /// type variables are related via subtyping at all, ignoring which of 
68+ /// the two is the subtype. 
6769/// 
6870/// When reporting ambiguity errors, we sometimes want to 
6971/// treat all inference vars which are subtypes of each 
@@ -79,7 +81,7 @@ pub(crate) struct TypeVariableStorage<'tcx> {
7981/// Even for something like `let x = returns_arg(); x.method();` the 
8082/// type of `x` is only a supertype of the argument of `returns_arg`. We 
8183/// still want to suggest specifying the type of the argument. 
82- sub_relations :  ut:: UnificationTableStorage < TyVidSubKey > , 
84+ sub_unification_table :  ut:: UnificationTableStorage < TyVidSubKey > , 
8385} 
8486
8587pub ( crate )  struct  TypeVariableTable < ' a ,  ' tcx >  { 
@@ -155,23 +157,24 @@ impl<'tcx> TypeVariableTable<'_, 'tcx> {
155157        self . storage . values [ vid] . origin 
156158    } 
157159
158-     /// Records that `a == b`, depending on `dir` . 
160+     /// Records that `a == b`. 
159161/// 
160162/// Precondition: neither `a` nor `b` are known. 
161163pub ( crate )  fn  equate ( & mut  self ,  a :  ty:: TyVid ,  b :  ty:: TyVid )  { 
162164        debug_assert ! ( self . probe( a) . is_unknown( ) ) ; 
163165        debug_assert ! ( self . probe( b) . is_unknown( ) ) ; 
164166        self . eq_relations ( ) . union ( a,  b) ; 
165-         self . sub_relations ( ) . union ( a,  b) ; 
167+         self . sub_unification_table ( ) . union ( a,  b) ; 
166168    } 
167169
168-     /// Records that `a <: b`, depending on `dir`. 
170+     /// Records that `a` and `b` are related via subtyping. We don't track 
171+ /// which of the two is the subtype. 
169172/// 
170173/// Precondition: neither `a` nor `b` are known. 
171- pub ( crate )  fn  sub ( & mut  self ,  a :  ty:: TyVid ,  b :  ty:: TyVid )  { 
174+ pub ( crate )  fn  sub_unify ( & mut  self ,  a :  ty:: TyVid ,  b :  ty:: TyVid )  { 
172175        debug_assert ! ( self . probe( a) . is_unknown( ) ) ; 
173176        debug_assert ! ( self . probe( b) . is_unknown( ) ) ; 
174-         self . sub_relations ( ) . union ( a,  b) ; 
177+         self . sub_unification_table ( ) . union ( a,  b) ; 
175178    } 
176179
177180    /// Instantiates `vid` with the type `ty`. 
@@ -206,7 +209,7 @@ impl<'tcx> TypeVariableTable<'_, 'tcx> {
206209    )  -> ty:: TyVid  { 
207210        let  eq_key = self . eq_relations ( ) . new_key ( TypeVariableValue :: Unknown  {  universe } ) ; 
208211
209-         let  sub_key = self . sub_relations ( ) . new_key ( ( ) ) ; 
212+         let  sub_key = self . sub_unification_table ( ) . new_key ( ( ) ) ; 
210213        debug_assert_eq ! ( eq_key. vid,  sub_key. vid) ; 
211214
212215        let  index = self . storage . values . push ( TypeVariableData  {  origin } ) ; 
@@ -231,16 +234,16 @@ impl<'tcx> TypeVariableTable<'_, 'tcx> {
231234        self . eq_relations ( ) . find ( vid) . vid 
232235    } 
233236
234-     /// Returns the "root" variable of `vid` in the `sub_relations ` 
235- /// equivalence table. All type variables that have been are 
236- /// related via  equality or subtyping will yield the same root 
237- /// variable (per the  union-find algorithm), so `sub_root_var (a) 
238- /// == sub_root_var (b)` implies that: 
237+     /// Returns the "root" variable of `vid` in the `sub_unification_table ` 
238+ /// equivalence table. All type variables that have been are related via  
239+ /// equality or subtyping will yield the same root variable (per the  
240+ /// union-find algorithm), so `sub_unification_table_root_var (a) 
241+ /// == sub_unification_table_root_var (b)` implies that: 
239242/// ```text 
240243/// exists X. (a <: X || X <: a) && (b <: X || X <: b) 
241244/// ``` 
242- pub ( crate )  fn  sub_root_var ( & mut  self ,  vid :  ty:: TyVid )  -> ty:: TyVid  { 
243-         self . sub_relations ( ) . find ( vid) . vid 
245+ pub ( crate )  fn  sub_unification_table_root_var ( & mut  self ,  vid :  ty:: TyVid )  -> ty:: TyVid  { 
246+         self . sub_unification_table ( ) . find ( vid) . vid 
244247    } 
245248
246249    /// Retrieves the type to which `vid` has been instantiated, if 
@@ -261,8 +264,8 @@ impl<'tcx> TypeVariableTable<'_, 'tcx> {
261264    } 
262265
263266    #[ inline]  
264-     fn  sub_relations ( & mut  self )  -> super :: UnificationTable < ' _ ,  ' tcx ,  TyVidSubKey >  { 
265-         self . storage . sub_relations . with_log ( self . undo_log ) 
267+     fn  sub_unification_table ( & mut  self )  -> super :: UnificationTable < ' _ ,  ' tcx ,  TyVidSubKey >  { 
268+         self . storage . sub_unification_table . with_log ( self . undo_log ) 
266269    } 
267270
268271    /// Returns a range of the type variables created during the snapshot. 
0 commit comments