@@ -303,13 +303,20 @@ struct ExtractedHirInfo {
303
303
}
304
304
305
305
fn extract_hir_info < ' tcx > ( tcx : TyCtxt < ' tcx > , def_id : LocalDefId ) -> ExtractedHirInfo {
306
+ // FIXME(#79625): Consider improving MIR to provide the information needed, to avoid going back
307
+ // to HIR for it.
308
+
306
309
let source_map = tcx. sess . source_map ( ) ;
307
- let ( some_fn_sig, hir_body) = fn_sig_and_body ( tcx, def_id) ;
310
+
311
+ let hir_node = tcx. hir_node_by_def_id ( def_id) ;
312
+ let ( _, fn_body_id) =
313
+ hir:: map:: associated_body ( hir_node) . expect ( "HIR node is a function with body" ) ;
314
+ let hir_body = tcx. hir ( ) . body ( fn_body_id) ;
308
315
309
316
let body_span = get_body_span ( tcx, hir_body, def_id) ;
310
317
311
318
let source_file = source_map. lookup_source_file ( body_span. lo ( ) ) ;
312
- let fn_sig_span = match some_fn_sig . filter ( |fn_sig| {
319
+ let fn_sig_span = match hir_node . fn_sig ( ) . filter ( |fn_sig| {
313
320
fn_sig. span . eq_ctxt ( body_span)
314
321
&& Lrc :: ptr_eq ( & source_file, & source_map. lookup_source_file ( fn_sig. span . lo ( ) ) )
315
322
} ) {
@@ -322,18 +329,6 @@ fn extract_hir_info<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> ExtractedHir
322
329
ExtractedHirInfo { function_source_hash, fn_sig_span, body_span }
323
330
}
324
331
325
- fn fn_sig_and_body (
326
- tcx : TyCtxt < ' _ > ,
327
- def_id : LocalDefId ,
328
- ) -> ( Option < & rustc_hir:: FnSig < ' _ > > , & rustc_hir:: Body < ' _ > ) {
329
- // FIXME(#79625): Consider improving MIR to provide the information needed, to avoid going back
330
- // to HIR for it.
331
- let hir_node = tcx. hir_node_by_def_id ( def_id) ;
332
- let ( _, fn_body_id) =
333
- hir:: map:: associated_body ( hir_node) . expect ( "HIR node is a function with body" ) ;
334
- ( hir_node. fn_sig ( ) , tcx. hir ( ) . body ( fn_body_id) )
335
- }
336
-
337
332
fn get_body_span < ' tcx > (
338
333
tcx : TyCtxt < ' tcx > ,
339
334
hir_body : & rustc_hir:: Body < ' tcx > ,
0 commit comments