File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed
compiler/rustc_mir_transform/src/coverage Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -313,14 +313,16 @@ fn extract_hir_info<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> ExtractedHir
313313 let body_span = get_body_span ( tcx, hir_body, def_id) ;
314314
315315 // The actual signature span is only used if it has the same context and
316- // filename as the body.
316+ // filename as the body, and precedes the body .
317317 let maybe_fn_sig_span = hir_node. fn_sig ( ) . map ( |fn_sig| fn_sig. span ) ;
318318 let fn_sig_span = maybe_fn_sig_span
319319 . filter ( |& fn_sig_span| {
320320 let source_map = tcx. sess . source_map ( ) ;
321321 let file_idx = |span : Span | source_map. lookup_source_file_idx ( span. lo ( ) ) ;
322322
323- fn_sig_span. eq_ctxt ( body_span) && file_idx ( fn_sig_span) == file_idx ( body_span)
323+ fn_sig_span. eq_ctxt ( body_span)
324+ && fn_sig_span. hi ( ) <= body_span. lo ( )
325+ && file_idx ( fn_sig_span) == file_idx ( body_span)
324326 } )
325327 // If so, extend it to the start of the body span.
326328 . map ( |fn_sig_span| fn_sig_span. with_hi ( body_span. lo ( ) ) )
You can’t perform that action at this time.
0 commit comments