@@ -938,51 +938,50 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
938
938
err
939
939
}
940
940
941
+ fn build_fn_sig_string ( & self , trait_ref : & ty:: TraitRef < ' tcx > ) -> String {
942
+ let inputs = trait_ref. substs . type_at ( 1 ) ;
943
+ let sig = if let ty:: TyTuple ( inputs, _) = inputs. sty {
944
+ self . tcx . mk_fn_sig (
945
+ inputs. iter ( ) . map ( |& x| x) ,
946
+ self . tcx . mk_infer ( ty:: TyVar ( ty:: TyVid { index : 0 } ) ) ,
947
+ false ,
948
+ hir:: Unsafety :: Normal ,
949
+ :: syntax:: abi:: Abi :: Rust
950
+ )
951
+ } else {
952
+ self . tcx . mk_fn_sig (
953
+ :: std:: iter:: once ( inputs) ,
954
+ self . tcx . mk_infer ( ty:: TyVar ( ty:: TyVid { index : 0 } ) ) ,
955
+ false ,
956
+ hir:: Unsafety :: Normal ,
957
+ :: syntax:: abi:: Abi :: Rust
958
+ )
959
+ } ;
960
+ format ! ( "{}" , ty:: Binder ( sig) )
961
+ }
962
+
941
963
fn report_closure_arg_mismatch ( & self ,
942
- span : Span ,
943
- found_span : Option < Span > ,
944
- expected_ref : ty:: PolyTraitRef < ' tcx > ,
945
- found : ty:: PolyTraitRef < ' tcx > )
964
+ span : Span ,
965
+ found_span : Option < Span > ,
966
+ expected_ref : ty:: PolyTraitRef < ' tcx > ,
967
+ found : ty:: PolyTraitRef < ' tcx > )
946
968
-> DiagnosticBuilder < ' tcx >
947
969
{
948
- fn build_fn_sig_string < ' a , ' gcx , ' tcx > ( tcx : ty:: TyCtxt < ' a , ' gcx , ' tcx > ,
949
- trait_ref : & ty:: TraitRef < ' tcx > ) -> String {
950
- let inputs = trait_ref. substs . type_at ( 1 ) ;
951
- let sig = if let ty:: TyTuple ( inputs, _) = inputs. sty {
952
- tcx. mk_fn_sig (
953
- inputs. iter ( ) . map ( |& x| x) ,
954
- tcx. mk_infer ( ty:: TyVar ( ty:: TyVid { index : 0 } ) ) ,
955
- false ,
956
- hir:: Unsafety :: Normal ,
957
- :: syntax:: abi:: Abi :: Rust
958
- )
959
- } else {
960
- tcx. mk_fn_sig (
961
- :: std:: iter:: once ( inputs) ,
962
- tcx. mk_infer ( ty:: TyVar ( ty:: TyVid { index : 0 } ) ) ,
963
- false ,
964
- hir:: Unsafety :: Normal ,
965
- :: syntax:: abi:: Abi :: Rust
966
- )
967
- } ;
968
- format ! ( "{}" , ty:: Binder ( sig) )
969
- }
970
-
971
970
let argument_is_closure = expected_ref. skip_binder ( ) . substs . type_at ( 0 ) . is_closure ( ) ;
972
971
let mut err = struct_span_err ! ( self . tcx. sess, span, E0631 ,
973
972
"type mismatch in {} arguments" ,
974
973
if argument_is_closure { "closure" } else { "function" } ) ;
975
974
976
975
let found_str = format ! (
977
976
"expected signature of `{}`" ,
978
- build_fn_sig_string ( self . tcx , found. skip_binder( ) )
977
+ self . build_fn_sig_string ( found. skip_binder( ) )
979
978
) ;
980
979
err. span_label ( span, found_str) ;
981
980
982
981
let found_span = found_span. unwrap_or ( span) ;
983
982
let expected_str = format ! (
984
983
"found signature of `{}`" ,
985
- build_fn_sig_string ( self . tcx , expected_ref. skip_binder( ) )
984
+ self . build_fn_sig_string ( expected_ref. skip_binder( ) )
986
985
) ;
987
986
err. span_label ( found_span, expected_str) ;
988
987
0 commit comments