@@ -257,9 +257,7 @@ fn adt_destructor(tcx: TyCtxt<'_>, def_id: DefId) -> Option<ty::Destructor> {
257257}
258258
259259/// If this `DefId` is a "primary tables entry", returns
260- /// `Some((body_id, header, decl))` with information about
261- /// its body-id, fn-header and fn-decl (if any). Otherwise,
262- /// returns `None`.
260+ /// `Some((body_id, body_ty, fn_sig))`. Otherwise, returns `None`.
263261///
264262/// If this function returns `Some`, then `typeck_results(def_id)` will
265263/// succeed; if it returns `None`, then `typeck_results(def_id)` may or
@@ -269,32 +267,28 @@ fn adt_destructor(tcx: TyCtxt<'_>, def_id: DefId) -> Option<ty::Destructor> {
269267fn primary_body_of (
270268 tcx : TyCtxt < ' _ > ,
271269 id : hir:: HirId ,
272- ) -> Option < ( hir:: BodyId , Option < & hir:: Ty < ' _ > > , Option < & hir:: FnHeader > , Option < & hir :: FnDecl < ' _ > > ) > {
270+ ) -> Option < ( hir:: BodyId , Option < & hir:: Ty < ' _ > > , Option < & hir:: FnSig < ' _ > > ) > {
273271 match tcx. hir ( ) . get ( id) {
274272 Node :: Item ( item) => match item. kind {
275273 hir:: ItemKind :: Const ( ref ty, body) | hir:: ItemKind :: Static ( ref ty, _, body) => {
276- Some ( ( body, Some ( ty) , None , None ) )
277- }
278- hir:: ItemKind :: Fn ( ref sig, .., body) => {
279- Some ( ( body, None , Some ( & sig. header ) , Some ( & sig. decl ) ) )
274+ Some ( ( body, Some ( ty) , None ) )
280275 }
276+ hir:: ItemKind :: Fn ( ref sig, .., body) => Some ( ( body, None , Some ( & sig) ) ) ,
281277 _ => None ,
282278 } ,
283279 Node :: TraitItem ( item) => match item. kind {
284- hir:: TraitItemKind :: Const ( ref ty, Some ( body) ) => Some ( ( body, Some ( ty) , None , None ) ) ,
280+ hir:: TraitItemKind :: Const ( ref ty, Some ( body) ) => Some ( ( body, Some ( ty) , None ) ) ,
285281 hir:: TraitItemKind :: Fn ( ref sig, hir:: TraitFn :: Provided ( body) ) => {
286- Some ( ( body, None , Some ( & sig. header ) , Some ( & sig . decl ) ) )
282+ Some ( ( body, None , Some ( & sig) ) )
287283 }
288284 _ => None ,
289285 } ,
290286 Node :: ImplItem ( item) => match item. kind {
291- hir:: ImplItemKind :: Const ( ref ty, body) => Some ( ( body, Some ( ty) , None , None ) ) ,
292- hir:: ImplItemKind :: Fn ( ref sig, body) => {
293- Some ( ( body, None , Some ( & sig. header ) , Some ( & sig. decl ) ) )
294- }
287+ hir:: ImplItemKind :: Const ( ref ty, body) => Some ( ( body, Some ( ty) , None ) ) ,
288+ hir:: ImplItemKind :: Fn ( ref sig, body) => Some ( ( body, None , Some ( & sig) ) ) ,
295289 _ => None ,
296290 } ,
297- Node :: AnonConst ( constant) => Some ( ( constant. body , None , None , None ) ) ,
291+ Node :: AnonConst ( constant) => Some ( ( constant. body , None , None ) ) ,
298292 _ => None ,
299293 }
300294}
@@ -362,14 +356,14 @@ fn typeck_with_fallback<'tcx>(
362356 let span = tcx. hir ( ) . span ( id) ;
363357
364358 // Figure out what primary body this item has.
365- let ( body_id, body_ty, fn_header , fn_decl ) = primary_body_of ( tcx, id) . unwrap_or_else ( || {
359+ let ( body_id, body_ty, fn_sig ) = primary_body_of ( tcx, id) . unwrap_or_else ( || {
366360 span_bug ! ( span, "can't type-check body of {:?}" , def_id) ;
367361 } ) ;
368362 let body = tcx. hir ( ) . body ( body_id) ;
369363
370364 let typeck_results = Inherited :: build ( tcx, def_id) . enter ( |inh| {
371365 let param_env = tcx. param_env ( def_id) ;
372- let fcx = if let ( Some ( header) , Some ( decl) ) = ( fn_header , fn_decl ) {
366+ let fcx = if let Some ( hir :: FnSig { header, decl, .. } ) = fn_sig {
373367 let fn_sig = if crate :: collect:: get_infer_ret_ty ( & decl. output ) . is_some ( ) {
374368 let fcx = FnCtxt :: new ( & inh, param_env, body. value . hir_id ) ;
375369 <dyn AstConv < ' _ > >:: ty_of_fn (
@@ -513,7 +507,7 @@ fn typeck_with_fallback<'tcx>(
513507
514508 fcx. select_all_obligations_or_error ( ) ;
515509
516- if fn_decl . is_some ( ) {
510+ if fn_sig . is_some ( ) {
517511 fcx. regionck_fn ( id, body) ;
518512 } else {
519513 fcx. regionck_expr ( body) ;
0 commit comments