@@ -502,7 +502,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
502
502
parent_name,
503
503
} ) ;
504
504
505
- let args = if self . infcx . tcx . get_diagnostic_item ( sym:: iterator_collect_fn)
505
+ let args = if self . tcx . get_diagnostic_item ( sym:: iterator_collect_fn)
506
506
== Some ( generics_def_id)
507
507
{
508
508
"Vec<_>" . to_string ( )
@@ -710,7 +710,7 @@ struct InsertableGenericArgs<'tcx> {
710
710
/// While doing so, the currently best spot is stored in `infer_source`.
711
711
/// For details on how we rank spots, see [Self::source_cost]
712
712
struct FindInferSourceVisitor < ' a , ' tcx > {
713
- infcx : & ' a InferCtxt < ' tcx > ,
713
+ tecx : & ' a TypeErrCtxt < ' a , ' tcx > ,
714
714
typeck_results : & ' a TypeckResults < ' tcx > ,
715
715
716
716
target : GenericArg < ' tcx > ,
@@ -722,12 +722,12 @@ struct FindInferSourceVisitor<'a, 'tcx> {
722
722
723
723
impl < ' a , ' tcx > FindInferSourceVisitor < ' a , ' tcx > {
724
724
fn new (
725
- infcx : & ' a InferCtxt < ' tcx > ,
725
+ tecx : & ' a TypeErrCtxt < ' a , ' tcx > ,
726
726
typeck_results : & ' a TypeckResults < ' tcx > ,
727
727
target : GenericArg < ' tcx > ,
728
728
) -> Self {
729
729
FindInferSourceVisitor {
730
- infcx ,
730
+ tecx ,
731
731
typeck_results,
732
732
733
733
target,
@@ -778,7 +778,7 @@ impl<'a, 'tcx> FindInferSourceVisitor<'a, 'tcx> {
778
778
}
779
779
780
780
// The sources are listed in order of preference here.
781
- let tcx = self . infcx . tcx ;
781
+ let tcx = self . tecx . tcx ;
782
782
let ctx = CostCtxt { tcx } ;
783
783
match source. kind {
784
784
InferSourceKind :: LetBinding { ty, .. } => ctx. ty_cost ( ty) ,
@@ -829,12 +829,12 @@ impl<'a, 'tcx> FindInferSourceVisitor<'a, 'tcx> {
829
829
830
830
fn node_args_opt ( & self , hir_id : HirId ) -> Option < GenericArgsRef < ' tcx > > {
831
831
let args = self . typeck_results . node_args_opt ( hir_id) ;
832
- self . infcx . resolve_vars_if_possible ( args)
832
+ self . tecx . resolve_vars_if_possible ( args)
833
833
}
834
834
835
835
fn opt_node_type ( & self , hir_id : HirId ) -> Option < Ty < ' tcx > > {
836
836
let ty = self . typeck_results . node_type_opt ( hir_id) ;
837
- self . infcx . resolve_vars_if_possible ( ty)
837
+ self . tecx . resolve_vars_if_possible ( ty)
838
838
}
839
839
840
840
// Check whether this generic argument is the inference variable we
@@ -849,20 +849,17 @@ impl<'a, 'tcx> FindInferSourceVisitor<'a, 'tcx> {
849
849
use ty:: { Infer , TyVar } ;
850
850
match ( inner_ty. kind ( ) , target_ty. kind ( ) ) {
851
851
( & Infer ( TyVar ( a_vid) ) , & Infer ( TyVar ( b_vid) ) ) => {
852
- self . infcx . inner . borrow_mut ( ) . type_variables ( ) . sub_unified ( a_vid, b_vid)
852
+ self . tecx . sub_relations . borrow_mut ( ) . unified ( self . tecx , a_vid, b_vid)
853
853
}
854
854
_ => false ,
855
855
}
856
856
}
857
857
( GenericArgKind :: Const ( inner_ct) , GenericArgKind :: Const ( target_ct) ) => {
858
858
use ty:: InferConst :: * ;
859
859
match ( inner_ct. kind ( ) , target_ct. kind ( ) ) {
860
- ( ty:: ConstKind :: Infer ( Var ( a_vid) ) , ty:: ConstKind :: Infer ( Var ( b_vid) ) ) => self
861
- . infcx
862
- . inner
863
- . borrow_mut ( )
864
- . const_unification_table ( )
865
- . unioned ( a_vid, b_vid) ,
860
+ ( ty:: ConstKind :: Infer ( Var ( a_vid) ) , ty:: ConstKind :: Infer ( Var ( b_vid) ) ) => {
861
+ self . tecx . inner . borrow_mut ( ) . const_unification_table ( ) . unioned ( a_vid, b_vid)
862
+ }
866
863
_ => false ,
867
864
}
868
865
}
@@ -914,7 +911,7 @@ impl<'a, 'tcx> FindInferSourceVisitor<'a, 'tcx> {
914
911
& self ,
915
912
expr : & ' tcx hir:: Expr < ' tcx > ,
916
913
) -> Box < dyn Iterator < Item = InsertableGenericArgs < ' tcx > > + ' a > {
917
- let tcx = self . infcx . tcx ;
914
+ let tcx = self . tecx . tcx ;
918
915
match expr. kind {
919
916
hir:: ExprKind :: Path ( ref path) => {
920
917
if let Some ( args) = self . node_args_opt ( expr. hir_id ) {
@@ -977,7 +974,7 @@ impl<'a, 'tcx> FindInferSourceVisitor<'a, 'tcx> {
977
974
path : & ' tcx hir:: Path < ' tcx > ,
978
975
args : GenericArgsRef < ' tcx > ,
979
976
) -> impl Iterator < Item = InsertableGenericArgs < ' tcx > > + ' a {
980
- let tcx = self . infcx . tcx ;
977
+ let tcx = self . tecx . tcx ;
981
978
let have_turbofish = path. segments . iter ( ) . any ( |segment| {
982
979
segment. args . is_some_and ( |args| args. args . iter ( ) . any ( |arg| arg. is_ty_or_const ( ) ) )
983
980
} ) ;
@@ -1031,7 +1028,7 @@ impl<'a, 'tcx> FindInferSourceVisitor<'a, 'tcx> {
1031
1028
args : GenericArgsRef < ' tcx > ,
1032
1029
qpath : & ' tcx hir:: QPath < ' tcx > ,
1033
1030
) -> Box < dyn Iterator < Item = InsertableGenericArgs < ' tcx > > + ' a > {
1034
- let tcx = self . infcx . tcx ;
1031
+ let tcx = self . tecx . tcx ;
1035
1032
match qpath {
1036
1033
hir:: QPath :: Resolved ( _self_ty, path) => {
1037
1034
Box :: new ( self . resolved_path_inferred_arg_iter ( path, args) )
@@ -1104,7 +1101,7 @@ impl<'a, 'tcx> Visitor<'tcx> for FindInferSourceVisitor<'a, 'tcx> {
1104
1101
type NestedFilter = nested_filter:: OnlyBodies ;
1105
1102
1106
1103
fn nested_visit_map ( & mut self ) -> Self :: Map {
1107
- self . infcx . tcx . hir ( )
1104
+ self . tecx . tcx . hir ( )
1108
1105
}
1109
1106
1110
1107
fn visit_local ( & mut self , local : & ' tcx Local < ' tcx > ) {
@@ -1160,7 +1157,7 @@ impl<'a, 'tcx> Visitor<'tcx> for FindInferSourceVisitor<'a, 'tcx> {
1160
1157
1161
1158
#[ instrument( level = "debug" , skip( self ) ) ]
1162
1159
fn visit_expr ( & mut self , expr : & ' tcx Expr < ' tcx > ) {
1163
- let tcx = self . infcx . tcx ;
1160
+ let tcx = self . tecx . tcx ;
1164
1161
match expr. kind {
1165
1162
// When encountering `func(arg)` first look into `arg` and then `func`,
1166
1163
// as `arg` is "more specific".
@@ -1191,7 +1188,7 @@ impl<'a, 'tcx> Visitor<'tcx> for FindInferSourceVisitor<'a, 'tcx> {
1191
1188
if generics. parent . is_none ( ) && generics. has_self {
1192
1189
argument_index += 1 ;
1193
1190
}
1194
- let args = self . infcx . resolve_vars_if_possible ( args) ;
1191
+ let args = self . tecx . resolve_vars_if_possible ( args) ;
1195
1192
let generic_args =
1196
1193
& generics. own_args_no_defaults ( tcx, args) [ generics. own_counts ( ) . lifetimes ..] ;
1197
1194
let span = match expr. kind {
@@ -1221,7 +1218,7 @@ impl<'a, 'tcx> Visitor<'tcx> for FindInferSourceVisitor<'a, 'tcx> {
1221
1218
{
1222
1219
let output = args. as_closure ( ) . sig ( ) . output ( ) . skip_binder ( ) ;
1223
1220
if self . generic_arg_contains_target ( output. into ( ) ) {
1224
- let body = self . infcx . tcx . hir ( ) . body ( body) ;
1221
+ let body = self . tecx . tcx . hir ( ) . body ( body) ;
1225
1222
let should_wrap_expr = if matches ! ( body. value. kind, ExprKind :: Block ( ..) ) {
1226
1223
None
1227
1224
} else {
@@ -1249,12 +1246,12 @@ impl<'a, 'tcx> Visitor<'tcx> for FindInferSourceVisitor<'a, 'tcx> {
1249
1246
&& let Some ( args) = self . node_args_opt ( expr. hir_id )
1250
1247
&& args. iter ( ) . any ( |arg| self . generic_arg_contains_target ( arg) )
1251
1248
&& let Some ( def_id) = self . typeck_results . type_dependent_def_id ( expr. hir_id )
1252
- && self . infcx . tcx . trait_of_item ( def_id) . is_some ( )
1249
+ && self . tecx . tcx . trait_of_item ( def_id) . is_some ( )
1253
1250
&& !has_impl_trait ( def_id)
1254
1251
{
1255
1252
let successor =
1256
1253
method_args. get ( 0 ) . map_or_else ( || ( ")" , span. hi ( ) ) , |arg| ( ", " , arg. span . lo ( ) ) ) ;
1257
- let args = self . infcx . resolve_vars_if_possible ( args) ;
1254
+ let args = self . tecx . resolve_vars_if_possible ( args) ;
1258
1255
self . update_infer_source ( InferSource {
1259
1256
span : path. ident . span ,
1260
1257
kind : InferSourceKind :: FullyQualifiedMethodCall {
0 commit comments