@@ -63,7 +63,9 @@ pub(crate) struct TypeVariableStorage<'tcx> {
6363 /// constraint `?X == ?Y`. This table also stores, for each key,
6464 /// the known value.
6565 eq_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
@@ -155,7 +157,7 @@ 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.
161163 pub ( crate ) fn equate ( & mut self , a : ty:: TyVid , b : ty:: TyVid ) {
@@ -165,10 +167,11 @@ impl<'tcx> TypeVariableTable<'_, 'tcx> {
165167 self . sub_relations ( ) . 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_relate ( & mut self , a : ty:: TyVid , b : ty:: TyVid ) {
172175 debug_assert ! ( self . probe( a) . is_unknown( ) ) ;
173176 debug_assert ! ( self . probe( b) . is_unknown( ) ) ;
174177 self . sub_relations ( ) . union ( a, b) ;
@@ -234,12 +237,12 @@ impl<'tcx> TypeVariableTable<'_, 'tcx> {
234237 /// Returns the "root" variable of `vid` in the `sub_relations`
235238 /// equivalence table. All type variables that have been are
236239 /// 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:
240+ /// variable (per the union-find algorithm), so `sub_relations_root_var (a)
241+ /// == sub_relations_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 {
245+ pub ( crate ) fn sub_relations_root_var ( & mut self , vid : ty:: TyVid ) -> ty:: TyVid {
243246 self . sub_relations ( ) . find ( vid) . vid
244247 }
245248
0 commit comments