@@ -20,6 +20,7 @@ use rustc_hir::def_id::DefId;
2020use rustc_hir:: intravisit:: Visitor ;
2121use rustc_hir:: lang_items:: LangItem ;
2222use rustc_hir:: { AsyncGeneratorKind , GeneratorKind , Node } ;
23+ use rustc_infer:: infer:: type_variable:: { TypeVariableOrigin , TypeVariableOriginKind } ;
2324use rustc_middle:: hir:: map;
2425use rustc_middle:: ty:: {
2526 self , suggest_arbitrary_trait_bound, suggest_constraining_type_param, AdtKind , DefIdTree ,
@@ -1584,32 +1585,38 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
15841585 expected : ty:: PolyTraitRef < ' tcx > ,
15851586 ) -> DiagnosticBuilder < ' tcx , ErrorGuaranteed > {
15861587 pub ( crate ) fn build_fn_sig_ty < ' tcx > (
1587- tcx : TyCtxt < ' tcx > ,
1588+ infcx : & InferCtxt < ' _ , ' tcx > ,
15881589 trait_ref : ty:: PolyTraitRef < ' tcx > ,
15891590 ) -> Ty < ' tcx > {
15901591 let inputs = trait_ref. skip_binder ( ) . substs . type_at ( 1 ) ;
15911592 let sig = match inputs. kind ( ) {
15921593 ty:: Tuple ( inputs)
1593- if tcx. fn_trait_kind_from_lang_item ( trait_ref. def_id ( ) ) . is_some ( ) =>
1594+ if infcx . tcx . fn_trait_kind_from_lang_item ( trait_ref. def_id ( ) ) . is_some ( ) =>
15941595 {
1595- tcx. mk_fn_sig (
1596+ infcx . tcx . mk_fn_sig (
15961597 inputs. iter ( ) ,
1597- tcx. mk_ty_infer ( ty:: TyVar ( ty:: TyVid :: from_u32 ( 0 ) ) ) ,
1598+ infcx. next_ty_var ( TypeVariableOrigin {
1599+ span : DUMMY_SP ,
1600+ kind : TypeVariableOriginKind :: MiscVariable ,
1601+ } ) ,
15981602 false ,
15991603 hir:: Unsafety :: Normal ,
16001604 abi:: Abi :: Rust ,
16011605 )
16021606 }
1603- _ => tcx. mk_fn_sig (
1607+ _ => infcx . tcx . mk_fn_sig (
16041608 std:: iter:: once ( inputs) ,
1605- tcx. mk_ty_infer ( ty:: TyVar ( ty:: TyVid :: from_u32 ( 0 ) ) ) ,
1609+ infcx. next_ty_var ( TypeVariableOrigin {
1610+ span : DUMMY_SP ,
1611+ kind : TypeVariableOriginKind :: MiscVariable ,
1612+ } ) ,
16061613 false ,
16071614 hir:: Unsafety :: Normal ,
16081615 abi:: Abi :: Rust ,
16091616 ) ,
16101617 } ;
16111618
1612- tcx. mk_fn_ptr ( trait_ref. rebind ( sig) )
1619+ infcx . tcx . mk_fn_ptr ( trait_ref. rebind ( sig) )
16131620 }
16141621
16151622 let argument_kind = match expected. skip_binder ( ) . self_ty ( ) . kind ( ) {
@@ -1629,8 +1636,8 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
16291636 let found_span = found_span. unwrap_or ( span) ;
16301637 err. span_label ( found_span, "found signature defined here" ) ;
16311638
1632- let expected = build_fn_sig_ty ( self . tcx , expected) ;
1633- let found = build_fn_sig_ty ( self . tcx , found) ;
1639+ let expected = build_fn_sig_ty ( self , expected) ;
1640+ let found = build_fn_sig_ty ( self , found) ;
16341641
16351642 let ( expected_str, found_str) = self . cmp ( expected, found) ;
16361643
0 commit comments