@@ -20,7 +20,7 @@ impl<'tcx> Rollback<sv::UndoLog<ut::Delegate<TyVidEqKey<'tcx>>>> for TypeVariabl
2020}
2121
2222#[ derive( Clone ) ]
23- pub struct TypeVariableStorage < ' tcx > {
23+ pub ( crate ) struct TypeVariableStorage < ' tcx > {
2424 /// The origins of each type variable.
2525 values : IndexVec < TyVid , TypeVariableData > ,
2626 /// Two variables are unified in `eq_relations` when we have a
@@ -29,7 +29,7 @@ pub struct TypeVariableStorage<'tcx> {
2929 eq_relations : ut:: UnificationTableStorage < TyVidEqKey < ' tcx > > ,
3030}
3131
32- pub struct TypeVariableTable < ' a , ' tcx > {
32+ pub ( crate ) struct TypeVariableTable < ' a , ' tcx > {
3333 storage : & ' a mut TypeVariableStorage < ' tcx > ,
3434
3535 undo_log : & ' a mut InferCtxtUndoLogs < ' tcx > ,
@@ -50,22 +50,22 @@ pub(crate) struct TypeVariableData {
5050}
5151
5252#[ derive( Copy , Clone , Debug ) ]
53- pub enum TypeVariableValue < ' tcx > {
53+ pub ( crate ) enum TypeVariableValue < ' tcx > {
5454 Known { value : Ty < ' tcx > } ,
5555 Unknown { universe : ty:: UniverseIndex } ,
5656}
5757
5858impl < ' tcx > TypeVariableValue < ' tcx > {
5959 /// If this value is known, returns the type it is known to be.
6060 /// Otherwise, `None`.
61- pub fn known ( & self ) -> Option < Ty < ' tcx > > {
61+ pub ( crate ) fn known ( & self ) -> Option < Ty < ' tcx > > {
6262 match * self {
6363 TypeVariableValue :: Unknown { .. } => None ,
6464 TypeVariableValue :: Known { value } => Some ( value) ,
6565 }
6666 }
6767
68- pub fn is_unknown ( & self ) -> bool {
68+ pub ( crate ) fn is_unknown ( & self ) -> bool {
6969 match * self {
7070 TypeVariableValue :: Unknown { .. } => true ,
7171 TypeVariableValue :: Known { .. } => false ,
@@ -74,7 +74,7 @@ impl<'tcx> TypeVariableValue<'tcx> {
7474}
7575
7676impl < ' tcx > TypeVariableStorage < ' tcx > {
77- pub fn new ( ) -> TypeVariableStorage < ' tcx > {
77+ pub ( crate ) fn new ( ) -> TypeVariableStorage < ' tcx > {
7878 TypeVariableStorage {
7979 values : Default :: default ( ) ,
8080 eq_relations : ut:: UnificationTableStorage :: new ( ) ,
@@ -105,14 +105,14 @@ impl<'tcx> TypeVariableTable<'_, 'tcx> {
105105 ///
106106 /// Note that this function does not return care whether
107107 /// `vid` has been unified with something else or not.
108- pub fn var_origin ( & self , vid : ty:: TyVid ) -> TypeVariableOrigin {
108+ pub ( crate ) fn var_origin ( & self , vid : ty:: TyVid ) -> TypeVariableOrigin {
109109 self . storage . values [ vid] . origin
110110 }
111111
112112 /// Records that `a == b`, depending on `dir`.
113113 ///
114114 /// Precondition: neither `a` nor `b` are known.
115- pub fn equate ( & mut self , a : ty:: TyVid , b : ty:: TyVid ) {
115+ pub ( crate ) fn equate ( & mut self , a : ty:: TyVid , b : ty:: TyVid ) {
116116 debug_assert ! ( self . probe( a) . is_unknown( ) ) ;
117117 debug_assert ! ( self . probe( b) . is_unknown( ) ) ;
118118 self . eq_relations ( ) . union ( a, b) ;
@@ -121,7 +121,7 @@ impl<'tcx> TypeVariableTable<'_, 'tcx> {
121121 /// Instantiates `vid` with the type `ty`.
122122 ///
123123 /// Precondition: `vid` must not have been previously instantiated.
124- pub fn instantiate ( & mut self , vid : ty:: TyVid , ty : Ty < ' tcx > ) {
124+ pub ( crate ) fn instantiate ( & mut self , vid : ty:: TyVid , ty : Ty < ' tcx > ) {
125125 let vid = self . root_var ( vid) ;
126126 debug_assert ! ( !ty. is_ty_var( ) , "instantiating ty var with var: {vid:?} {ty:?}" ) ;
127127 debug_assert ! ( self . probe( vid) . is_unknown( ) ) ;
@@ -143,7 +143,7 @@ impl<'tcx> TypeVariableTable<'_, 'tcx> {
143143 /// - `origin`: indicates *why* the type variable was created.
144144 /// The code in this module doesn't care, but it can be useful
145145 /// for improving error messages.
146- pub fn new_var (
146+ pub ( crate ) fn new_var (
147147 & mut self ,
148148 universe : ty:: UniverseIndex ,
149149 origin : TypeVariableOrigin ,
@@ -158,7 +158,7 @@ impl<'tcx> TypeVariableTable<'_, 'tcx> {
158158 }
159159
160160 /// Returns the number of type variables created thus far.
161- pub fn num_vars ( & self ) -> usize {
161+ pub ( crate ) fn num_vars ( & self ) -> usize {
162162 self . storage . values . len ( )
163163 }
164164
@@ -167,42 +167,29 @@ impl<'tcx> TypeVariableTable<'_, 'tcx> {
167167 /// will yield the same root variable (per the union-find
168168 /// algorithm), so `root_var(a) == root_var(b)` implies that `a ==
169169 /// b` (transitively).
170- pub fn root_var ( & mut self , vid : ty:: TyVid ) -> ty:: TyVid {
170+ pub ( crate ) fn root_var ( & mut self , vid : ty:: TyVid ) -> ty:: TyVid {
171171 self . eq_relations ( ) . find ( vid) . vid
172172 }
173173
174174 /// Retrieves the type to which `vid` has been instantiated, if
175175 /// any.
176- pub fn probe ( & mut self , vid : ty:: TyVid ) -> TypeVariableValue < ' tcx > {
176+ pub ( crate ) fn probe ( & mut self , vid : ty:: TyVid ) -> TypeVariableValue < ' tcx > {
177177 self . inlined_probe ( vid)
178178 }
179179
180180 /// An always-inlined variant of `probe`, for very hot call sites.
181181 #[ inline( always) ]
182- pub fn inlined_probe ( & mut self , vid : ty:: TyVid ) -> TypeVariableValue < ' tcx > {
182+ pub ( crate ) fn inlined_probe ( & mut self , vid : ty:: TyVid ) -> TypeVariableValue < ' tcx > {
183183 self . eq_relations ( ) . inlined_probe_value ( vid)
184184 }
185185
186- /// If `t` is a type-inference variable, and it has been
187- /// instantiated, then return the with which it was
188- /// instantiated. Otherwise, returns `t`.
189- pub fn replace_if_possible ( & mut self , t : Ty < ' tcx > ) -> Ty < ' tcx > {
190- match * t. kind ( ) {
191- ty:: Infer ( ty:: TyVar ( v) ) => match self . probe ( v) {
192- TypeVariableValue :: Unknown { .. } => t,
193- TypeVariableValue :: Known { value } => value,
194- } ,
195- _ => t,
196- }
197- }
198-
199186 #[ inline]
200187 fn eq_relations ( & mut self ) -> super :: UnificationTable < ' _ , ' tcx , TyVidEqKey < ' tcx > > {
201188 self . storage . eq_relations . with_log ( self . undo_log )
202189 }
203190
204191 /// Returns a range of the type variables created during the snapshot.
205- pub fn vars_since_snapshot (
192+ pub ( crate ) fn vars_since_snapshot (
206193 & mut self ,
207194 value_count : usize ,
208195 ) -> ( Range < TyVid > , Vec < TypeVariableOrigin > ) {
@@ -215,7 +202,7 @@ impl<'tcx> TypeVariableTable<'_, 'tcx> {
215202
216203 /// Returns indices of all variables that are not yet
217204 /// instantiated.
218- pub fn unresolved_variables ( & mut self ) -> Vec < ty:: TyVid > {
205+ pub ( crate ) fn unresolved_variables ( & mut self ) -> Vec < ty:: TyVid > {
219206 ( 0 ..self . num_vars ( ) )
220207 . filter_map ( |i| {
221208 let vid = ty:: TyVid :: from_usize ( i) ;
0 commit comments