@@ -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
}
@@ -917,7 +914,7 @@ impl<'a, 'tcx> FindInferSourceVisitor<'a, 'tcx> {
917
914
& self ,
918
915
expr : & ' tcx hir:: Expr < ' tcx > ,
919
916
) -> Box < dyn Iterator < Item = InsertableGenericArgs < ' tcx > > + ' a > {
920
- let tcx = self . infcx . tcx ;
917
+ let tcx = self . tecx . tcx ;
921
918
match expr. kind {
922
919
hir:: ExprKind :: Path ( ref path) => {
923
920
if let Some ( args) = self . node_args_opt ( expr. hir_id ) {
@@ -980,7 +977,7 @@ impl<'a, 'tcx> FindInferSourceVisitor<'a, 'tcx> {
980
977
path : & ' tcx hir:: Path < ' tcx > ,
981
978
args : GenericArgsRef < ' tcx > ,
982
979
) -> impl Iterator < Item = InsertableGenericArgs < ' tcx > > + ' a {
983
- let tcx = self . infcx . tcx ;
980
+ let tcx = self . tecx . tcx ;
984
981
let have_turbofish = path. segments . iter ( ) . any ( |segment| {
985
982
segment. args . is_some_and ( |args| args. args . iter ( ) . any ( |arg| arg. is_ty_or_const ( ) ) )
986
983
} ) ;
@@ -1034,7 +1031,7 @@ impl<'a, 'tcx> FindInferSourceVisitor<'a, 'tcx> {
1034
1031
args : GenericArgsRef < ' tcx > ,
1035
1032
qpath : & ' tcx hir:: QPath < ' tcx > ,
1036
1033
) -> Box < dyn Iterator < Item = InsertableGenericArgs < ' tcx > > + ' a > {
1037
- let tcx = self . infcx . tcx ;
1034
+ let tcx = self . tecx . tcx ;
1038
1035
match qpath {
1039
1036
hir:: QPath :: Resolved ( _self_ty, path) => {
1040
1037
Box :: new ( self . resolved_path_inferred_arg_iter ( path, args) )
@@ -1107,7 +1104,7 @@ impl<'a, 'tcx> Visitor<'tcx> for FindInferSourceVisitor<'a, 'tcx> {
1107
1104
type NestedFilter = nested_filter:: OnlyBodies ;
1108
1105
1109
1106
fn nested_visit_map ( & mut self ) -> Self :: Map {
1110
- self . infcx . tcx . hir ( )
1107
+ self . tecx . tcx . hir ( )
1111
1108
}
1112
1109
1113
1110
fn visit_local ( & mut self , local : & ' tcx Local < ' tcx > ) {
@@ -1163,7 +1160,7 @@ impl<'a, 'tcx> Visitor<'tcx> for FindInferSourceVisitor<'a, 'tcx> {
1163
1160
1164
1161
#[ instrument( level = "debug" , skip( self ) ) ]
1165
1162
fn visit_expr ( & mut self , expr : & ' tcx Expr < ' tcx > ) {
1166
- let tcx = self . infcx . tcx ;
1163
+ let tcx = self . tecx . tcx ;
1167
1164
match expr. kind {
1168
1165
// When encountering `func(arg)` first look into `arg` and then `func`,
1169
1166
// as `arg` is "more specific".
@@ -1194,7 +1191,7 @@ impl<'a, 'tcx> Visitor<'tcx> for FindInferSourceVisitor<'a, 'tcx> {
1194
1191
if generics. parent . is_none ( ) && generics. has_self {
1195
1192
argument_index += 1 ;
1196
1193
}
1197
- let args = self . infcx . resolve_vars_if_possible ( args) ;
1194
+ let args = self . tecx . resolve_vars_if_possible ( args) ;
1198
1195
let generic_args =
1199
1196
& generics. own_args_no_defaults ( tcx, args) [ generics. own_counts ( ) . lifetimes ..] ;
1200
1197
let span = match expr. kind {
@@ -1224,7 +1221,7 @@ impl<'a, 'tcx> Visitor<'tcx> for FindInferSourceVisitor<'a, 'tcx> {
1224
1221
{
1225
1222
let output = args. as_closure ( ) . sig ( ) . output ( ) . skip_binder ( ) ;
1226
1223
if self . generic_arg_contains_target ( output. into ( ) ) {
1227
- let body = self . infcx . tcx . hir ( ) . body ( body) ;
1224
+ let body = self . tecx . tcx . hir ( ) . body ( body) ;
1228
1225
let should_wrap_expr = if matches ! ( body. value. kind, ExprKind :: Block ( ..) ) {
1229
1226
None
1230
1227
} else {
@@ -1252,12 +1249,12 @@ impl<'a, 'tcx> Visitor<'tcx> for FindInferSourceVisitor<'a, 'tcx> {
1252
1249
&& let Some ( args) = self . node_args_opt ( expr. hir_id )
1253
1250
&& args. iter ( ) . any ( |arg| self . generic_arg_contains_target ( arg) )
1254
1251
&& let Some ( def_id) = self . typeck_results . type_dependent_def_id ( expr. hir_id )
1255
- && self . infcx . tcx . trait_of_item ( def_id) . is_some ( )
1252
+ && self . tecx . tcx . trait_of_item ( def_id) . is_some ( )
1256
1253
&& !has_impl_trait ( def_id)
1257
1254
{
1258
1255
let successor =
1259
1256
method_args. get ( 0 ) . map_or_else ( || ( ")" , span. hi ( ) ) , |arg| ( ", " , arg. span . lo ( ) ) ) ;
1260
- let args = self . infcx . resolve_vars_if_possible ( args) ;
1257
+ let args = self . tecx . resolve_vars_if_possible ( args) ;
1261
1258
self . update_infer_source ( InferSource {
1262
1259
span : path. ident . span ,
1263
1260
kind : InferSourceKind :: FullyQualifiedMethodCall {
0 commit comments