@@ -489,7 +489,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
489
489
parent_name,
490
490
} ) ;
491
491
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)
493
493
== Some ( generics_def_id)
494
494
{
495
495
"Vec<_>" . to_string ( )
@@ -697,7 +697,7 @@ struct InsertableGenericArgs<'tcx> {
697
697
/// While doing so, the currently best spot is stored in `infer_source`.
698
698
/// For details on how we rank spots, see [Self::source_cost]
699
699
struct FindInferSourceVisitor < ' a , ' tcx > {
700
- infcx : & ' a InferCtxt < ' tcx > ,
700
+ tecx : & ' a TypeErrCtxt < ' a , ' tcx > ,
701
701
typeck_results : & ' a TypeckResults < ' tcx > ,
702
702
703
703
target : GenericArg < ' tcx > ,
@@ -709,12 +709,12 @@ struct FindInferSourceVisitor<'a, 'tcx> {
709
709
710
710
impl < ' a , ' tcx > FindInferSourceVisitor < ' a , ' tcx > {
711
711
fn new (
712
- infcx : & ' a InferCtxt < ' tcx > ,
712
+ tecx : & ' a TypeErrCtxt < ' a , ' tcx > ,
713
713
typeck_results : & ' a TypeckResults < ' tcx > ,
714
714
target : GenericArg < ' tcx > ,
715
715
) -> Self {
716
716
FindInferSourceVisitor {
717
- infcx ,
717
+ tecx ,
718
718
typeck_results,
719
719
720
720
target,
@@ -765,7 +765,7 @@ impl<'a, 'tcx> FindInferSourceVisitor<'a, 'tcx> {
765
765
}
766
766
767
767
// The sources are listed in order of preference here.
768
- let tcx = self . infcx . tcx ;
768
+ let tcx = self . tecx . tcx ;
769
769
let ctx = CostCtxt { tcx } ;
770
770
match source. kind {
771
771
InferSourceKind :: LetBinding { ty, .. } => ctx. ty_cost ( ty) ,
@@ -816,12 +816,12 @@ impl<'a, 'tcx> FindInferSourceVisitor<'a, 'tcx> {
816
816
817
817
fn node_args_opt ( & self , hir_id : HirId ) -> Option < GenericArgsRef < ' tcx > > {
818
818
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)
820
820
}
821
821
822
822
fn opt_node_type ( & self , hir_id : HirId ) -> Option < Ty < ' tcx > > {
823
823
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)
825
825
}
826
826
827
827
// Check whether this generic argument is the inference variable we
@@ -836,20 +836,17 @@ impl<'a, 'tcx> FindInferSourceVisitor<'a, 'tcx> {
836
836
use ty:: { Infer , TyVar } ;
837
837
match ( inner_ty. kind ( ) , target_ty. kind ( ) ) {
838
838
( & 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)
840
840
}
841
841
_ => false ,
842
842
}
843
843
}
844
844
( GenericArgKind :: Const ( inner_ct) , GenericArgKind :: Const ( target_ct) ) => {
845
845
use ty:: InferConst :: * ;
846
846
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
+ }
853
850
_ => false ,
854
851
}
855
852
}
@@ -901,7 +898,7 @@ impl<'a, 'tcx> FindInferSourceVisitor<'a, 'tcx> {
901
898
& self ,
902
899
expr : & ' tcx hir:: Expr < ' tcx > ,
903
900
) -> Box < dyn Iterator < Item = InsertableGenericArgs < ' tcx > > + ' a > {
904
- let tcx = self . infcx . tcx ;
901
+ let tcx = self . tecx . tcx ;
905
902
match expr. kind {
906
903
hir:: ExprKind :: Path ( ref path) => {
907
904
if let Some ( args) = self . node_args_opt ( expr. hir_id ) {
@@ -964,7 +961,7 @@ impl<'a, 'tcx> FindInferSourceVisitor<'a, 'tcx> {
964
961
path : & ' tcx hir:: Path < ' tcx > ,
965
962
args : GenericArgsRef < ' tcx > ,
966
963
) -> impl Iterator < Item = InsertableGenericArgs < ' tcx > > + ' a {
967
- let tcx = self . infcx . tcx ;
964
+ let tcx = self . tecx . tcx ;
968
965
let have_turbofish = path. segments . iter ( ) . any ( |segment| {
969
966
segment. args . is_some_and ( |args| args. args . iter ( ) . any ( |arg| arg. is_ty_or_const ( ) ) )
970
967
} ) ;
@@ -1018,7 +1015,7 @@ impl<'a, 'tcx> FindInferSourceVisitor<'a, 'tcx> {
1018
1015
args : GenericArgsRef < ' tcx > ,
1019
1016
qpath : & ' tcx hir:: QPath < ' tcx > ,
1020
1017
) -> Box < dyn Iterator < Item = InsertableGenericArgs < ' tcx > > + ' a > {
1021
- let tcx = self . infcx . tcx ;
1018
+ let tcx = self . tecx . tcx ;
1022
1019
match qpath {
1023
1020
hir:: QPath :: Resolved ( _self_ty, path) => {
1024
1021
Box :: new ( self . resolved_path_inferred_arg_iter ( path, args) )
@@ -1091,7 +1088,7 @@ impl<'a, 'tcx> Visitor<'tcx> for FindInferSourceVisitor<'a, 'tcx> {
1091
1088
type NestedFilter = nested_filter:: OnlyBodies ;
1092
1089
1093
1090
fn nested_visit_map ( & mut self ) -> Self :: Map {
1094
- self . infcx . tcx . hir ( )
1091
+ self . tecx . tcx . hir ( )
1095
1092
}
1096
1093
1097
1094
fn visit_local ( & mut self , local : & ' tcx Local < ' tcx > ) {
@@ -1147,7 +1144,7 @@ impl<'a, 'tcx> Visitor<'tcx> for FindInferSourceVisitor<'a, 'tcx> {
1147
1144
1148
1145
#[ instrument( level = "debug" , skip( self ) ) ]
1149
1146
fn visit_expr ( & mut self , expr : & ' tcx Expr < ' tcx > ) {
1150
- let tcx = self . infcx . tcx ;
1147
+ let tcx = self . tecx . tcx ;
1151
1148
match expr. kind {
1152
1149
// When encountering `func(arg)` first look into `arg` and then `func`,
1153
1150
// as `arg` is "more specific".
@@ -1178,7 +1175,7 @@ impl<'a, 'tcx> Visitor<'tcx> for FindInferSourceVisitor<'a, 'tcx> {
1178
1175
if generics. parent . is_none ( ) && generics. has_self {
1179
1176
argument_index += 1 ;
1180
1177
}
1181
- let args = self . infcx . resolve_vars_if_possible ( args) ;
1178
+ let args = self . tecx . resolve_vars_if_possible ( args) ;
1182
1179
let generic_args =
1183
1180
& generics. own_args_no_defaults ( tcx, args) [ generics. own_counts ( ) . lifetimes ..] ;
1184
1181
let span = match expr. kind {
@@ -1208,7 +1205,7 @@ impl<'a, 'tcx> Visitor<'tcx> for FindInferSourceVisitor<'a, 'tcx> {
1208
1205
{
1209
1206
let output = args. as_closure ( ) . sig ( ) . output ( ) . skip_binder ( ) ;
1210
1207
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) ;
1212
1209
let should_wrap_expr = if matches ! ( body. value. kind, ExprKind :: Block ( ..) ) {
1213
1210
None
1214
1211
} else {
@@ -1236,12 +1233,12 @@ impl<'a, 'tcx> Visitor<'tcx> for FindInferSourceVisitor<'a, 'tcx> {
1236
1233
&& let Some ( args) = self . node_args_opt ( expr. hir_id )
1237
1234
&& args. iter ( ) . any ( |arg| self . generic_arg_contains_target ( arg) )
1238
1235
&& 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 ( )
1240
1237
&& !has_impl_trait ( def_id)
1241
1238
{
1242
1239
let successor =
1243
1240
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) ;
1245
1242
self . update_infer_source ( InferSource {
1246
1243
span : path. ident . span ,
1247
1244
kind : InferSourceKind :: FullyQualifiedMethodCall {
0 commit comments