@@ -2641,8 +2641,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
2641
2641
}
2642
2642
2643
2643
/// Returns the parameters of a function, with their generic parameters if those are the full
2644
- /// type of that parameter. Returns `None` if the function has no generics or the body is
2645
- /// unavailable (eg is an instrinsic).
2644
+ /// type of that parameter.
2645
+ ///
2646
+ /// Returns `None` if the body is not a named function (e.g. a closure).
2646
2647
fn get_hir_param_info (
2647
2648
& self ,
2648
2649
def_id : DefId ,
@@ -2667,6 +2668,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
2667
2668
kind : hir:: ItemKind :: Fn { sig, generics, body, .. } ,
2668
2669
..
2669
2670
} ) => ( sig, generics, Some ( body) , None ) ,
2671
+ hir:: Node :: ForeignItem ( & hir:: ForeignItem {
2672
+ kind : hir:: ForeignItemKind :: Fn ( sig, params, generics) ,
2673
+ ..
2674
+ } ) => ( sig, generics, None , Some ( params) ) ,
2670
2675
_ => return None ,
2671
2676
} ;
2672
2677
@@ -2700,7 +2705,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
2700
2705
) )
2701
2706
}
2702
2707
( None , Some ( params) ) => {
2703
- let params = params. get ( is_method as usize ..) ?;
2708
+ let params =
2709
+ params. get ( is_method as usize ..params. len ( ) - sig. decl . c_variadic as usize ) ?;
2704
2710
debug_assert_eq ! ( params. len( ) , fn_inputs. len( ) ) ;
2705
2711
Some ( (
2706
2712
fn_inputs. zip ( params. iter ( ) . map ( |param| FnParam :: Name ( param) ) ) . collect ( ) ,
0 commit comments