@@ -257,9 +257,7 @@ fn adt_destructor(tcx: TyCtxt<'_>, def_id: DefId) -> Option<ty::Destructor> {
257
257
}
258
258
259
259
/// 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`.
263
261
///
264
262
/// If this function returns `Some`, then `typeck_results(def_id)` will
265
263
/// 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> {
269
267
fn primary_body_of (
270
268
tcx : TyCtxt < ' _ > ,
271
269
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 < ' _ > > ) > {
273
271
match tcx. hir ( ) . get ( id) {
274
272
Node :: Item ( item) => match item. kind {
275
273
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 ) )
280
275
}
276
+ hir:: ItemKind :: Fn ( ref sig, .., body) => Some ( ( body, None , Some ( & sig) ) ) ,
281
277
_ => None ,
282
278
} ,
283
279
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 ) ) ,
285
281
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) ) )
287
283
}
288
284
_ => None ,
289
285
} ,
290
286
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) ) ) ,
295
289
_ => None ,
296
290
} ,
297
- Node :: AnonConst ( constant) => Some ( ( constant. body , None , None , None ) ) ,
291
+ Node :: AnonConst ( constant) => Some ( ( constant. body , None , None ) ) ,
298
292
_ => None ,
299
293
}
300
294
}
@@ -362,14 +356,14 @@ fn typeck_with_fallback<'tcx>(
362
356
let span = tcx. hir ( ) . span ( id) ;
363
357
364
358
// 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 ( || {
366
360
span_bug ! ( span, "can't type-check body of {:?}" , def_id) ;
367
361
} ) ;
368
362
let body = tcx. hir ( ) . body ( body_id) ;
369
363
370
364
let typeck_results = Inherited :: build ( tcx, def_id) . enter ( |inh| {
371
365
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 {
373
367
let fn_sig = if crate :: collect:: get_infer_ret_ty ( & decl. output ) . is_some ( ) {
374
368
let fcx = FnCtxt :: new ( & inh, param_env, body. value . hir_id ) ;
375
369
<dyn AstConv < ' _ > >:: ty_of_fn (
@@ -513,7 +507,7 @@ fn typeck_with_fallback<'tcx>(
513
507
514
508
fcx. select_all_obligations_or_error ( ) ;
515
509
516
- if fn_decl . is_some ( ) {
510
+ if fn_sig . is_some ( ) {
517
511
fcx. regionck_fn ( id, body) ;
518
512
} else {
519
513
fcx. regionck_expr ( body) ;
0 commit comments