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