@@ -711,38 +711,38 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
711
711
}
712
712
}
713
713
714
- OutputTypeParameterMismatch ( ref expected_trait_ref, ref actual_trait_ref, _) => {
714
+ OutputTypeParameterMismatch ( ref found_trait_ref, ref expected_trait_ref, _) => {
715
+ let found_trait_ref = self . resolve_type_vars_if_possible ( & * found_trait_ref) ;
715
716
let expected_trait_ref = self . resolve_type_vars_if_possible ( & * expected_trait_ref) ;
716
- let actual_trait_ref = self . resolve_type_vars_if_possible ( & * actual_trait_ref) ;
717
- if actual_trait_ref. self_ty ( ) . references_error ( ) {
717
+ if expected_trait_ref. self_ty ( ) . references_error ( ) {
718
718
return ;
719
719
}
720
- let expected_trait_ty = expected_trait_ref . self_ty ( ) ;
720
+ let found_trait_ty = found_trait_ref . self_ty ( ) ;
721
721
722
- let found_did = expected_trait_ty . ty_to_def_id ( ) ;
722
+ let found_did = found_trait_ty . ty_to_def_id ( ) ;
723
723
let found_span = found_did. and_then ( |did| {
724
724
self . tcx . hir . span_if_local ( did)
725
725
} ) ;
726
726
727
- let self_ty_count =
728
- match expected_trait_ref . skip_binder ( ) . substs . type_at ( 1 ) . sty {
727
+ let found_ty_count =
728
+ match found_trait_ref . skip_binder ( ) . substs . type_at ( 1 ) . sty {
729
729
ty:: TyTuple ( ref tys, _) => tys. len ( ) ,
730
730
_ => 1 ,
731
731
} ;
732
- let ( arg_tys , arg_ty_count ) =
733
- match actual_trait_ref . skip_binder ( ) . substs . type_at ( 1 ) . sty {
732
+ let ( expected_tys , expected_ty_count ) =
733
+ match expected_trait_ref . skip_binder ( ) . substs . type_at ( 1 ) . sty {
734
734
ty:: TyTuple ( ref tys, _) =>
735
735
( tys. iter ( ) . map ( |t| & t. sty ) . collect ( ) , tys. len ( ) ) ,
736
736
ref sty => ( vec ! [ sty] , 1 ) ,
737
737
} ;
738
- if self_ty_count == arg_ty_count {
738
+ if found_ty_count == expected_ty_count {
739
739
self . report_closure_arg_mismatch ( span,
740
740
found_span,
741
- expected_trait_ref ,
742
- actual_trait_ref )
741
+ found_trait_ref ,
742
+ expected_trait_ref )
743
743
} else {
744
- let arg_tuple = if arg_ty_count == 1 {
745
- arg_tys . first ( ) . and_then ( |t| {
744
+ let expected_tuple = if expected_ty_count == 1 {
745
+ expected_tys . first ( ) . and_then ( |t| {
746
746
if let & & ty:: TyTuple ( ref tuptys, _) = t {
747
747
Some ( tuptys. len ( ) )
748
748
} else {
@@ -753,15 +753,15 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
753
753
None
754
754
} ;
755
755
756
- // FIXME(#44150): Expand this to "N args expected bug a N-tuple found".
756
+ // FIXME(#44150): Expand this to "N args expected but a N-tuple found."
757
757
// Type of the 1st expected argument is somehow provided as type of a
758
758
// found one in that case.
759
759
//
760
760
// ```
761
761
// [1i32, 2, 3].sort_by(|(a, b)| ..)
762
762
// // ^^^^^^^^
763
- // // actual_trait_ref : std::ops::FnMut<(&i32, &i32)>
764
- // // expected_trait_ref : std::ops::FnMut<(&i32,)>
763
+ // // expected_trait_ref : std::ops::FnMut<(&i32, &i32)>
764
+ // // found_trait_ref : std::ops::FnMut<(&i32,)>
765
765
// ```
766
766
767
767
let closure_args_span = found_did. and_then ( |did| self . tcx . hir . get_if_local ( did) )
@@ -778,10 +778,10 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
778
778
self . report_arg_count_mismatch (
779
779
span,
780
780
closure_args_span. or ( found_span) ,
781
- arg_ty_count ,
782
- arg_tuple ,
783
- self_ty_count ,
784
- expected_trait_ty . is_closure ( )
781
+ expected_ty_count ,
782
+ expected_tuple ,
783
+ found_ty_count ,
784
+ found_trait_ty . is_closure ( )
785
785
)
786
786
}
787
787
}
0 commit comments