@@ -2641,8 +2641,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
26412641 }
26422642
26432643 /// 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).
26462647 fn get_hir_param_info (
26472648 & self ,
26482649 def_id : DefId ,
@@ -2667,6 +2668,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
26672668 kind : hir:: ItemKind :: Fn { sig, generics, body, .. } ,
26682669 ..
26692670 } ) => ( 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) ) ,
26702675 _ => return None ,
26712676 } ;
26722677
@@ -2700,7 +2705,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
27002705 ) )
27012706 }
27022707 ( None , Some ( params) ) => {
2703- let params = params. get ( is_method as usize ..) ?;
2708+ let params = params. get ( is_method as usize ..params . len ( ) - sig . decl . c_variadic as usize ) ?;
27042709 debug_assert_eq ! ( params. len( ) , fn_inputs. len( ) ) ;
27052710 Some ( (
27062711 fn_inputs. zip ( params. iter ( ) . map ( |param| FnParam :: Name ( param) ) ) . collect ( ) ,
0 commit comments