@@ -13,7 +13,6 @@ use rustc_hir::intravisit::{self, Visitor};
1313use rustc_hir:: { Body , Closure , Expr , ExprKind , FnRetTy , HirId , LetStmt , LocalSource } ;
1414use rustc_middle:: bug;
1515use rustc_middle:: hir:: nested_filter;
16- use rustc_middle:: infer:: unify_key:: ConstVariableValue ;
1716use rustc_middle:: ty:: adjustment:: { Adjust , Adjustment , AutoBorrow } ;
1817use rustc_middle:: ty:: print:: { FmtPrinter , PrettyPrinter , Print , Printer } ;
1918use rustc_middle:: ty:: {
@@ -183,9 +182,7 @@ fn fmt_printer<'a, 'tcx>(infcx: &'a InferCtxt<'tcx>, ns: Namespace) -> FmtPrinte
183182 warn ! ( "resolved ty var in error message" ) ;
184183 }
185184
186- let mut infcx_inner = infcx. inner . borrow_mut ( ) ;
187- let ty_vars = infcx_inner. type_variables ( ) ;
188- let var_origin = ty_vars. var_origin ( ty_vid) ;
185+ let var_origin = infcx. type_var_origin ( ty_vid) ;
189186 if let Some ( def_id) = var_origin. param_def_id
190187 // The `Self` param of a trait has the def-id of the trait,
191188 // since it's a synthetic parameter.
@@ -206,24 +203,8 @@ fn fmt_printer<'a, 'tcx>(infcx: &'a InferCtxt<'tcx>, ns: Namespace) -> FmtPrinte
206203 }
207204 } ;
208205 printer. ty_infer_name_resolver = Some ( Box :: new ( ty_getter) ) ;
209- let const_getter = move |ct_vid| match infcx
210- . inner
211- . borrow_mut ( )
212- . const_unification_table ( )
213- . probe_value ( ct_vid)
214- {
215- ConstVariableValue :: Known { value : _ } => {
216- warn ! ( "resolved const var in error message" ) ;
217- None
218- }
219- ConstVariableValue :: Unknown { origin, universe : _ } => {
220- if let Some ( def_id) = origin. param_def_id {
221- Some ( infcx. tcx . item_name ( def_id) )
222- } else {
223- None
224- }
225- }
226- } ;
206+ let const_getter =
207+ move |ct_vid| Some ( infcx. tcx . item_name ( infcx. const_var_origin ( ct_vid) ?. param_def_id ?) ) ;
227208 printer. const_infer_name_resolver = Some ( Box :: new ( const_getter) ) ;
228209 printer
229210}
@@ -300,9 +281,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
300281 match arg. unpack ( ) {
301282 GenericArgKind :: Type ( ty) => {
302283 if let ty:: Infer ( ty:: TyVar ( ty_vid) ) = * ty. kind ( ) {
303- let mut inner = self . inner . borrow_mut ( ) ;
304- let ty_vars = & inner. type_variables ( ) ;
305- let var_origin = ty_vars. var_origin ( ty_vid) ;
284+ let var_origin = self . infcx . type_var_origin ( ty_vid) ;
306285 if let Some ( def_id) = var_origin. param_def_id
307286 // The `Self` param of a trait has the def-id of the trait,
308287 // since it's a synthetic parameter.
@@ -332,13 +311,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
332311 }
333312 GenericArgKind :: Const ( ct) => {
334313 if let ty:: ConstKind :: Infer ( InferConst :: Var ( vid) ) = ct. kind ( ) {
335- let origin =
336- match self . inner . borrow_mut ( ) . const_unification_table ( ) . probe_value ( vid) {
337- ConstVariableValue :: Known { value } => {
338- bug ! ( "resolved infer var: {vid:?} {value}" )
339- }
340- ConstVariableValue :: Unknown { origin, universe : _ } => origin,
341- } ;
314+ let origin = self . const_var_origin ( vid) . expect ( "expected unresolved const var" ) ;
342315 if let Some ( def_id) = origin. param_def_id {
343316 return InferenceDiagnosticsData {
344317 name : self . tcx . item_name ( def_id) . to_string ( ) ,
@@ -885,7 +858,7 @@ impl<'a, 'tcx> FindInferSourceVisitor<'a, 'tcx> {
885858 use ty:: InferConst :: * ;
886859 match ( inner_ct. kind ( ) , target_ct. kind ( ) ) {
887860 ( ty:: ConstKind :: Infer ( Var ( a_vid) ) , ty:: ConstKind :: Infer ( Var ( b_vid) ) ) => {
888- self . tecx . inner . borrow_mut ( ) . const_unification_table ( ) . unioned ( a_vid , b_vid)
861+ self . tecx . root_const_var ( a_vid ) == self . tecx . root_const_var ( b_vid)
889862 }
890863 _ => false ,
891864 }
0 commit comments