@@ -20,6 +20,7 @@ use rustc_hir::def_id::DefId;
20
20
use rustc_hir:: intravisit:: Visitor ;
21
21
use rustc_hir:: lang_items:: LangItem ;
22
22
use rustc_hir:: { AsyncGeneratorKind , GeneratorKind , Node } ;
23
+ use rustc_infer:: infer:: type_variable:: { TypeVariableOrigin , TypeVariableOriginKind } ;
23
24
use rustc_middle:: hir:: map;
24
25
use rustc_middle:: ty:: {
25
26
self , suggest_arbitrary_trait_bound, suggest_constraining_type_param, AdtKind , DefIdTree ,
@@ -1584,32 +1585,38 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
1584
1585
expected : ty:: PolyTraitRef < ' tcx > ,
1585
1586
) -> DiagnosticBuilder < ' tcx , ErrorGuaranteed > {
1586
1587
pub ( crate ) fn build_fn_sig_ty < ' tcx > (
1587
- tcx : TyCtxt < ' tcx > ,
1588
+ infcx : & InferCtxt < ' _ , ' tcx > ,
1588
1589
trait_ref : ty:: PolyTraitRef < ' tcx > ,
1589
1590
) -> Ty < ' tcx > {
1590
1591
let inputs = trait_ref. skip_binder ( ) . substs . type_at ( 1 ) ;
1591
1592
let sig = match inputs. kind ( ) {
1592
1593
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 ( ) =>
1594
1595
{
1595
- tcx. mk_fn_sig (
1596
+ infcx . tcx . mk_fn_sig (
1596
1597
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
+ } ) ,
1598
1602
false ,
1599
1603
hir:: Unsafety :: Normal ,
1600
1604
abi:: Abi :: Rust ,
1601
1605
)
1602
1606
}
1603
- _ => tcx. mk_fn_sig (
1607
+ _ => infcx . tcx . mk_fn_sig (
1604
1608
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
+ } ) ,
1606
1613
false ,
1607
1614
hir:: Unsafety :: Normal ,
1608
1615
abi:: Abi :: Rust ,
1609
1616
) ,
1610
1617
} ;
1611
1618
1612
- tcx. mk_fn_ptr ( trait_ref. rebind ( sig) )
1619
+ infcx . tcx . mk_fn_ptr ( trait_ref. rebind ( sig) )
1613
1620
}
1614
1621
1615
1622
let argument_kind = match expected. skip_binder ( ) . self_ty ( ) . kind ( ) {
@@ -1629,8 +1636,8 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
1629
1636
let found_span = found_span. unwrap_or ( span) ;
1630
1637
err. span_label ( found_span, "found signature defined here" ) ;
1631
1638
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) ;
1634
1641
1635
1642
let ( expected_str, found_str) = self . cmp ( expected, found) ;
1636
1643
0 commit comments