@@ -489,7 +489,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
489489 parent_name,
490490 } ) ;
491491
492- let args = if self . infcx . tcx . get_diagnostic_item ( sym:: iterator_collect_fn)
492+ let args = if self . tcx . get_diagnostic_item ( sym:: iterator_collect_fn)
493493 == Some ( generics_def_id)
494494 {
495495 "Vec<_>" . to_string ( )
@@ -697,7 +697,7 @@ struct InsertableGenericArgs<'tcx> {
697697/// While doing so, the currently best spot is stored in `infer_source`.
698698/// For details on how we rank spots, see [Self::source_cost]
699699struct FindInferSourceVisitor < ' a , ' tcx > {
700- infcx : & ' a InferCtxt < ' tcx > ,
700+ tecx : & ' a TypeErrCtxt < ' a , ' tcx > ,
701701 typeck_results : & ' a TypeckResults < ' tcx > ,
702702
703703 target : GenericArg < ' tcx > ,
@@ -709,12 +709,12 @@ struct FindInferSourceVisitor<'a, 'tcx> {
709709
710710impl < ' a , ' tcx > FindInferSourceVisitor < ' a , ' tcx > {
711711 fn new (
712- infcx : & ' a InferCtxt < ' tcx > ,
712+ tecx : & ' a TypeErrCtxt < ' a , ' tcx > ,
713713 typeck_results : & ' a TypeckResults < ' tcx > ,
714714 target : GenericArg < ' tcx > ,
715715 ) -> Self {
716716 FindInferSourceVisitor {
717- infcx ,
717+ tecx ,
718718 typeck_results,
719719
720720 target,
@@ -765,7 +765,7 @@ impl<'a, 'tcx> FindInferSourceVisitor<'a, 'tcx> {
765765 }
766766
767767 // The sources are listed in order of preference here.
768- let tcx = self . infcx . tcx ;
768+ let tcx = self . tecx . tcx ;
769769 let ctx = CostCtxt { tcx } ;
770770 match source. kind {
771771 InferSourceKind :: LetBinding { ty, .. } => ctx. ty_cost ( ty) ,
@@ -816,12 +816,12 @@ impl<'a, 'tcx> FindInferSourceVisitor<'a, 'tcx> {
816816
817817 fn node_args_opt ( & self , hir_id : HirId ) -> Option < GenericArgsRef < ' tcx > > {
818818 let args = self . typeck_results . node_args_opt ( hir_id) ;
819- self . infcx . resolve_vars_if_possible ( args)
819+ self . tecx . resolve_vars_if_possible ( args)
820820 }
821821
822822 fn opt_node_type ( & self , hir_id : HirId ) -> Option < Ty < ' tcx > > {
823823 let ty = self . typeck_results . node_type_opt ( hir_id) ;
824- self . infcx . resolve_vars_if_possible ( ty)
824+ self . tecx . resolve_vars_if_possible ( ty)
825825 }
826826
827827 // Check whether this generic argument is the inference variable we
@@ -836,20 +836,17 @@ impl<'a, 'tcx> FindInferSourceVisitor<'a, 'tcx> {
836836 use ty:: { Infer , TyVar } ;
837837 match ( inner_ty. kind ( ) , target_ty. kind ( ) ) {
838838 ( & Infer ( TyVar ( a_vid) ) , & Infer ( TyVar ( b_vid) ) ) => {
839- self . infcx . inner . borrow_mut ( ) . type_variables ( ) . sub_unified ( a_vid, b_vid)
839+ self . tecx . sub_relations . borrow_mut ( ) . unified ( self . tecx , a_vid, b_vid)
840840 }
841841 _ => false ,
842842 }
843843 }
844844 ( GenericArgKind :: Const ( inner_ct) , GenericArgKind :: Const ( target_ct) ) => {
845845 use ty:: InferConst :: * ;
846846 match ( inner_ct. kind ( ) , target_ct. kind ( ) ) {
847- ( ty:: ConstKind :: Infer ( Var ( a_vid) ) , ty:: ConstKind :: Infer ( Var ( b_vid) ) ) => self
848- . infcx
849- . inner
850- . borrow_mut ( )
851- . const_unification_table ( )
852- . unioned ( a_vid, b_vid) ,
847+ ( ty:: ConstKind :: Infer ( Var ( a_vid) ) , ty:: ConstKind :: Infer ( Var ( b_vid) ) ) => {
848+ self . tecx . inner . borrow_mut ( ) . const_unification_table ( ) . unioned ( a_vid, b_vid)
849+ }
853850 _ => false ,
854851 }
855852 }
@@ -901,7 +898,7 @@ impl<'a, 'tcx> FindInferSourceVisitor<'a, 'tcx> {
901898 & self ,
902899 expr : & ' tcx hir:: Expr < ' tcx > ,
903900 ) -> Box < dyn Iterator < Item = InsertableGenericArgs < ' tcx > > + ' a > {
904- let tcx = self . infcx . tcx ;
901+ let tcx = self . tecx . tcx ;
905902 match expr. kind {
906903 hir:: ExprKind :: Path ( ref path) => {
907904 if let Some ( args) = self . node_args_opt ( expr. hir_id ) {
@@ -964,7 +961,7 @@ impl<'a, 'tcx> FindInferSourceVisitor<'a, 'tcx> {
964961 path : & ' tcx hir:: Path < ' tcx > ,
965962 args : GenericArgsRef < ' tcx > ,
966963 ) -> impl Iterator < Item = InsertableGenericArgs < ' tcx > > + ' a {
967- let tcx = self . infcx . tcx ;
964+ let tcx = self . tecx . tcx ;
968965 let have_turbofish = path. segments . iter ( ) . any ( |segment| {
969966 segment. args . is_some_and ( |args| args. args . iter ( ) . any ( |arg| arg. is_ty_or_const ( ) ) )
970967 } ) ;
@@ -1018,7 +1015,7 @@ impl<'a, 'tcx> FindInferSourceVisitor<'a, 'tcx> {
10181015 args : GenericArgsRef < ' tcx > ,
10191016 qpath : & ' tcx hir:: QPath < ' tcx > ,
10201017 ) -> Box < dyn Iterator < Item = InsertableGenericArgs < ' tcx > > + ' a > {
1021- let tcx = self . infcx . tcx ;
1018+ let tcx = self . tecx . tcx ;
10221019 match qpath {
10231020 hir:: QPath :: Resolved ( _self_ty, path) => {
10241021 Box :: new ( self . resolved_path_inferred_arg_iter ( path, args) )
@@ -1091,7 +1088,7 @@ impl<'a, 'tcx> Visitor<'tcx> for FindInferSourceVisitor<'a, 'tcx> {
10911088 type NestedFilter = nested_filter:: OnlyBodies ;
10921089
10931090 fn nested_visit_map ( & mut self ) -> Self :: Map {
1094- self . infcx . tcx . hir ( )
1091+ self . tecx . tcx . hir ( )
10951092 }
10961093
10971094 fn visit_local ( & mut self , local : & ' tcx Local < ' tcx > ) {
@@ -1147,7 +1144,7 @@ impl<'a, 'tcx> Visitor<'tcx> for FindInferSourceVisitor<'a, 'tcx> {
11471144
11481145 #[ instrument( level = "debug" , skip( self ) ) ]
11491146 fn visit_expr ( & mut self , expr : & ' tcx Expr < ' tcx > ) {
1150- let tcx = self . infcx . tcx ;
1147+ let tcx = self . tecx . tcx ;
11511148 match expr. kind {
11521149 // When encountering `func(arg)` first look into `arg` and then `func`,
11531150 // as `arg` is "more specific".
@@ -1178,7 +1175,7 @@ impl<'a, 'tcx> Visitor<'tcx> for FindInferSourceVisitor<'a, 'tcx> {
11781175 if generics. parent . is_none ( ) && generics. has_self {
11791176 argument_index += 1 ;
11801177 }
1181- let args = self . infcx . resolve_vars_if_possible ( args) ;
1178+ let args = self . tecx . resolve_vars_if_possible ( args) ;
11821179 let generic_args =
11831180 & generics. own_args_no_defaults ( tcx, args) [ generics. own_counts ( ) . lifetimes ..] ;
11841181 let span = match expr. kind {
@@ -1208,7 +1205,7 @@ impl<'a, 'tcx> Visitor<'tcx> for FindInferSourceVisitor<'a, 'tcx> {
12081205 {
12091206 let output = args. as_closure ( ) . sig ( ) . output ( ) . skip_binder ( ) ;
12101207 if self . generic_arg_contains_target ( output. into ( ) ) {
1211- let body = self . infcx . tcx . hir ( ) . body ( body) ;
1208+ let body = self . tecx . tcx . hir ( ) . body ( body) ;
12121209 let should_wrap_expr = if matches ! ( body. value. kind, ExprKind :: Block ( ..) ) {
12131210 None
12141211 } else {
@@ -1236,12 +1233,12 @@ impl<'a, 'tcx> Visitor<'tcx> for FindInferSourceVisitor<'a, 'tcx> {
12361233 && let Some ( args) = self . node_args_opt ( expr. hir_id )
12371234 && args. iter ( ) . any ( |arg| self . generic_arg_contains_target ( arg) )
12381235 && let Some ( def_id) = self . typeck_results . type_dependent_def_id ( expr. hir_id )
1239- && self . infcx . tcx . trait_of_item ( def_id) . is_some ( )
1236+ && self . tecx . tcx . trait_of_item ( def_id) . is_some ( )
12401237 && !has_impl_trait ( def_id)
12411238 {
12421239 let successor =
12431240 method_args. get ( 0 ) . map_or_else ( || ( ")" , span. hi ( ) ) , |arg| ( ", " , arg. span . lo ( ) ) ) ;
1244- let args = self . infcx . resolve_vars_if_possible ( args) ;
1241+ let args = self . tecx . resolve_vars_if_possible ( args) ;
12451242 self . update_infer_source ( InferSource {
12461243 span : path. ident . span ,
12471244 kind : InferSourceKind :: FullyQualifiedMethodCall {
0 commit comments