@@ -512,7 +512,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
512
512
. borrow ( )
513
513
. expr_ty_adjusted_opt ( * expr)
514
514
. unwrap_or_else ( || Ty :: new_misc_error ( tcx) ) ;
515
- ( ty , normalize_span ( expr. span ) )
515
+ ( self . resolve_vars_if_possible ( ty ) , normalize_span ( expr. span ) )
516
516
} )
517
517
. collect ( ) ;
518
518
let callee_expr = match & call_expr. peel_blocks ( ) . kind {
@@ -649,7 +649,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
649
649
}
650
650
651
651
let ( arg_ty, arg_span) = provided_arg_tys[ provided_idx] ;
652
- let arg_ty = self . resolve_vars_if_possible ( arg_ty) ;
653
652
654
653
let expectation = Expectation :: rvalue_hint ( self , expected_input_ty) ;
655
654
let coerced_ty = expectation. only_has_type ( self ) . unwrap_or ( formal_input_ty) ;
@@ -722,11 +721,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
722
721
// Wrap up the N provided arguments starting at this position in a tuple.
723
722
let provided_as_tuple = Ty :: new_tup_from_iter (
724
723
tcx,
725
- provided_arg_tys
726
- . iter ( )
727
- . map ( |( ty, _) | self . resolve_vars_if_possible ( * ty) )
728
- . skip ( mismatch_idx)
729
- . take ( tys. len ( ) ) ,
724
+ provided_arg_tys. iter ( ) . map ( |( ty, _) | * ty) . skip ( mismatch_idx) . take ( tys. len ( ) ) ,
730
725
) ;
731
726
732
727
let mut satisfied = true ;
@@ -737,10 +732,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
737
732
provided_arg_tys. iter ( ) . map ( |( ty, _) | * ty) . skip ( mismatch_idx + tys. len ( ) ) ,
738
733
) ,
739
734
) {
740
- if !self . can_coerce (
741
- self . resolve_vars_if_possible ( provided_ty) ,
742
- self . resolve_vars_if_possible ( * expected_ty) ,
743
- ) {
735
+ if !self . can_coerce ( provided_ty, self . resolve_vars_if_possible ( * expected_ty) ) {
744
736
satisfied = false ;
745
737
break ;
746
738
}
@@ -767,10 +759,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
767
759
mk_trace (
768
760
* lo,
769
761
( formal_ty, expected_ty) ,
770
- self . resolve_vars_if_possible (
771
- provided_arg_tys[ mismatch_idx. into ( ) ] ,
772
- )
773
- . 0 ,
762
+ provided_arg_tys[ mismatch_idx. into ( ) ] . 0 ,
774
763
) ,
775
764
terr,
776
765
) ;
@@ -853,7 +842,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
853
842
return true ;
854
843
} ;
855
844
let ( provided_ty, provided_span) = provided_arg_tys[ * provided_idx] ;
856
- let provided_ty = self . resolve_vars_if_possible ( provided_ty) ;
857
845
let ( formal_ty, expected_ty) = formal_and_expected_inputs[ * expected_idx] ;
858
846
let formal_ty = self . resolve_vars_if_possible ( formal_ty) ;
859
847
let expected_ty = self . resolve_vars_if_possible ( expected_ty) ;
@@ -888,7 +876,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
888
876
let formal_ty = self . resolve_vars_if_possible ( formal_ty) ;
889
877
let expected_ty = self . resolve_vars_if_possible ( expected_ty) ;
890
878
let ( provided_ty, provided_arg_span) = provided_arg_tys[ * provided_idx] ;
891
- let provided_ty = self . resolve_vars_if_possible ( provided_ty) ;
892
879
let trace = mk_trace ( provided_arg_span, ( formal_ty, expected_ty) , provided_ty) ;
893
880
let mut err = self . err_ctxt ( ) . report_and_explain_type_error ( trace, * err) ;
894
881
self . emit_coerce_suggestions (
@@ -903,7 +890,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
903
890
) ;
904
891
err. span_label ( full_call_span, format ! ( "arguments to this {call_name} are incorrect" ) ) ;
905
892
906
- self . emit_generic_mismatches (
893
+ self . label_generic_mismatches (
907
894
& mut err,
908
895
fn_def_id,
909
896
& matched_inputs,
@@ -1019,7 +1006,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1019
1006
let formal_ty = self . resolve_vars_if_possible ( formal_ty) ;
1020
1007
let expected_ty = self . resolve_vars_if_possible ( expected_ty) ;
1021
1008
let ( provided_ty, provided_span) = provided_arg_tys[ provided_idx] ;
1022
- let provided_ty = self . resolve_vars_if_possible ( provided_ty) ;
1023
1009
if let Compatibility :: Incompatible ( error) = compatibility {
1024
1010
let trace = mk_trace ( provided_span, ( formal_ty, expected_ty) , provided_ty) ;
1025
1011
if let Some ( e) = error {
@@ -1048,7 +1034,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1048
1034
}
1049
1035
Error :: Extra ( arg_idx) => {
1050
1036
let ( provided_ty, provided_span) = provided_arg_tys[ arg_idx] ;
1051
- let provided_ty = self . resolve_vars_if_possible ( provided_ty) ;
1052
1037
let provided_ty_name = if !has_error_or_infer ( [ provided_ty] ) {
1053
1038
// FIXME: not suggestable, use something else
1054
1039
format ! ( " of type `{provided_ty}`" )
@@ -1132,12 +1117,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1132
1117
} else {
1133
1118
args_span
1134
1119
} ;
1135
- let rendered =
1136
- if !has_error_or_infer ( [ self . resolve_vars_if_possible ( input_ty) ] ) {
1137
- format ! ( " of type `{input_ty}`" )
1138
- } else {
1139
- "" . to_string ( )
1140
- } ;
1120
+ let rendered = if !has_error_or_infer ( [ input_ty] ) {
1121
+ format ! ( " of type `{input_ty}`" )
1122
+ } else {
1123
+ "" . to_string ( )
1124
+ } ;
1141
1125
labels. push ( ( span, format ! ( "an argument{rendered} is missing" ) ) ) ;
1142
1126
suggestion_text = match suggestion_text {
1143
1127
SuggestionText :: None => SuggestionText :: Provide ( false ) ,
@@ -1244,7 +1228,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1244
1228
second_expected_idx,
1245
1229
) => {
1246
1230
let ( first_provided_ty, first_span) = provided_arg_tys[ first_provided_idx] ;
1247
- let first_provided_ty = self . resolve_vars_if_possible ( first_provided_ty) ;
1248
1231
let ( _, first_expected_ty) = formal_and_expected_inputs[ first_expected_idx] ;
1249
1232
let first_expected_ty = self . resolve_vars_if_possible ( first_expected_ty) ;
1250
1233
let first_provided_ty_name = if !has_error_or_infer ( [ first_provided_ty] ) {
@@ -1258,7 +1241,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1258
1241
) ) ;
1259
1242
1260
1243
let ( second_provided_ty, second_span) = provided_arg_tys[ second_provided_idx] ;
1261
- let second_provided_ty = self . resolve_vars_if_possible ( second_provided_ty) ;
1262
1244
let ( _, second_expected_ty) = formal_and_expected_inputs[ second_expected_idx] ;
1263
1245
let second_provided_ty = self . resolve_vars_if_possible ( second_provided_ty) ;
1264
1246
let second_provided_ty_name = if !has_error_or_infer ( [ second_provided_ty] ) {
@@ -1281,7 +1263,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1281
1263
let ( _, expected_ty) = formal_and_expected_inputs[ dst_arg] ;
1282
1264
let expected_ty = self . resolve_vars_if_possible ( expected_ty) ;
1283
1265
let ( provided_ty, provided_span) = provided_arg_tys[ dest_input] ;
1284
- let provided_ty = self . resolve_vars_if_possible ( provided_ty) ;
1285
1266
let provided_ty_name = if !has_error_or_infer ( [ provided_ty] ) {
1286
1267
format ! ( ", found `{provided_ty}`" )
1287
1268
} else {
@@ -1301,7 +1282,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1301
1282
}
1302
1283
}
1303
1284
1304
- self . emit_generic_mismatches (
1285
+ self . label_generic_mismatches (
1305
1286
& mut err,
1306
1287
fn_def_id,
1307
1288
& matched_inputs,
@@ -2259,7 +2240,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
2259
2240
. collect ( ) ;
2260
2241
2261
2242
if params. len ( ) == param_generics. len ( ) {
2262
- // TODO: IndexVec or something like that from data structures better?
2263
2243
let mut generics_map: Vec < ( usize , & hir:: GenericParam < ' _ > ) > = Vec :: new ( ) ;
2264
2244
// This is a map from the index of the generic to the index of the parameter and the
2265
2245
// parameter
@@ -2480,7 +2460,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
2480
2460
}
2481
2461
}
2482
2462
2483
- fn emit_generic_mismatches (
2463
+ fn label_generic_mismatches (
2484
2464
& self ,
2485
2465
err : & mut DiagnosticBuilder < ' _ > ,
2486
2466
callable_def_id : Option < DefId > ,
@@ -2516,7 +2496,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
2516
2496
. filter ( |( idx, _) | * idx > matched_idx)
2517
2497
{
2518
2498
if let ty:: Infer ( ty:: TyVar ( b) ) = formal_ty. kind ( ) {
2519
- if self . check_ty_vars_equal ( * a, * b) {
2499
+ if self . root_var ( * a) == self . root_var ( * b) {
2520
2500
formal_ty_idxs_matched. push ( input_idx. into ( ) ) ;
2521
2501
if expected_ty_matched. is_none ( ) {
2522
2502
expected_ty_matched = Some ( expected_ty) ;
0 commit comments